Skip to content

Commit 6967663

Browse files
Merge pull request #7009 from Shopify/faster-ci
Faster CI
2 parents 6047afe + 49c9939 commit 6967663

6 files changed

Lines changed: 102 additions & 15 deletions

File tree

.github/actions/run-and-save-test-coverage/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ runs:
88
using: "composite"
99
steps:
1010
- name: Unit tests with coverage
11-
run: pnpm vitest run --coverage --reporter json --outputFile ./coverage/report.json
11+
run: pnpm vitest run --coverage --coverage.all=false --reporter=json --outputFile=./coverage/report.json
1212
shell: bash
1313
env:
1414
VITEST_MIN_THREADS: "1"

.github/actions/setup-cli-deps/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ runs:
2525
cache: 'pnpm'
2626
cache-dependency-path: 'pnpm-lock.yaml'
2727
- name: Install dependencies
28-
run: pnpm install --frozen-lockfile
28+
run: pnpm install --frozen-lockfile --prefer-offline
2929
shell: bash

.github/workflows/tests-pr.yml

Lines changed: 97 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,45 @@ jobs:
147147
run: 'test -z "$(git status --porcelain "docs-shopify.dev/generated/*.json" )" || { echo -e "Run (pnpm build-dev-docs) before pushing new commands or flags." ; exit 1; }'
148148

149149
unit-tests:
150-
name: 'Unit tests with Node ${{ matrix.node }} in ${{ matrix.os }}'
150+
name: "Unit tests with Node ${{ matrix.node }} in ${{ matrix.os }}${{ matrix.shard != '' && format(' (shard {0})', matrix.shard) || '' }}"
151151
runs-on: ${{ matrix.os }}
152152
timeout-minutes: 30
153153
strategy:
154154
matrix:
155155
os: [ 'ubuntu-latest', 'windows-latest', 'macos-latest' ]
156156
node: [ '20.14.0', '22.2.0', '24.1.0' ]
157+
shard: [ '' ]
158+
include:
159+
# Add sharding for Windows jobs to reduce wall-clock time
160+
- os: windows-latest
161+
node: '20.14.0'
162+
shard: '1/2'
163+
- os: windows-latest
164+
node: '20.14.0'
165+
shard: '2/2'
166+
- os: windows-latest
167+
node: '22.2.0'
168+
shard: '1/2'
169+
- os: windows-latest
170+
node: '22.2.0'
171+
shard: '2/2'
172+
- os: windows-latest
173+
node: '24.1.0'
174+
shard: '1/2'
175+
- os: windows-latest
176+
node: '24.1.0'
177+
shard: '2/2'
178+
exclude:
179+
# Exclude the non-sharded Windows entries (replaced by sharded ones above)
180+
- os: windows-latest
181+
node: '20.14.0'
182+
shard: ''
183+
- os: windows-latest
184+
node: '22.2.0'
185+
shard: ''
186+
- os: windows-latest
187+
node: '24.1.0'
188+
shard: ''
157189
steps:
158190
- uses: actions/checkout@v3
159191
with:
@@ -165,16 +197,30 @@ jobs:
165197
with:
166198
node-version: ${{ matrix.node }}
167199
- name: Unit tests
168-
run: pnpm vitest run
200+
run: pnpm vitest run ${{ matrix.shard && format('--shard {0}', matrix.shard) || '' }}
169201
env:
170202
VITEST_MIN_THREADS: "1"
171203
VITEST_MAX_THREADS: "4"
172204

