Skip to content

Unit Tests

Unit Tests #26675

Workflow file for this run

name: Unit Tests
permissions: {}
on:
pull_request:
push:
schedule:
- cron: '0 8 * * *'
jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
with:
persist-credentials: false
- name: Use Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v6
with:
node-version: '20.20.x'
- run: npm ci
- run: npm run build-glean
# Run the regular tests on push
- run: npm test
if: github.event_name != 'schedule'
# But measure coverage without ignore markers in the nighly job
- name: Remove `c8 ignore` markers to output full unit test coverage if on the `report-coverage` branch
run: find src/ -type f -name "*.js" -or -name "*.ts" -or -name "*.jsx" -or -name "*.tsx" -exec sed --in-place --expression='s/c8 ignore/c8 TEMPORARILY DO NOT ignore/g' {} \;
if: github.event_name == 'schedule'
# (and set an arbitrary coverage threshold for that "true" coverage):
- run: npm test -- --coverage.thresholds.lines=80 --coverage.thresholds.functions=80 --coverage.thresholds.branches=80 --coverage.thresholds.statements=80
if: github.event_name == 'schedule'
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: always()
with:
name: coverage-report
path: coverage/
retention-days: 30