From a3314d6753e9a3ab7d6a7810ae9eddb2fea498ec Mon Sep 17 00:00:00 2001 From: Binoy Patel Date: Thu, 26 Oct 2023 10:50:40 -0400 Subject: [PATCH 1/5] chore(test): use turbo for testing --- .github/workflows/test.yml | 2 +- packages/sanity/package.json | 2 +- turbo.json | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 990aa2ef775..54c9e0f9d82 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -162,7 +162,7 @@ jobs: run: | node -v npm -v - yarn test --silent --shard=${{ matrix.shardIndex}}/${{ matrix.shardTotal }} + yarn turbo run test env: SANITY_CI_CLI_AUTH_TOKEN: ${{ secrets.SANITY_CI_CLI_AUTH_TOKEN }} GITHUB_SHARD_IDENTIFIER: ${{ matrix.shardIndex }}-${{ matrix.shardTotal }} diff --git a/packages/sanity/package.json b/packages/sanity/package.json index cb04a1e2115..4f19fa52f21 100644 --- a/packages/sanity/package.json +++ b/packages/sanity/package.json @@ -120,7 +120,7 @@ "clean": "rimraf _internal.js cli.js desk.js lib router.js", "coverage": "jest --coverage", "prepublishOnly": "run-s write:version write:ui-version", - "test": "pkg-utils --strict && jest", + "test": "jest", "test:ct": "playwright test -c playwright-ct.config.ts", "watch": "pkg-utils watch --tsconfig tsconfig.lib.json", "write:playwright-report-as-pr-comment": "node -r esbuild-register playwright-ct/scripts/parsePlaywrightReportJson.ts", diff --git a/turbo.json b/turbo.json index 2485589a75f..8b5386ea9d2 100644 --- a/turbo.json +++ b/turbo.json @@ -16,6 +16,7 @@ "build": { "outputs": ["lib/**", "index.js"], "dependsOn": ["^build"] - } + }, + "test": {} } } From a8ca984f87dcb8abda4b5fd62494139f3f33fb52 Mon Sep 17 00:00:00 2001 From: Binoy Patel Date: Thu, 26 Oct 2023 10:55:25 -0400 Subject: [PATCH 2/5] chore(test): update CI config --- .github/workflows/test.yml | 159 ++++++++++++++++++++----------------- package.json | 1 + 2 files changed, 87 insertions(+), 73 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 54c9e0f9d82..ff69c0c988f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,21 +8,104 @@ on: branches: [next] jobs: - install: + # install: + # timeout-minutes: 60 + # name: Install (${{ matrix.os }} / node ${{ matrix.node }}) + # runs-on: ${{ matrix.os }} + # env: + # TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + # TURBO_TEAM: ${{ vars.TURBO_TEAM }} + # continue-on-error: ${{ matrix.experimental }} + + # strategy: + # fail-fast: false + # matrix: + # os: [ubuntu-latest] + # node: [18, 20] + # experimental: [false] + # # include: + # # - os: windows-latest + # # node: 16 + # # experimental: true + + # steps: + # - name: Checkout + # uses: actions/checkout@v4 + + # - name: Setup node + # uses: actions/setup-node@v4 + # with: + # node-version: ${{ matrix.node }} + + # - name: Cache node modules + # id: cache-node-modules + # uses: actions/cache@v3 + # env: + # cache-name: cache-node-modules + # with: + # path: '**/node_modules' + # key: ${{ runner.os }}-modules-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }} + # restore-keys: | + # ${{ runner.os }}-modules-${{ env.cache-name }}- + # ${{ runner.os }}-modules- + # ${{ runner.os }}- + + # - name: Cache build + # id: cache-build + # uses: actions/cache@v3 + # env: + # cache-name: cache-build + # with: + # path: './*' + # key: ${{ runner.os }}-build-${{ matrix.node }}-${{ env.cache-name }}-${{ github.run_id }} + # restore-keys: | + # ${{ runner.os }}-build-${{ env.cache-name }}- + # ${{ runner.os }}-build- + # ${{ runner.os }}- + + # - name: Install project dependencies + # if: steps.cache-node-modules.outputs.cache-hit != 'true' + # run: yarn install --frozen-lockfile + + # - name: Store Playwright's Version + # run: | + # PLAYWRIGHT_VERSION=$(npx playwright --version | sed 's/Version //') + # echo "Playwright's Version: $PLAYWRIGHT_VERSION" + # echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV + + # - name: Cache Playwright Browsers for Playwright's Version + # id: cache-playwright-browsers + # uses: actions/cache@v3 + # with: + # path: ~/.cache/ms-playwright + # key: playwright-browsers-${{ env.PLAYWRIGHT_VERSION }} + + # - name: Install Playwright Browsers + # if: steps.cache-playwright-browsers.outputs.cache-hit != 'true' + # run: npx playwright install --with-deps + + # - name: Build CLI + # run: yarn build:cli # Needed for CLI tests + + test: timeout-minutes: 60 - name: Install (${{ matrix.os }} / node ${{ matrix.node }}) + name: Test (${{ matrix.os }} / node ${{ matrix.node }}) runs-on: ${{ matrix.os }} env: TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} TURBO_TEAM: ${{ vars.TURBO_TEAM }} continue-on-error: ${{ matrix.experimental }} + needs: [install] strategy: + # we want to know if a test fails on a specific node version fail-fast: false matrix: os: [ubuntu-latest] node: [18, 20] experimental: [false] + # shardIndex: [1, 2, 3, 4] + # shardTotal: [4] # include: # - os: windows-latest # node: 16 @@ -87,82 +170,12 @@ jobs: - name: Build CLI run: yarn build:cli # Needed for CLI tests - test: - timeout-minutes: 60 - name: Test (${{ matrix.os }} / node ${{ matrix.node }}) - runs-on: ${{ matrix.os }} - env: - TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} - TURBO_TEAM: ${{ vars.TURBO_TEAM }} - continue-on-error: ${{ matrix.experimental }} - needs: [install] - - strategy: - # we want to know if a test fails on a specific node version - fail-fast: false - matrix: - os: [ubuntu-latest] - node: [18, 20] - experimental: [false] - shardIndex: [1, 2, 3, 4] - shardTotal: [4] - # include: - # - os: windows-latest - # node: 16 - # experimental: true - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup node - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node }} - - - uses: actions/cache@v3 - id: restore-node-modules - env: - cache-name: cache-node-modules - with: - path: '**/node_modules' - key: ${{ runner.os }}-modules-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }} - - - uses: actions/cache@v3 - id: restore-build - env: - cache-name: cache-build - with: - path: ./* - key: ${{ runner.os }}-build-${{ matrix.node }}-${{ env.cache-name }}-${{ github.run_id }} - - - name: Install project dependencies - if: steps.cache-node-modules.outputs.cache-hit != 'true' - run: yarn install --frozen-lockfile - - - name: Store Playwright's Version - run: | - PLAYWRIGHT_VERSION=$(npx playwright --version | sed 's/Version //') - echo "Playwright's Version: $PLAYWRIGHT_VERSION" - echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV - - - name: Cache Playwright Browsers for Playwright's Version - id: cache-playwright-browsers - uses: actions/cache@v3 - with: - path: ~/.cache/ms-playwright - key: playwright-browsers-${{ env.PLAYWRIGHT_VERSION }} - - - name: Install Playwright Browsers - if: steps.cache-playwright-browsers.outputs.cache-hit != 'true' - run: npx playwright install --with-deps - - name: Test id: test run: | node -v npm -v - yarn turbo run test + yarn test:ci env: SANITY_CI_CLI_AUTH_TOKEN: ${{ secrets.SANITY_CI_CLI_AUTH_TOKEN }} GITHUB_SHARD_IDENTIFIER: ${{ matrix.shardIndex }}-${{ matrix.shardTotal }} diff --git a/package.json b/package.json index f5f5f5cd33c..2c26705fabd 100644 --- a/package.json +++ b/package.json @@ -61,6 +61,7 @@ "release-notes": "node -r esbuild-register scripts/printReleaseNotesTemplate", "start": "yarn dev:test-studio", "test": "jest --forceExit", + "test:ci": "turbo run --filter=@sanity/* --filter=groq --filter=sanity test", "test:e2e": "playwright test", "perf:test": "cd perf && yarn perf:test", "perf:studio": "cd perf && yarn studio", From 1bcb008d30154b96cbd77cfe5e1cc8d463f179ab Mon Sep 17 00:00:00 2001 From: Binoy Patel Date: Thu, 26 Oct 2023 10:56:38 -0400 Subject: [PATCH 3/5] chore(test): remove install dependency --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ff69c0c988f..3769a1ea828 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -95,7 +95,7 @@ jobs: TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} TURBO_TEAM: ${{ vars.TURBO_TEAM }} continue-on-error: ${{ matrix.experimental }} - needs: [install] + # needs: [install] strategy: # we want to know if a test fails on a specific node version From dc151664ed86ea880f01303b34fd52d1b459ec91 Mon Sep 17 00:00:00 2001 From: Binoy Patel Date: Thu, 26 Oct 2023 11:00:24 -0400 Subject: [PATCH 4/5] chore(test): fix actions --- .github/workflows/test.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3769a1ea828..a933a446883 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -172,10 +172,7 @@ jobs: - name: Test id: test - run: | - node -v - npm -v - yarn test:ci + run: yarn test:ci env: SANITY_CI_CLI_AUTH_TOKEN: ${{ secrets.SANITY_CI_CLI_AUTH_TOKEN }} GITHUB_SHARD_IDENTIFIER: ${{ matrix.shardIndex }}-${{ matrix.shardTotal }} From 3d9d8d09e1a1c3a8f846a1703649c282d229b770 Mon Sep 17 00:00:00 2001 From: Binoy Patel Date: Thu, 26 Oct 2023 11:11:11 -0400 Subject: [PATCH 5/5] chore(test): remove cache --- .github/workflows/test.yml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a933a446883..7c261ade514 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -133,19 +133,6 @@ jobs: ${{ runner.os }}-modules- ${{ runner.os }}- - - name: Cache build - id: cache-build - uses: actions/cache@v3 - env: - cache-name: cache-build - with: - path: './*' - key: ${{ runner.os }}-build-${{ matrix.node }}-${{ env.cache-name }}-${{ github.run_id }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - name: Install project dependencies if: steps.cache-node-modules.outputs.cache-hit != 'true' run: yarn install --frozen-lockfile