|
| 1 | +name: Run TS tests |
| 2 | +on: |
| 3 | + workflow_call: |
| 4 | + inputs: |
| 5 | + submodules: |
| 6 | + default: false |
| 7 | + required: false |
| 8 | + type: boolean |
| 9 | + runs-on: |
| 10 | + default: ubuntu-24.04-arm |
| 11 | + required: false |
| 12 | + type: string |
| 13 | + workflow_dispatch: |
| 14 | +jobs: |
| 15 | + node: |
| 16 | + name: Node v${{ matrix.node }} typescript |
| 17 | + runs-on: ${{ inputs.runs-on }} |
| 18 | + env: |
| 19 | + MSHOULD_FAST: 1 |
| 20 | + strategy: |
| 21 | + matrix: # May 2025 LTS versions. In release.yml, we hardcode specific v1.2.3 for determinism. |
| 22 | + node: [22, 24] # In tests, it's better to have latest node updates instead. |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@1e31de5234b9f8995739874a8ce0492dc87873e2 # v4 |
| 25 | + with: |
| 26 | + persist-credentials: false |
| 27 | + submodules: ${{ inputs.submodules }} |
| 28 | + - name: Use Node.js ${{ matrix.node }} |
| 29 | + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4 |
| 30 | + with: |
| 31 | + registry-url: "https://registry.npmjs.org" |
| 32 | + cache: npm |
| 33 | + node-version: ${{ matrix.node }} |
| 34 | + - run: npm install |
| 35 | + - run: npm run build --if-present |
| 36 | + - run: npm test |
| 37 | + node: |
| 38 | + name: Node v${{ matrix.node }}, typescript with compilation |
| 39 | + runs-on: ${{ inputs.runs-on }} |
| 40 | + env: |
| 41 | + MSHOULD_FAST: 1 |
| 42 | + strategy: |
| 43 | + matrix: # May 2025 LTS versions. In release.yml, we hardcode specific v1.2.3 for determinism. |
| 44 | + node: [20] |
| 45 | + steps: |
| 46 | + - uses: actions/checkout@1e31de5234b9f8995739874a8ce0492dc87873e2 # v4 |
| 47 | + with: |
| 48 | + persist-credentials: false |
| 49 | + submodules: ${{ inputs.submodules }} |
| 50 | + - name: Use Node.js ${{ matrix.node }} |
| 51 | + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4 |
| 52 | + with: |
| 53 | + registry-url: "https://registry.npmjs.org" |
| 54 | + cache: npm |
| 55 | + node-version: ${{ matrix.node }} |
| 56 | + - run: npm install |
| 57 | + - run: npm run build --if-present |
| 58 | + - run: npm run test:node20 --if-present |
| 59 | + bun: |
| 60 | + name: Bun |
| 61 | + runs-on: ${{ inputs.runs-on }} |
| 62 | + env: |
| 63 | + MSHOULD_FAST: 1 |
| 64 | + steps: |
| 65 | + - uses: actions/checkout@1e31de5234b9f8995739874a8ce0492dc87873e2 # v4 |
| 66 | + with: |
| 67 | + persist-credentials: false |
| 68 | + submodules: ${{ inputs.submodules }} |
| 69 | + - uses: oven-sh/setup-bun@4bc047ad259df6fc24a6c9b0f9a0cb08cf17fbe5 # v2.0.1 |
| 70 | + with: |
| 71 | + bun-version: latest |
| 72 | + - run: bun install |
| 73 | + - run: bun run --if-present build |
| 74 | + - run: bun run --if-present test:bun |
| 75 | + deno: |
| 76 | + name: Deno |
| 77 | + runs-on: ${{ inputs.runs-on }} |
| 78 | + steps: |
| 79 | + - uses: actions/checkout@1e31de5234b9f8995739874a8ce0492dc87873e2 # v4 |
| 80 | + with: |
| 81 | + persist-credentials: false |
| 82 | + submodules: ${{ inputs.submodules }} |
| 83 | + - uses: denoland/setup-deno@909cc5acb0fdd60627fb858598759246509fa755 # v2.0.2 |
| 84 | + with: |
| 85 | + deno-version: v2.x |
| 86 | + - run: grep -q 'test:deno' package.json && deno install || exit 0 |
| 87 | + name: Run deno install if test:deno is present |
| 88 | + - run: grep -q 'build' package.json && deno task build || exit 0 |
| 89 | + name: Run build if present |
| 90 | + - run: grep -q 'test:deno' package.json && deno task test:deno || exit 0 |
| 91 | + name: Run test:deno if present |
| 92 | + lint: |
| 93 | + name: Lint |
| 94 | + runs-on: ${{ inputs.runs-on }} |
| 95 | + steps: |
| 96 | + - uses: actions/checkout@1e31de5234b9f8995739874a8ce0492dc87873e2 # v4 |
| 97 | + with: |
| 98 | + persist-credentials: false |
| 99 | + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4 |
| 100 | + with: |
| 101 | + registry-url: "https://registry.npmjs.org" |
| 102 | + cache: npm |
| 103 | + - run: npm install |
| 104 | + - run: npm run build --if-present |
| 105 | + - run: npm run lint --if-present |
| 106 | + coverage: |
| 107 | + name: Measure coverage |
| 108 | + runs-on: ${{ inputs.runs-on }} |
| 109 | + env: |
| 110 | + MSHOULD_FAST: 0 # Disable parallelism for coverage |
| 111 | + steps: |
| 112 | + - uses: actions/checkout@1e31de5234b9f8995739874a8ce0492dc87873e2 # v4 |
| 113 | + with: |
| 114 | + persist-credentials: false |
| 115 | + submodules: ${{ inputs.submodules }} |
| 116 | + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4 |
| 117 | + with: |
| 118 | + registry-url: "https://registry.npmjs.org" |
| 119 | + cache: npm |
| 120 | + - run: npm install |
| 121 | + - run: npm run build --if-present |
| 122 | + - run: npm install --no-save c8@10.1.2 # Don't want lockfiles. Any better way? |
| 123 | + - run: npx c8 npm test |
0 commit comments