diff --git a/.github/actions/run-and-save-test-coverage/action.yml b/.github/actions/run-and-save-test-coverage/action.yml index e2f80d915be..3a1d8c58ade 100644 --- a/.github/actions/run-and-save-test-coverage/action.yml +++ b/.github/actions/run-and-save-test-coverage/action.yml @@ -8,7 +8,7 @@ runs: using: "composite" steps: - name: Unit tests with coverage - run: pnpm vitest run --coverage --reporter json --outputFile ./coverage/report.json + run: pnpm vitest run --coverage --coverage.all=false --reporter=json --outputFile=./coverage/report.json shell: bash env: VITEST_MIN_THREADS: "1" diff --git a/.github/actions/setup-cli-deps/action.yml b/.github/actions/setup-cli-deps/action.yml index 37a8810e32f..29d2181e00a 100644 --- a/.github/actions/setup-cli-deps/action.yml +++ b/.github/actions/setup-cli-deps/action.yml @@ -25,5 +25,5 @@ runs: cache: 'pnpm' cache-dependency-path: 'pnpm-lock.yaml' - name: Install dependencies - run: pnpm install --frozen-lockfile + run: pnpm install --frozen-lockfile --prefer-offline shell: bash diff --git a/.github/workflows/tests-pr.yml b/.github/workflows/tests-pr.yml index 19642321aee..63beb8b4d47 100644 --- a/.github/workflows/tests-pr.yml +++ b/.github/workflows/tests-pr.yml @@ -147,13 +147,45 @@ jobs: 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; }' unit-tests: - name: 'Unit tests with Node ${{ matrix.node }} in ${{ matrix.os }}' + name: "Unit tests with Node ${{ matrix.node }} in ${{ matrix.os }}${{ matrix.shard != '' && format(' (shard {0})', matrix.shard) || '' }}" runs-on: ${{ matrix.os }} timeout-minutes: 30 strategy: matrix: os: [ 'ubuntu-latest', 'windows-latest', 'macos-latest' ] node: [ '20.14.0', '22.2.0', '24.1.0' ] + shard: [ '' ] + include: + # Add sharding for Windows jobs to reduce wall-clock time + - os: windows-latest + node: '20.14.0' + shard: '1/2' + - os: windows-latest + node: '20.14.0' + shard: '2/2' + - os: windows-latest + node: '22.2.0' + shard: '1/2' + - os: windows-latest + node: '22.2.0' + shard: '2/2' + - os: windows-latest + node: '24.1.0' + shard: '1/2' + - os: windows-latest + node: '24.1.0' + shard: '2/2' + exclude: + # Exclude the non-sharded Windows entries (replaced by sharded ones above) + - os: windows-latest + node: '20.14.0' + shard: '' + - os: windows-latest + node: '22.2.0' + shard: '' + - os: windows-latest + node: '24.1.0' + shard: '' steps: - uses: actions/checkout@v3 with: @@ -165,16 +197,30 @@ jobs: with: node-version: ${{ matrix.node }} - name: Unit tests - run: pnpm vitest run + run: pnpm vitest run ${{ matrix.shard && format('--shard {0}', matrix.shard) || '' }} env: VITEST_MIN_THREADS: "1" VITEST_MAX_THREADS: "4" - test-coverage: + unit-tests-gate: + name: "Unit tests" + needs: unit-tests + if: always() + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - name: Verify all unit tests passed + if: needs.unit-tests.result != 'success' + run: exit 1 + + test-coverage-shard: if: ${{ github.event.pull_request.user.login != 'dependabot[bot]' }} - name: 'Test Coverage' + name: "Test Coverage (shard ${{ matrix.shard }})" runs-on: ubuntu-latest timeout-minutes: 30 + strategy: + matrix: + shard: ['1/2', '2/2'] steps: - uses: actions/checkout@v3 with: @@ -185,12 +231,54 @@ jobs: uses: ./.github/actions/setup-cli-deps with: node-version: ${{ env.DEFAULT_NODE_VERSION }} - - name: Build - run: pnpm nx run-many --all --skip-nx-cache --target=build --output-style=stream - - name: Run and save test coverage - uses: ./.github/actions/run-and-save-test-coverage + - name: Unit tests with coverage (shard) + 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 }} + env: + VITEST_MIN_THREADS: "1" + VITEST_MAX_THREADS: "4" + - uses: actions/upload-artifact@v4 + with: + name: coverage-blob-${{ matrix.shard == '1/2' && '1' || '2' }} + path: vitest-blob-reports/ + retention-days: 1 + + test-coverage-merge: + if: ${{ github.event.pull_request.user.login != 'dependabot[bot]' }} + needs: test-coverage-shard + name: 'Test Coverage' + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v3 + with: + repository: ${{ github.event.pull_request.head.repo.full_name || github.event.repository.full_name }} + ref: ${{ github.event.pull_request.head.ref || github.event.merge_group.head_ref }} + fetch-depth: 1 + - name: Setup deps + uses: ./.github/actions/setup-cli-deps + with: + node-version: ${{ env.DEFAULT_NODE_VERSION }} + - uses: actions/download-artifact@v4 + with: + pattern: coverage-blob-* + path: vitest-blob-reports + merge-multiple: true + - name: Merge coverage reports + run: pnpm vitest --mergeReports vitest-blob-reports --reporter=json --outputFile=./coverage/report.json --coverage --coverage.all=false + - name: Convert coverage to Jest + run: ./bin/save-coverage-file.js + - name: Take copy of report as new baseline for branch + run: cp ./report.json ./baseline-report.json + - name: Clean ref name + env: + SAFE_REF_NAME: "${{ github.head_ref }}" + run: | + SAFE_REF_NAME="${SAFE_REF_NAME//[\/.]/}" + echo "SAFE_REF_NAME=${SAFE_REF_NAME}" >> $GITHUB_ENV + - uses: actions/upload-artifact@v4 with: - branch-name: '${{ github.head_ref }}' + name: ${{ env.SAFE_REF_NAME }}--coverage-report + path: ./baseline-report.json - name: Download and publish test coverage uses: ./.github/actions/download-and-publish-test-coverage with: diff --git a/README.md b/README.md index 8c83357a545..85f501ef784 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Learn more in the docs: [Create an app](https://shopify.dev/apps/getting-started To work with themes, the CLI needs to be installed globally with: -- `npm install -g @shopify/cli @shopify/theme` +- `npm install -g @shopify/cli` You can also use do it through Homebrew on macOS: `brew tap shopify/shopify && brew install shopify-cli` diff --git a/configurations/vite.config.ts b/configurations/vite.config.ts index 09ec4ee55d3..c7fc06c8030 100644 --- a/configurations/vite.config.ts +++ b/configurations/vite.config.ts @@ -36,7 +36,7 @@ export default function config(packagePath: string, {poolStrategy}: ConfigOption clearMocks: true, mockReset: true, // Note: In Vitest 3.0, mockReset restores the original implementation setupFiles: [path.join(__dirname, './vitest/setup.js')], - reporters: ['verbose', 'hanging-process'], + reporters: process.env.CI ? ['basic'] : ['verbose', 'hanging-process'], pool: poolStrategy, coverage: { provider: 'istanbul', diff --git a/vitest.workspace.json b/vitest.workspace.json index a34f6c8699d..b6523d9888e 100644 --- a/vitest.workspace.json +++ b/vitest.workspace.json @@ -6,6 +6,5 @@ "packages/plugin-did-you-mean", "packages/theme", "packages/ui-extensions-dev-console", - "packages/ui-extensions-server-kit", - "packages/ui-extensions-test-utils" + "packages/ui-extensions-server-kit" ]