Skip to content

Commit

Permalink
fix(repo): GHA optimizations (#2037)
Browse files Browse the repository at this point in the history
* fix(repo): GHA optimizations

* fix(repo): GHA attempt 4vCPU intial step

* fix(repo): Remove GITHUB_ACCESS_TOKEN for better Turbo caching

* fix(repo): Enable Turbo summarize

* chore(repo): Remove unneeded Turbo globalDeps

* chore(repo): Re-introduce follow-on jobs to CI workflow

* chore(repo): Turbo summarize unit tests

* chore(repo): Test reducing CI integration boxes as Playwright isn't using all vCPUs

* chore(repo): Disable remix integration test until ready
  • Loading branch information
tmilewski authored Nov 3, 2023
1 parent 0293f29 commit 7f7b4cb
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 25 deletions.
12 changes: 9 additions & 3 deletions .github/actions/init/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ inputs:
description: 'Enable Playwright?'
required: false
default: 'false'
turbo-summarize:
description: 'The token to use for Turbo task summaries'
required: false
default: 'false'
turbo-enabled:
description: 'Enable Turbo?'
required: false
Expand Down Expand Up @@ -44,6 +48,7 @@ runs:
CACHE_DIR: ${{ inputs.turbo-cache-dir }}
REMOTE_ONLY: ${{ inputs.turbo-remote-only }}
SIGNATURE: ${{ inputs.turbo-signature }}
SUMMARIZE: ${{ inputs.turbo-summarize }}
TEAM: ${{ inputs.turbo-team }}
TOKEN: ${{ inputs.turbo-token }}
with:
Expand All @@ -54,13 +59,14 @@ runs:
? os.availableParallelism()
: os.cpus().length;
const { ENABLED, CACHE_DIR, SIGNATURE, REMOTE_ONLY, TEAM, TOKEN } = process.env
const { ENABLED, CACHE_DIR, SIGNATURE, REMOTE_ONLY, SUMMARIZE, TEAM, TOKEN } = process.env
core.exportVariable('TURBO_ARGS',
[
'--output-logs=new-only',
`--cache-dir=${CACHE_DIR}`,
`--concurrency=${cpus}`
`--concurrency=${cpus}`,
`--summarize=${SUMMARIZE}`,
].join(' ')
)
Expand Down Expand Up @@ -90,7 +96,7 @@ runs:
id: npm-cache
with:
path: ./node_modules
key: ${{ runner.os }}-node-${{ inputs.node-version }}-node-modules-${{ hashFiles('**/package-lock.json') }}
key: ${{ runner.os }}-node-${{ inputs.node-version }}-node-modules-${{ hashFiles('package-lock.json') }}

- name: Install NPM Dependencies
if: steps.npm-cache.outputs.cache-hit != 'true'
Expand Down
42 changes: 38 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ concurrency:
jobs:
formatting-linting:
name: Formatting, linting & changeset checks
runs-on: ${{ vars.RUNNER_NORMAL }}
runs-on: ${{ vars.RUNNER_LARGE }}
timeout-minutes: ${{ fromJSON(vars.TIMEOUT_MINUTES_NORMAL) }}

env:
TURBO_SUMMARIZE: true

steps:
- name: Checkout Repo
timeout-minutes: ${{ fromJSON(vars.TIMEOUT_MINUTES_SHORT) }}
Expand All @@ -28,12 +31,13 @@ jobs:
show-progress: false

- name: Setup
timeout-minutes: ${{ vars.TIMEOUT_MINUTES_SHORT }}
timeout-minutes: ${{ fromJSON(vars.TIMEOUT_MINUTES_SHORT) }}
id: config
uses: ./.github/actions/init
with:
turbo-remote-only: false
turbo-signature: ${{ secrets.TURBO_REMOTE_CACHE_SIGNATURE_KEY }}
turbo-summarize: ${{ env.TURBO_SUMMARIZE }}
turbo-team: ${{ vars.TURBO_TEAM }}
turbo-token: ${{ secrets.TURBO_TOKEN }}

Expand Down Expand Up @@ -67,12 +71,24 @@ jobs:
timeout-minutes: ${{ fromJSON(vars.TIMEOUT_MINUTES_SHORT) }}
run: npm run lint -- $TURBO_ARGS -- --quiet

- name: Upload Turbo Summary
uses: actions/upload-artifact@v3
if: ${{ env.TURBO_SUMMARIZE == 'true' }}
continue-on-error: true
with:
name: turbo-summary-report-lint-${{ github.run_id }}-${{ github.run_attempt }}
path: .turbo/runs
retention-days: 5

unit-tests:
name: Unit Tests
needs: formatting-linting
runs-on: ${{ vars.RUNNER_LARGE }}
timeout-minutes: ${{ fromJSON(vars.TIMEOUT_MINUTES_NORMAL) }}

env:
TURBO_SUMMARIZE: true

strategy:
matrix:
node-version: [ 18, 20 ]
Expand All @@ -90,6 +106,7 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
turbo-signature: ${{ secrets.TURBO_REMOTE_CACHE_SIGNATURE_KEY }}
turbo-summarize: ${{ env.TURBO_SUMMARIZE }}
turbo-team: ${{ vars.TURBO_TEAM }}
turbo-token: ${{ secrets.TURBO_TOKEN }}

Expand All @@ -98,24 +115,36 @@ jobs:
env:
NODE_VERSION: ${{ matrix.node-version }}

- name: Upload Turbo Summary
uses: actions/upload-artifact@v3
if: ${{ env.TURBO_SUMMARIZE == 'true' }}
continue-on-error: true
with:
name: turbo-summary-report-unit-${{ github.run_id }}-${{ github.run_attempt }}-node-${{ matrix.node-version }}
path: .turbo/runs
retention-days: 5

integration-tests:
name: Integration Tests
needs: formatting-linting
runs-on: ${{ vars.RUNNER_LARGE }}
runs-on: ${{ vars.RUNNER_MEDIUM }}
timeout-minutes: ${{ fromJSON(vars.TIMEOUT_MINUTES_NORMAL) }}

strategy:
matrix:
# TODO: Remove `matrix.test-name != 'remix'` when ready, or from matrix when required check is disabled
test-name: [ 'generic', 'nextjs', 'remix' ]

steps:
- name: Checkout Repo
if: ${{ matrix.test-name != 'remix' }}
uses: actions/checkout@v4
with:
fetch-depth: 0
show-progress: false

- name: Setup
if: ${{ matrix.test-name != 'remix' }}
id: config
uses: ./.github/actions/init
with:
Expand All @@ -125,20 +154,24 @@ jobs:
playwright-enabled: true

- name: Verdaccio
if: ${{ matrix.test-name != 'remix' }}
uses: ./.github/actions/verdaccio
with:
publish-cmd: |
if [ "$(npm config get registry)" = "https://registry.npmjs.org/" ]; then echo 'Error: Using default registry' && exit 1; else npx turbo build $TURBO_ARGS && npx changeset publish --no-git-tag; fi
- name: Install @clerk/backend in /integration
if: ${{ matrix.test-name != 'remix' }}
working-directory: ./integration
run: npm init -y && npm install @clerk/backend

- name: Install @clerk/clerk-js in os temp
if: ${{ matrix.test-name != 'remix' }}
working-directory: ${{runner.temp}}
run: mkdir clerk-js && cd clerk-js && npm init -y && npm install @clerk/clerk-js

- name: Run Integration Tests
if: ${{ matrix.test-name != 'remix' }}
run: npm run test:integration:${{ matrix.test-name }}
env:
E2E_APP_CLERK_JS_DIR: ${{runner.temp}}
Expand All @@ -147,9 +180,10 @@ jobs:
MAILSAC_API_KEY: ${{ secrets.MAILSAC_API_KEY }}

# - name: Upload Integration Report for ${{ matrix.test-name }}
# if: ${{ matrix.test-name != 'remix' }}
# uses: actions/upload-artifact@v3
# if: always()
# with:
# name: integration-report-${{ github.ref }}-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.test-name }}
# name: integration-report-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.test-name }}
# path: playwright-report/
# retention-days: 1
2 changes: 1 addition & 1 deletion .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:

jobs:
triage:
timeout-minutes: ${{ vars.TIMEOUT_MINUTES_SHORT }}
timeout-minutes: 3
permissions:
contents: read
pull-requests: write
Expand Down
7 changes: 6 additions & 1 deletion integration/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
/* eslint-disable turbo/no-undeclared-env-vars */
import os from 'node:os';

import type { PlaywrightTestConfig } from '@playwright/test';
import { defineConfig, devices } from '@playwright/test';
import { config } from 'dotenv';
import * as path from 'path';

config({ path: path.resolve(__dirname, '.env.local') });

const numAvailableWorkers = os.cpus().length - 1;

export const common: PlaywrightTestConfig = {
testDir: './tests',
snapshotDir: './tests/snapshots',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
timeout: process.env.CI ? 90000 : 30000,
workers: process.env.CI ? '50%' : '70%',
maxFailures: process.env.CI ? 1 : undefined,
workers: process.env.CI ? numAvailableWorkers : '70%',
reporter: [[process.env.CI ? 'html' : 'line', { open: 'never' }]] as any,
use: {
trace: 'on-first-retry',
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"release": "TURBO_FORCE=true FORCE_COLOR=1 npm run build -- --force && changeset publish && git push --follow-tags",
"release:snapshot": "TURBO_FORCE=true FORCE_COLOR=1 npm run build && changeset publish --tag snapshot --no-git-tag",
"release:staging": "TURBO_FORCE=true FORCE_COLOR=1 npm run build && changeset publish --tag staging --no-git-tag",
"release:verdaccio": "if [ \"$(npm config get registry)\" = \"https://registry.npmjs.org/\" ]; then echo 'Error: Using default registry' && exit 1; else TURBO_CONCURRENCY=1 npm run build && changeset publish --no-git-tag; fi",
"test": "FORCE_COLOR=1 turbo test --concurrency=${TURBO_CONCURRENCY:-80%}",
"test:cache:clear": "FORCE_COLOR=1 turbo test:cache:clear --continue --concurrency=${TURBO_CONCURRENCY:-80%}",
"test:integration:base": "DEBUG=1 npx playwright test --config integration/playwright.config.ts",
Expand Down
18 changes: 2 additions & 16 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,7 @@
"remoteCache": {
"signature": true
},
"globalDependencies": [
".changeset/changelog.js",
".changeset/config.json",
".github/**",
".jit",
".nvmrc",
".prettier*",
"jest.*.ts",
"package.json",
"package-lock.json",
"tsconfig.json",
"tsconfig.*.json",
"verdaccio.yaml"
],
"globalDependencies": ["jest.*.ts", "package.json", "package-lock.json", "tsconfig.json", "tsconfig.*.json"],
"globalEnv": [
"CLERK_*",
"GATSBY_CLERK_*",
Expand All @@ -26,8 +13,7 @@
"NODE_VERSION",
"NPM_VERSION",
"TZ",
"VERCEL",
"GITHUB_ACCESS_TOKEN"
"VERCEL"
],
"pipeline": {
"build": {
Expand Down

0 comments on commit 7f7b4cb

Please sign in to comment.