build(deps): bump the minor-and-patch group across 1 directory with 45 updates #54
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: write # to checkout the code and merge dependabot PRs | |
pull-requests: write # to add coverage reports to the PR | |
statuses: write # to update commit status | |
jobs: | |
run-tests: | |
name: 🧪 Run Tests | |
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: Install Dependencies | |
run: npm ci --include=dev | |
- name: Run Linters | |
run: npm run lint | |
- name: Run Tests | |
id: run-tests | |
run: | | |
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 | |
update-codecov: | |
name: ☂️ Update CodeCov | |
runs-on: ubuntu-latest | |
needs: run-tests # only run if tests passed | |
if: needs.run-tests.outputs.success == 'true' | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: { name: test-coverage-reports } | |
- uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
update-pull-request: | |
name: 📝 Update PR | |
runs-on: ubuntu-latest | |
needs: run-tests # only run if tests passed and the event is a PR | |
if: needs.run-tests.outputs.success == 'true' && github.event_name == 'pull_request' | |
permissions: | |
contents: write # to auto-merge dependabot PRs | |
pull-requests: write # to update the PR | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download Test Coverage Reports | |
uses: actions/download-artifact@v4 | |
with: { name: test-coverage-reports, path: ./coverage } | |
- name: Add Vitest Test Coverage Report to PR | |
uses: davelosert/vitest-coverage-report-action@v2 | |
- name: "(dependabot🤖) Approve & Auto-Merge PR" | |
if: github.actor == 'dependabot[bot]' | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PR_URL: ${{ github.event.pull_request.html_url }} | |
run: | | |
gh pr review --approve "$PR_URL" | |
gh pr merge --auto --merge "$PR_URL" | |
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 }}\" | |
}" |