build: update tooling to prep for migration to monorepo #88
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: | |
workflow_dispatch: | |
pull_request: | |
types: [opened, reopened, synchronize] # default PR types | |
branches: [main, next] | |
paths: ["src/**/*", "package*.json", "index.html"] | |
push: | |
branches: [main, next] | |
paths: ["src/**/*", "package*.json", "index.html"] | |
jobs: | |
test: | |
name: Run Tests | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read # to checkout the code | |
issues: write # to comment on released issues | |
pull-requests: write # to add coverage reports to the PR | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: ".nvmrc" | |
- run: npm ci --include=dev | |
- name: Lint | |
run: npm run lint | |
- name: Run Tests | |
if: success() | |
id: run-tests | |
run: npm run test:ci | |
- name: Update GitHub Commit Status | |
if: ${{ !cancelled() }} | |
run: | | |
if [ ${{ steps.run-tests.outcome }} == 'success' ]; 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 'content-type: application/json' \ | |
--data "{ | |
\"context\": \"tests\", | |
\"state\": \"$commit_status_state\", | |
\"description\": \"$description\", | |
\"target_url\": \"https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\" | |
}" | |
- name: Update CodeCov | |
if: success() | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
- name: Update PR with Coverage Reports | |
if: github.event_name == 'pull_request' | |
uses: davelosert/vitest-coverage-report-action@v2 | |
release: | |
name: Release if Tests Passed (push/dispatch only) | |
needs: test | |
if: github.event_name != 'pull_request' && needs.test.result == 'success' | |
uses: ./.github/workflows/release.yaml | |
secrets: | |
SEMANTIC_RELEASE_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }} |