Skip to content

Commit

Permalink
Image link checker (#225)
Browse files Browse the repository at this point in the history
* Image link checker

* handle modules correctly

* simplify

* Add tests

* run tests as part of build

* move to test folder

* Test passed file paths

* Use Jest in MJS mode

* Allow passing a list of files to test

* try with mocha and chai

* run tests on PRs

* use updated action

* Run on only md and mdx files

* try this way

* add check on files content

* This seems to work with top-level await

* no need to run twice

* try with this PR setting

* correct paths

* remove logging message

* can I skip these steps?

* try adding a reporter

* continue on error so the reporter can do its job

* debug why test report file is not available

* upload artifact

* This didn't work

This reverts commit 3722bfe.

* try with quoted path

* Restore files that I changed to get errors

* Note about testing in readme
  • Loading branch information
timothymcmackin authored Jan 9, 2024
1 parent 9936653 commit 541f6ff
Show file tree
Hide file tree
Showing 8 changed files with 1,548 additions and 33 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ jobs:
with:
node-version: 18
- run: npm ci
- id: files
uses: jitterbit/get-changed-files@v1
- run: npm run test -- --filesToCheck=${{ steps.files.outputs.added_modified }}
- run: npm run build
- uses: aws-actions/configure-aws-credentials@v2
with:
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Tests

on:
pull_request:
types: [opened, reopened, synchronize]

jobs:

checkChangedFiles:
runs-on: ubuntu-latest
outputs:
files: ${{ steps.files.outputs.added_modified }}
steps:
- uses: actions/checkout@v2
- id: files
uses: Ana06/[email protected]
with:
format: 'csv'
filter: '*.mdx?'

test:
runs-on: ubuntu-latest
needs: checkChangedFiles
if: ${{ needs.checkChangedFiles.outputs.files != '' }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 18
- run: npm ci
- run: npm run test -- --reporter JSON --reporter-option output=mocha.json --filesToCheck=${{ needs.checkChangedFiles.outputs.files }}
continue-on-error: true
- run: ls
- uses: dorny/test-reporter@v1
with:
name: Mocha tests
path: 'mocha.json'
reporter: mocha-json
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ node_modules
out
build

filesToTest.txt

6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ npm run start

Finally, open [http://localhost:3000](http://localhost:3000) in your browser to view the website.

## Tests

The workflow `.github/workflows/tests.yml` runs automated tests on pull requests.
To run tests locally, run `npm run test -- --filesToCheck=docs/developing.md,docs/architecture.mdx`, where `--filesToCheck` is a comma-separated list of the MD and MDX files to test.

Docusaurus automatically checks for broken links and markdown-encoded images when you run `npm run build`.

## License

Expand Down
Loading

0 comments on commit 541f6ff

Please sign in to comment.