| 1 | name: Unit Tests |
| 2 | |
| 3 | on: [push, pull_request, merge_group] |
| 4 | |
| 5 | permissions: |
| 6 | contents: read |
| 7 | |
| 8 | jobs: |
| 9 | unit-test: |
| 10 | runs-on: ubuntu-latest |
| 11 | steps: |
| 12 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 13 | |
| 14 | - uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 |
| 15 | # uses version from "packageManager" field in package.json |
| 16 | |
| 17 | - name: Setup Node.js |
| 18 | uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0 |
| 19 | with: |
| 20 | cache: pnpm |
| 21 | node-version-file: '.node-version' |
| 22 | |
| 23 | - name: Install Packages |
| 24 | run: | |
| 25 | pnpm install --frozen-lockfile |
| 26 | env: |
| 27 | CYPRESS_CACHE_FOLDER: .cache/Cypress |
| 28 | |
| 29 | - name: Run Unit Tests |
| 30 | run: | |
| 31 | pnpm test:coverage |
| 32 | |
| 33 | - name: Run ganttDb tests using California timezone |
| 34 | env: |
| 35 | # Makes sure that gantt db works even in a timezone that has daylight savings |
| 36 | # since some days have 25 hours instead of 24. |
| 37 | TZ: America/Los_Angeles |
| 38 | run: | |
| 39 | pnpm exec vitest run ./packages/mermaid/src/diagrams/gantt/ganttDb.spec.ts --coverage |
| 40 | |
| 41 | - name: Verify out-of-tree build with TypeScript |
| 42 | run: | |
| 43 | pnpm test:check:tsc |
| 44 | |
| 45 | - name: Upload Coverage to Codecov |
| 46 | uses: codecov/codecov-action@13ce06bfc6bbe3ecf90edbbf1bc32fe5978ca1d3 # v5.3.1 |
| 47 | # Run step only pushes to develop and pull_requests |
| 48 | if: ${{ github.event_name == 'pull_request' || github.ref == 'refs/heads/develop' }} |
| 49 | with: |
| 50 | files: ./coverage/vitest/lcov.info |
| 51 | flags: unit |
| 52 | name: mermaid-codecov |
| 53 | fail_ci_if_error: false |
| 54 | verbose: true |
| 55 | token: 6845cc80-77ee-4e17-85a1-026cd95e0766 |
| 56 | |