Skip to content

Commit 44dee81

Browse files
committed
chore(ci): run jest tests in a separate workflow
1 parent 512e16a commit 44dee81

File tree

3 files changed

+79
-5
lines changed

3 files changed

+79
-5
lines changed

.github/workflows/cli-test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373
run: |
7474
node -v
7575
npm -v
76-
pnpm test -- --silent --selectProjects=@sanity/cli
76+
pnpm test:jest --silent --selectProjects=@sanity/cli
7777
env:
7878
# Update token in github and change below to ${{ secrets.SANITY_CI_CLI_AUTH_TOKEN }} after merge to next
7979
SANITY_CI_CLI_AUTH_TOKEN_STAGING: ${{ secrets.SANITY_CI_CLI_AUTH_TOKEN_STAGING }}

.github/workflows/jest.yml

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Unit tests
2+
3+
on:
4+
# Build on pushes branches that have a PR (including drafts)
5+
pull_request:
6+
# Build on commits pushed to branches without a PR if it's in the allowlist
7+
push:
8+
branches: [next]
9+
10+
jobs:
11+
test:
12+
timeout-minutes: 60
13+
name: Jest tests (${{ matrix.os }} / node ${{ matrix.node }})
14+
runs-on: ${{ matrix.os }}
15+
env:
16+
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
17+
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
18+
continue-on-error: ${{ matrix.experimental }}
19+
20+
strategy:
21+
# we want to know if a test fails on a specific node version
22+
fail-fast: false
23+
matrix:
24+
os: [ubuntu-latest]
25+
node: [18, 20]
26+
experimental: [false]
27+
shardIndex: [1, 2, 3, 4]
28+
shardTotal: [4]
29+
# include:
30+
# - os: windows-latest
31+
# node: 16
32+
# experimental: true
33+
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v4
37+
38+
- name: Setup node
39+
uses: actions/setup-node@v4
40+
with:
41+
node-version: ${{ matrix.node }}
42+
43+
- uses: pnpm/action-setup@v4
44+
name: Install pnpm
45+
id: pnpm-install
46+
with:
47+
run_install: false
48+
49+
- name: Get pnpm store directory
50+
id: pnpm-cache
51+
shell: bash
52+
run: |
53+
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
54+
55+
- name: Cache node modules
56+
id: cache-node-modules
57+
uses: actions/cache@v4
58+
env:
59+
cache-name: cache-node-modules
60+
with:
61+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
62+
key: ${{ runner.os }}-pnpm-store-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }}
63+
restore-keys: |
64+
v1-${{ runner.os }}-pnpm-store-${{ env.cache-name }}-
65+
v1-${{ runner.os }}-pnpm-store-
66+
v1-${{ runner.os }}-
67+
68+
- name: Install project dependencies
69+
run: pnpm install
70+
71+
- name: Test
72+
id: test
73+
run: |
74+
node -v
75+
pnpm test:jest --silent --shard=${{ matrix.shardIndex}}/${{ matrix.shardTotal }} --ignoreProjects=@sanity/cli
76+
env:
77+
GITHUB_SHARD_IDENTIFIER: ${{ matrix.shardIndex }}-${{ matrix.shardTotal }}

.github/workflows/test.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,4 @@ jobs:
7272
id: test
7373
run: |
7474
node -v
75-
npm -v
76-
pnpm test -- --silent --shard=${{ matrix.shardIndex}}/${{ matrix.shardTotal }} --ignoreProjects=@sanity/cli
77-
env:
78-
GITHUB_SHARD_IDENTIFIER: ${{ matrix.shardIndex }}-${{ matrix.shardTotal }}
75+
pnpm test:vitest

0 commit comments

Comments
 (0)