173-
test-coverage:
205+
unit-tests-gate:
206+
name: "Unit tests"
207+
needs: unit-tests
208+
if: always()
209+
runs-on: ubuntu-latest
210+
timeout-minutes: 5
211+
steps:
212+
- name: Verify all unit tests passed
213+
if: needs.unit-tests.result != 'success'
214+
run: exit 1
215+
216+
test-coverage-shard:
174217
if: ${{ github.event.pull_request.user.login != 'dependabot[bot]' }}
175-
name: 'Test Coverage'
218+
name: "Test Coverage (shard ${{ matrix.shard }})"
176219
runs-on: ubuntu-latest
177220
timeout-minutes: 30
221+
strategy:
222+
matrix:
223+
shard: ['1/2', '2/2']
178224
steps:
179225
- uses: actions/checkout@v3
180226
with:
@@ -185,12 +231,54 @@ jobs:
185231
uses: ./.github/actions/setup-cli-deps
186232
with:
187233
node-version: ${{ env.DEFAULT_NODE_VERSION }}
188-
- name: Build
189-
run: pnpm nx run-many --all --skip-nx-cache --target=build --output-style=stream
190-
- name: Run and save test coverage
191-
uses: ./.github/actions/run-and-save-test-coverage
234+
- name: Unit tests with coverage (shard)
235+
run: pnpm vitest run --coverage --coverage.all=false --reporter=blob --outputFile=vitest-blob-reports/blob-${{ matrix.shard == '1/2' && '1' || '2' }}.json --shard ${{ matrix.shard }}
236+
env:
237+
VITEST_MIN_THREADS: "1"
238+
VITEST_MAX_THREADS: "4"
239+
- uses: actions/upload-artifact@v4
240+
with:
241+
name: coverage-blob-${{ matrix.shard == '1/2' && '1' || '2' }}
242+
path: vitest-blob-reports/
243+
retention-days: 1
244+
245+
test-coverage-merge:
246+
if: ${{ github.event.pull_request.user.login != 'dependabot[bot]' }}
247+
needs: test-coverage-shard
248+
name: 'Test Coverage'
249+
runs-on: ubuntu-latest
250+
timeout-minutes: 15
251+
steps:
252+
- uses: actions/checkout@v3
253+
with:
254+
repository: ${{ github.event.pull_request.head.repo.full_name || github.event.repository.full_name }}
255+
ref: ${{ github.event.pull_request.head.ref || github.event.merge_group.head_ref }}
256+
fetch-depth: 1
257+
- name: Setup deps
258+
uses: ./.github/actions/setup-cli-deps
259+
with:
260+
node-version: ${{ env.DEFAULT_NODE_VERSION }}
261+
- uses: actions/download-artifact@v4
262+
with:
263+
pattern: coverage-blob-*
264+
path: vitest-blob-reports
265+
merge-multiple: true
266+
- name: Merge coverage reports
267+
run: pnpm vitest --mergeReports vitest-blob-reports --reporter=json --outputFile=./coverage/report.json --coverage --coverage.all=false
268+
- name: Convert coverage to Jest
269+
run: ./bin/save-coverage-file.js
270+
- name: Take copy of report as new baseline for branch
271+
run: cp ./report.json ./baseline-report.json
272+
- name: Clean ref name
273+
env:
274+
SAFE_REF_NAME: "${{ github.head_ref }}"
275+
run: |
276+
SAFE_REF_NAME="${SAFE_REF_NAME//[\/.]/}"
277+
echo "SAFE_REF_NAME=${SAFE_REF_NAME}" >> $GITHUB_ENV
278+
- uses: actions/upload-artifact@v4
192279
with:
193-
branch-name: '${{ github.head_ref }}'
280+
name: ${{ env.SAFE_REF_NAME }}--coverage-report
281+
path: ./baseline-report.json
194282
- name: Download and publish test coverage
195283
uses: ./.github/actions/download-and-publish-test-coverage
196284
with:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Learn more in the docs: [Create an app](https://shopify.dev/apps/getting-started
3737

3838
To work with themes, the CLI needs to be installed globally with:
3939

40-
- `npm install -g @shopify/cli @shopify/theme`
40+
- `npm install -g @shopify/cli`
4141

4242
You can also use do it through Homebrew on macOS: `brew tap shopify/shopify && brew install shopify-cli`
4343

configurations/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default function config(packagePath: string, {poolStrategy}: ConfigOption
3636
clearMocks: true,
3737
mockReset: true, // Note: In Vitest 3.0, mockReset restores the original implementation
3838
setupFiles: [path.join(__dirname, './vitest/setup.js')],
39-
reporters: ['verbose', 'hanging-process'],
39+
reporters: process.env.CI ? ['basic'] : ['verbose', 'hanging-process'],
4040
pool: poolStrategy,
4141
coverage: {
4242
provider: 'istanbul',

vitest.workspace.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@
66
"packages/plugin-did-you-mean",
77
"packages/theme",
88
"packages/ui-extensions-dev-console",
9-
"packages/ui-extensions-server-kit",
10-
"packages/ui-extensions-test-utils"
9+
"packages/ui-extensions-server-kit"
1110
]

0 commit comments

Comments
 (0)