Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(test): use turbo for testing #5077

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
175 changes: 86 additions & 89 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -50,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
Expand All @@ -87,82 +157,9 @@ 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 test --silent --shard=${{ matrix.shardIndex}}/${{ matrix.shardTotal }}
run: yarn test:ci
env:
SANITY_CI_CLI_AUTH_TOKEN: ${{ secrets.SANITY_CI_CLI_AUTH_TOKEN }}
GITHUB_SHARD_IDENTIFIER: ${{ matrix.shardIndex }}-${{ matrix.shardTotal }}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/sanity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"build": {
"outputs": ["lib/**", "index.js"],
"dependsOn": ["^build"]
}
},
"test": {}
}
}
Loading