Skip to content

Update test-vitest-coverage-action.yml #43

Update test-vitest-coverage-action.yml

Update test-vitest-coverage-action.yml #43

name: "Test"
on:
push:
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
branch:
- ${{ github.head_ref }}
- "main"
permissions:
# Required to checkout the code
contents: read
steps:
- uses: actions/checkout@v4
with:
ref: ${{ matrix.branch }}
repository: ${{github.event.pull_request.head.repo.full_name}}
- run: echo "Repo is '${{ github.repository }}', PR repo is ${{github.event.pull_request.head.repo.full_name}}"
- name: "Install Node"
uses: actions/setup-node@v4
with:
node-version: "18.x"
- name: "Install Deps"
run: npm install
- uses: actions/github-script@v7
with:
script: |
console.log(JSON.stringify(context, null, 2))
- name: "Test"
run: npx vitest --coverage.enabled true
- name: "Upload Coverage"
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.branch }}
path: coverage
report-coverage:
needs: test
runs-on: ubuntu-latest
steps:
- name: "Download Coverage Artifacts"
uses: actions/download-artifact@v4
with:
name: coverage-${{ github.head_ref }}
path: coverage
- uses: actions/download-artifact@v4
with:
name: coverage-main
path: coverage-main
- name: "Echo Ref"
run: echo ${{ github.ref }}
- name: "Report Coverage"
uses: davelosert/vitest-coverage-report-action@test-automatic-pr
with:
json-summary-compare-path: coverage-main/coverage-summary.json
pr-number: ${{ github.ref == 'refs/heads/main' && 'none' || 'auto' }}