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

feat(ci): add workflow config for auto-updating studios #7002

Closed
wants to merge 6 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
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
25 changes: 20 additions & 5 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 7 additions & 1 deletion test/e2e/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand All @@ -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,
}
Loading