fix: use npm cli commands for version retrieval for better compatibility with workspaces #110
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: Tests | |
on: | |
pull_request: | |
branches: [main] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref }} | |
cancel-in-progress: true | |
jobs: | |
unit-tests: | |
name: Run unit tests | |
runs-on: ubuntu-20.04 | |
timeout-minutes: 5 | |
steps: | |
- name: Check out Git repository | |
uses: actions/[email protected] | |
- name: Parse .tool-versions | |
uses: wistia/[email protected] | |
- name: Set up Node.js environment | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODEJS_TOOL_VERSION }} | |
- name: Cache node_modules | |
uses: actions/cache@v4 | |
id: cache-modules | |
with: | |
path: '**/node_modules' | |
key: ${{ runner.os }}-node${{ env.NODEJS_TOOL_VERSION }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node${{ env.NODEJS_TOOL_VERSION }}- | |
- name: Install Node.js dependencies | |
if: steps.cache-modules.outputs.cache-hit != 'true' | |
run: npm ci | |
- name: Run unit tests | |
run: npm run test:coverage | |
env: | |
NODE_ENV: test | |
- name: Report coverage | |
if: always() | |
uses: davelosert/vitest-coverage-report-action@v2 |