- Create a 'granular token' with the right permissions
- Create a new 'Secrets and Variables > Action > Repository Secrets' named
NPM_PUBLISH_TOKEN
- The name must match the content of the release workflow
- The value is the granular token
- Create a new release using a tag whose format is
v.x.x.x
The current TypeScript version for the project is 4.9.x
. When it's time to move up to 5
, both package.json and dependabot.yaml must be updated accordingly.
-
Use
nyc
with at least thehtml
andcobertura
reports (see nyc configuration). -
The script
npm run test:coverage
runs the tests generating the coverage report into./coverage/report
.
This action does not run the test but...
-
Uses irongut/[email protected] to both output the coverage and to generate a nice markdown file, which includes a
img.shields.io
badge. -
Uses
marocchino/sticky-pull-request-comment@v2
to add a comment to the PR stating the coverage. -
Runs a bash script that isolates the badge from the generated markdown on step 1 and downloads the respective
.svg
file, saving it to./coverage/coverage.svg
file.
-
The Github repository pages is set to use
Git Actions
to publish the pages, instead of loading them from a branch. -
In the ci workflow
-
The
test
step uses the actionsactions/configure-pages@v3
andactions/upload-pages-artifact@v1
to prepare the pages and to upload the./coverage
directory- Preparing the pages probably just need to be done once, so this may need to change if other steps are uploading content to the pages
-
The
deploy-coverage
job deploys the uploaded content.- This job only works when ran from a branch that is allowed to deploy to the github-pages environment.
- This environment is automatically created when preparing the pages
- At the moment, only
main
is authorized
- A permission error is thrown if the branch is not allowed, with a message that refers to the
id-token
permission - See the documentation for the actions/deploy-pages@v2 action for more details.
- This job only works when ran from a branch that is allowed to deploy to the github-pages environment.
-
The pages for this repository are located at https://m-paternostro.github.io/chai-ts (this can be checked on the GitHub pages, after a workflow has successfully deployed pages). Moreover:
- badge: https://m-paternostro.github.io/chai-ts/coverage.svg
- html report: https://m-paternostro.github.io/chai-ts/report/index.html
With these, it's possible to write the Coverage
badge in the README.md.