WIP workflow to run tests #31
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Automated test for PRs | |
| # Run any time a PR is created or modified | |
| on: | |
| pull_request: | |
| types: [opened, reopened, synchronize] | |
| env: | |
| # The folder with the doc files | |
| DOCS_FOLDER: 'docs' | |
| # The folder that Docusaurus hosts static files (images) from | |
| STATIC_FOLDER: 'static' | |
| # Images to ignore for image use checks | |
| IGNORE_IMAGES: 'img/site' | |
| # The folder that the tests repo is cloned to | |
| TEST_REPO: 'doclib' | |
| jobs: | |
| # Get files that are added or changed in this PR | |
| # Provides the files as a comma-separated list | |
| getChangedFiles: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| files: ${{ steps.changed-markdown-files.outputs.all_changed_files }} | |
| steps: | |
| # https://github.com/marketplace/actions/changed-files | |
| - name: Get all changed MD/MDX files | |
| id: changed-markdown-files | |
| uses: tj-actions/changed-files@24d32ffd492484c1d75e0c0b894501ddb9d30d62 # v47 | |
| with: | |
| separator: ',' | |
| files: | | |
| docs/**/*.md | |
| docs/**/*.mdx | |
| # Test the changed files | |
| test: | |
| runs-on: ubuntu-latest | |
| needs: [getChangedFiles] | |
| if: ${{ needs.getChangedFiles.outputs.files != '' }} | |
| steps: | |
| # Clone the repo | |
| - uses: actions/checkout@v2 | |
| - uses: actions/setup-node@v1 | |
| with: | |
| node-version: 20 | |
| # Dependencies may not be necessary | |
| # - run: npm ci | |
| # Clone tests from https://gitlab.com/nomadic-labs/doclib | |
| # Uses https://github.com/marketplace/actions/any-clone-repo | |
| - name: Clone test repo | |
| uses: chihqiang/checkout-action@main | |
| with: | |
| repo: https://gitlab.com/nomadic-labs/doclib.git | |
| branch: main | |
| dest: ${{ env.TEST_REPO }} | |
| - name: Install test repo dependencies | |
| working-directory: ${{ env.TEST_REPO }} | |
| run : npm ci | |
| # Run tests | |
| - name: Run image link check | |
| working-directory: ${{ env.TEST_REPO }} | |
| continue-on-error: true | |
| # Here, --docFiles is the list of changed files so the test checks the links to images in only those files | |
| run: npm run imageLinks -- --baseFolder=${{ github.workspace }} --docFiles=${{ needs.getChangedFiles.outputs.files }} --imageFolder=${{ env.STATIC_FOLDER }} | |
| - name: Run unused image check | |
| working-directory: ${{ env.TEST_REPO }} | |
| continue-on-error: true | |
| # Here, --docFiles is the folder where all of the doc files are so the test can check that no images have become abandoned | |
| run: npm run usedImages -- --baseFolder=${{ github.workspace }} --docFiles=${{ env.DOCS_FOLDER }} --imageFolder=${{ env.STATIC_FOLDER }} --ignoreImages=${{ env.IGNORE_IMAGES }} | |
| - name: Run undeclared dependency check | |
| working-directory: ${{ env.TEST_REPO }} | |
| continue-on-error: true | |
| run: npm run proposeDependencies -- --baseFolder=${{ github.workspace }} --docFiles=${{ needs.getChangedFiles.outputs.files }} | |
| - name: Run external link check | |
| working-directory: ${{ env.TEST_REPO }} | |
| continue-on-error: true | |
| run: npm run checkExternalLinks -- --baseFolder=${{ github.workspace }} --docFiles=${{ needs.getChangedFiles.outputs.files }} |