build(deps): bump the minor-and-patch group across 1 directory with 45 updates #43
Workflow file for this run
This file contains 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: Test Workflow | |
on: | |
pull_request: | |
types: [opened, reopened, synchronize] # default PR types | |
branches: [main, next] | |
paths: ["src/**/*", "package*.json"] | |
# This workflow is called by the CI/CD Workflow (see ./cicd.yaml) | |
workflow_call: | |
secrets: | |
CODECOV_TOKEN: { required: true } | |
outputs: | |
success: | |
description: "Whether the tests passed" | |
value: ${{ jobs.run-tests.outputs.success }} | |
# This workflow can be manually triggered | |
workflow_dispatch: | |
permissions: | |
contents: read # to checkout the code | |
pull-requests: write # to add coverage reports to the PR | |
statuses: write # to update commit status | |
jobs: | |
run-tests: | |
name: Test | |
runs-on: ubuntu-latest | |
outputs: | |
success: ${{ steps.run-tests.outputs.success }} | |
permissions: | |
contents: read # to checkout the code | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: ".nvmrc" | |
- name: Setup Dependencies | |
run: npm ci --include=dev | |
- name: Run Linters | |
run: npm run lint | |
- name: Run Tests | |
id: run-tests | |
run: | | |
npm ci --include=dev | |
npm run test:ci | |
echo "success=$( [ $? == 0 ] && echo true || echo false )" \ | |
>> "$GITHUB_OUTPUT" | |
- name: Upload Test Coverage Reports | |
uses: actions/upload-artifact@v4 | |
with: | |
name: test-coverage-reports | |
path: ./coverage | |
report-test-coverage: | |
name: Report Test Coverage | |
runs-on: ubuntu-latest | |
needs: run-tests # only run if tests passed | |
if: needs.run-tests.outputs.success == 'true' | |
permissions: | |
pull-requests: write # to add coverage reports to the PR | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: test-coverage-reports | |
- name: (PR-Only) Update PR with Coverage Reports | |
if: github.event_name == 'pull_request' | |
uses: davelosert/vitest-coverage-report-action@v2 | |
- name: Update CodeCov | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
update-github-commit-status: | |
name: Update GitHub Commit Status | |
runs-on: ubuntu-latest | |
needs: run-tests # always run unless the workflow was cancelled | |
if: ${{ !cancelled() }} | |
permissions: | |
statuses: write # to update commit status | |
steps: | |
- run: | | |
if [ ${{ needs.run-tests.outputs.success }} == 'true' ]; then | |
commit_status_state='success' | |
description='Tests passed' | |
else | |
commit_status_state='failure' | |
description='Tests failed' | |
fi | |
curl --request POST \ | |
--url https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }} \ | |
--header 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ | |
--header 'Accept: application/vnd.github+json' \ | |
--header 'X-GitHub-Api-Version: 2022-11-28' \ | |
--data "{ | |
\"context\": \"tests\", | |
\"state\": \"$commit_status_state\", | |
\"description\": \"$description\", | |
\"target_url\": \"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\" | |
}" |