Skip to content

chore(deps): update vitest monorepo to v4.0.6 (#23) #63

chore(deps): update vitest monorepo to v4.0.6 (#23)

chore(deps): update vitest monorepo to v4.0.6 (#23) #63

Workflow file for this run

name: CI - Node.js
on:
push:
branches:
- "main"
- "prod-**"
pull_request:
branches:
- "main"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.workflow_run.head_branch || github.ref }}
cancel-in-progress: ${{ !contains(github.ref, 'main') && !contains(github.ref, 'prod-') }}
permissions:
contents: read
jobs:
lint:
name: Lint
runs-on: ubuntu-24.04
strategy:
matrix:
node-version: [22, 24]
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
- name: Check number of lockfiles
run: |
if [ $(find . -name 'package-lock.json' | grep -vc -e 'node_modules') -gt 0 ]
then
echo -e 'Error: found package-lock files in the repository.\nWe use pnpm workspaces to manage packages so all dependencies should be added via pnpm add'
exit 1
fi
- name: Install pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4
id: pnpm-install
with:
run_install: false
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- name: Check formatting
run: |
pnpm format:check || [ $? -eq 1 ] && printf "\nTip: Run 'pnpm run format' in your terminal to fix this.\n\n"
- name: Lint
run: pnpm lint
test:
name: Test
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
node-version: [22, 24]
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
- name: Install pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4
id: pnpm-install
with:
run_install: false
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"
- name: Install Dependencies
run: |
pnpm install
pnpm fetch-data
- name: Run Tests
run: pnpm test
build:
name: Build
needs: [lint, test]
runs-on: ubuntu-24.04
strategy:
matrix:
node-version: [22, 24]
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
- name: Install pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4
id: pnpm-install
with:
run_install: false
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"
- name: Install and Build
run: |
pnpm install
pnpm fetch-data
pnpm build
test-coverage:
name: Test Coverage
needs: [lint, test]
runs-on: ubuntu-24.04
strategy:
matrix:
node-version: [22, 24]
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
- name: Install pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4
id: pnpm-install
with:
run_install: false
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"
- name: Install Dependencies
run: |
pnpm install
pnpm fetch-data
- name: Run tests with coverage
run: pnpm test:coverage
env:
CI: true
- name: Generate coverage summary
if: always()
run: |
echo "## Test Coverage Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
# Extract coverage summary from packages/server
if [ -f packages/server/coverage/coverage-summary.json ]; then
node -e "
const fs = require('fs');
const coverage = JSON.parse(fs.readFileSync('packages/server/coverage/coverage-summary.json', 'utf8'));
const total = coverage.total;
const formatPercent = (pct) => {
const color = pct >= 90 ? '🟢' : pct >= 80 ? '🟡' : '🔴';
return \`\${color} \${pct.toFixed(2)}%\`;
};
console.log('Coverage Summary:');
console.log('');
console.log('Statements :', formatPercent(total.statements.pct));
console.log('Branches :', formatPercent(total.branches.pct));
console.log('Functions :', formatPercent(total.functions.pct));
console.log('Lines :', formatPercent(total.lines.pct));
console.log('');
console.log('Files tested:', Object.keys(coverage).length - 1);
" >> $GITHUB_STEP_SUMMARY
else
echo "Coverage report not found" >> $GITHUB_STEP_SUMMARY
fi
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
- name: Upload coverage reports
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5
if: always()
with:
files: ./packages/server/coverage/coverage-final.json
flags: unittests
name: codecov-curriculum-db