Vitest - GitHub Actions
Running Vitest in Parallel on GitHub Actions using Matrix Workflow
name: Run Vitest
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shard: [1, 2]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "24.x"
- name: Install dependencies
run: npm install
- name: Run tests in shard ${{ matrix.shard }}
run: npx vitest run --shard=${{ matrix.shard }}/2 --reporter=default --reporter=junit --outputFile.junit=./results.xml
# `vitest run` exits non-zero on test failures - report the results anyway
- name: Convert test results to Currents format
if: always()
run: npx currents convert --input-format=junit --input-file=./results.xml --output-dir=.currents --framework=vitest --framework-version=v3.2.4
- name: Upload test results to Currents.dev
if: always()
# CURRENTS_RECORD_KEY is a secret stored in the repository settings
env:
CURRENTS_RECORD_KEY: ${{ secrets.CURRENTS_RECORD_KEY }}
run: |
npx currents upload --project-id XXXXXX --ci-build-id ${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt }}Explore
Last updated
Was this helpful?