diff --git a/.env.example b/.env.example index 8f03c8d450e..6a8df14c675 100644 --- a/.env.example +++ b/.env.example @@ -14,3 +14,5 @@ SANITY_E2E_BASE_URL=http://localhost:3339 # Whether or not to run the end to end tests in headless mode. Defaults to true, but sometimes # you might want to see the browser in action, in which case you can set this to `false`. HEADLESS=true +# In CI, we have to provide some signal of how we've built the studio. Set this to `true` if you're testing an auto-updating build. +SANITY_E2E_IS_AUTO_UPDATING=false diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 73a7e64b5ee..d4fbb8893e3 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -19,6 +19,7 @@ jobs: matrix: # Be sure to update all instances in this file and `pr-cleanup.yml` if updated project: [chromium, firefox] + config: [auto-updating, default] steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 @@ -82,8 +83,13 @@ jobs: SANITY_E2E_SESSION_TOKEN: ${{ secrets.SANITY_E2E_SESSION_TOKEN_NEW }} SANITY_E2E_PROJECT_ID: ${{ vars.SANITY_E2E_PROJECT_ID }} SANITY_E2E_DATASET: ${{ vars.SANITY_E2E_DATASET }} - run: pnpm e2e:setup && pnpm e2e:build - + SANITY_E2E_IS_AUTO_UPDATING: ${{ matrix.config == 'auto-updating' && 'true' || '' }} + run: | + if [ "${{ matrix.config }}" == "auto-updating" ]; then + pnpm e2e:setup && pnpm e2e:build --auto-updates + else + pnpm e2e:setup && pnpm e2e:build + fi - name: Build E2E test studio on PR if: ${{ github.event_name == 'pull_request' }} env: @@ -92,8 +98,14 @@ jobs: # Delete `SANITY_E2E_SESSION_TOKEN_NEW` from github SANITY_E2E_SESSION_TOKEN: ${{ secrets.SANITY_E2E_SESSION_TOKEN_NEW }} SANITY_E2E_PROJECT_ID: ${{ vars.SANITY_E2E_PROJECT_ID }} - SANITY_E2E_DATASET: pr-${{ matrix.project }}-${{ github.event.number }} - run: pnpm e2e:setup && pnpm e2e:build + SANITY_E2E_DATASET: pr-${{ matrix.project }}-${{ github.event.number }}${{ matrix.config == 'auto-updating' && '-auto-updating' || '' }} + SANITY_E2E_IS_AUTO_UPDATING: ${{ matrix.config == 'auto-updating' && 'true' || '' }} + run: | + if [ "${{ matrix.config }}" == "auto-updating" ]; then + pnpm e2e:setup && pnpm e2e:build --auto-updates + else + pnpm e2e:setup && pnpm e2e:build + fi # Caches build from either PR or next - name: Cache build @@ -123,6 +135,7 @@ jobs: # Add more shards here if needed shardIndex: [1, 2] shardTotal: [2] + config: [auto-updating, default] steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 @@ -199,6 +212,7 @@ jobs: SANITY_E2E_SESSION_TOKEN: ${{ secrets.SANITY_E2E_SESSION_TOKEN_NEW }} SANITY_E2E_PROJECT_ID: ${{ vars.SANITY_E2E_PROJECT_ID }} SANITY_E2E_DATASET: ${{ vars.SANITY_E2E_DATASET }} + SANITY_E2E_IS_AUTO_UPDATING: ${{ matrix.config == 'auto-updating' && 'true' || '' }} run: pnpm test:e2e --project ${{ matrix.project }} --shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }} - name: Run E2E tests on PR @@ -212,7 +226,8 @@ jobs: # Delete `SANITY_E2E_SESSION_TOKEN_NEW` from github SANITY_E2E_SESSION_TOKEN: ${{ secrets.SANITY_E2E_SESSION_TOKEN_NEW }} SANITY_E2E_PROJECT_ID: ${{ vars.SANITY_E2E_PROJECT_ID }} - SANITY_E2E_DATASET: pr-${{ matrix.project }}-${{ github.event.number }} + SANITY_E2E_DATASET: pr-${{ matrix.project }}-${{ github.event.number }}${{ matrix.config == 'auto-updating' && '-auto-updating' || '' }} + SANITY_E2E_IS_AUTO_UPDATING: ${{ matrix.config == 'auto-updating' && 'true' || '' }} run: pnpm test:e2e --project ${{ matrix.project }} --shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }} - uses: actions/upload-artifact@v3 diff --git a/test/e2e/env.ts b/test/e2e/env.ts index 5bdce546e5c..8d704bb1f97 100644 --- a/test/e2e/env.ts +++ b/test/e2e/env.ts @@ -5,6 +5,7 @@ import {loadEnvFiles} from '../../scripts/utils/loadEnvFiles' loadEnvFiles() +const SANITY_E2E_IS_AUTO_UPDATING = process.env.SANITY_E2E_IS_AUTO_UPDATING === 'true' const SANITY_E2E_SESSION_TOKEN = process.env.SANITY_E2E_SESSION_TOKEN! const SANITY_E2E_PROJECT_ID = process.env.SANITY_E2E_PROJECT_ID! const SANITY_E2E_DATASET = process.env.SANITY_E2E_DATASET! @@ -27,4 +28,9 @@ if (!SANITY_E2E_DATASET) { process.exit(1) } -export {SANITY_E2E_DATASET, SANITY_E2E_PROJECT_ID, SANITY_E2E_SESSION_TOKEN} +export { + SANITY_E2E_DATASET, + SANITY_E2E_IS_AUTO_UPDATING, + SANITY_E2E_PROJECT_ID, + SANITY_E2E_SESSION_TOKEN, +}