> For the complete documentation index, see [llms.txt](https://docs.currents.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.currents.dev/getting-started/other-frameworks/vitest/ci-setup/vitest-github-actions.md).

# Vitest - GitHub Actions

{% hint style="info" %}
TL;DR Check out the example repository:

[https://github.com/currents-dev/currents-junit-xml-example](https://github.com/currents-dev/currents-junit-xml-example/tree/main/packages/vitest)
{% endhint %}

Currents uses the native [Vitest sharding](https://vitest.dev/guide/cli#shard) to split the tests between multiple containers. Each shard writes its own JUnit XML report, converts it and uploads it under a shared [CI Build ID](/guides/parallelization-guide/ci-build-id.md).

Here's an example workflow configuration file:

{% code title=".github/workflows /vitest.yml" overflow="wrap" %}

```yaml
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 }}
```

{% endcode %}

* Get your [Record Key](/guides/record-key.md) and set [GH secret](https://docs.github.com/en/actions/reference/encrypted-secrets) variable`CURRENTS_RECORD_KEY`.
* Update `npx currents upload` `--project-id` argument to [your project's id](/dashboard/projects/project-settings.md).
* Set `--framework-version` to the Vitest version installed in the workflow.

### Explore

<table data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td>@currents/cmd</td><td></td><td></td><td><a href="/pages/gYsC6lIgqlpAND2vLZwQ">/pages/gYsC6lIgqlpAND2vLZwQ</a></td></tr><tr><td>CI Build ID</td><td></td><td></td><td><a href="/pages/d7NOovtmXVrt6HaVXgKq">/pages/d7NOovtmXVrt6HaVXgKq</a></td></tr><tr><td>currents convert</td><td></td><td></td><td><a href="/pages/YOhXCVL31whmI0wKNcAX">/pages/YOhXCVL31whmI0wKNcAX</a></td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.currents.dev/getting-started/other-frameworks/vitest/ci-setup/vitest-github-actions.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
