-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(repo): Update CI flow; Integrate Turbo caching
- Loading branch information
Showing
5 changed files
with
266 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
name: CI | ||
|
||
on: | ||
workflow_dispatch: | ||
merge_group: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
env: | ||
FORCE_COLOR: '1' | ||
NODE_VERSION: '18' | ||
TURBO_ARGS: --output-logs=new-only --cache-dir=./.turbo-cache --concurrency=8 | ||
TURBO_TOKEN: ${{ secrets.TEST_TURBO_TOKEN }} | ||
TURBO_TEAM: ${{ secrets.TEST_TURBO_TEAM }} | ||
TURBO_REMOTE_CACHE_SIGNATURE_KEY: ${{ secrets.TURBO_REMOTE_CACHE_SIGNATURE_KEY }} | ||
TURBO_REMOTE_ONLY: true | ||
TURBO_CONCURRENCY: 8 # Available CPU in RUNNER_LARGE | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
formatting-linting: | ||
name: Formatting & Linting | ||
runs-on: ${{ vars.RUNNER_LARGE }} | ||
env: | ||
TURBO_REMOTE_ONLY: false | ||
|
||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
show-progress: false | ||
|
||
- name: Setup NodeJS ${{ env.NODE_VERSION }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ env.NODE_VERSION }} | ||
|
||
- name: Cache node_modules | ||
uses: actions/cache@v3 | ||
id: npm-cache | ||
with: | ||
path: ./node_modules | ||
key: ${{ runner.os }}-node-${{ env.NODE_VERSION }}-node-modules-${{ hashFiles('**/package-lock.json') }} | ||
|
||
- name: Install NPM Dependencies | ||
if: steps.npm-cache.outputs.cache-hit != 'true' | ||
run: npm ci --audit=false --fund=false | ||
|
||
- name: Require Changeset | ||
run: if [ "${{ github.event.pull_request.user.login }}" = "clerk-cookie" ]; then echo 'Skipping' && exit 0; else npx changeset status --since=origin/main; fi | ||
|
||
- name: Check Formatting | ||
run: npm run format:check | ||
|
||
- name: Lint packages using publint | ||
run: npm run lint:publint -- ${{ env.TURBO_ARGS }} | ||
|
||
- name: Lint types using attw | ||
run: npm run lint:attw -- ${{ env.TURBO_ARGS }} | ||
continue-on-error: true # TODO: Remove this when all related errors are fixed | ||
|
||
- name: Run lint | ||
run: npm run lint -- ${{ env.TURBO_ARGS }} -- --quiet | ||
|
||
unit-tests: | ||
name: Unit Tests | ||
needs: formatting-linting | ||
runs-on: ${{ vars.RUNNER_LARGE }} | ||
|
||
strategy: | ||
matrix: | ||
node-version: [ 18, 20 ] | ||
|
||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
show-progress: false | ||
|
||
- name: Setup NodeJS ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: Cache node_modules | ||
uses: actions/cache@v3 | ||
id: npm-cache | ||
with: | ||
path: ./node_modules | ||
key: ${{ runner.os }}-node-${{ matrix.node-version }}-node-modules-${{ hashFiles('**/package-lock.json') }} | ||
|
||
- name: Install NPM Dependencies | ||
if: steps.npm-cache.outputs.cache-hit != 'true' | ||
run: npm ci --audit=false --fund=false | ||
|
||
- name: Run tests | ||
run: npx turbo test ${{ env.TURBO_ARGS }} | ||
env: | ||
NODE_VERSION: ${{ matrix.node-version }} | ||
|
||
integration-tests: | ||
name: Integration Tests | ||
needs: formatting-linting | ||
runs-on: ${{ vars.RUNNER_LARGE }} | ||
|
||
strategy: | ||
matrix: | ||
test-name: [ 'generic', 'nextjs', 'remix' ] | ||
|
||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
show-progress: false | ||
|
||
- name: Setup NodeJS ${{ env.NODE_VERSION }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ env.NODE_VERSION }} | ||
|
||
- name: Cache node_modules | ||
uses: actions/cache@v3 | ||
id: npm-cache | ||
with: | ||
path: ./node_modules | ||
key: ${{ runner.os }}-node-${{ env.NODE_VERSION }}-node-modules-${{ hashFiles('**/package-lock.json') }} | ||
|
||
- name: Install NPM Dependencies | ||
if: steps.npm-cache.outputs.cache-hit != 'true' | ||
run: npm ci --audit=false --fund=false | ||
|
||
- name: Get Playwright Version | ||
id: playwright-version | ||
run: echo "VERSION=$(node -e "console.log($(npm ls @playwright/test --json).dependencies['@playwright/test'].version)")" >> "$GITHUB_OUTPUT" | ||
|
||
- name: Cache Playwright Binaries | ||
uses: actions/cache@v3 | ||
id: playwright-cache | ||
with: | ||
path: ~/.cache/ms-playwright | ||
key: ${{ runner.os }}-node-${{ env.NODE_VERSION }}-playwright-${{ steps.playwright-version.outputs.VERSION }} | ||
|
||
- name: Install Playwright Browsers | ||
if: steps.playwright-cache.outputs.cache-hit != 'true' | ||
run: npx playwright install --with-deps | ||
|
||
- name: Update NPM Registry | ||
run: npm set registry http://localhost:4873/ | ||
|
||
- name: Run Verdaccio | ||
run: | | ||
nohup ./node_modules/.bin/verdaccio --config ./verdaccio.yaml & sleep 5 | ||
./node_modules/.bin/npm-cli-adduser -u user -p pass -e [email protected] -r http://localhost:4873/ | ||
./node_modules/.bin/npm-cli-login -u user -p pass -e [email protected] -r http://localhost:4873/ | ||
- name: Publish to Verdaccio | ||
run: | | ||
if [ "$(npm config get registry)" = "https://registry.npmjs.org/" ]; then echo 'Error: Using default registry' && exit 1; else npx turbo build ${{ env.TURBO_ARGS }} && npx changeset publish --no-git-tag; fi | ||
- name: Install @clerk/backend in /integration | ||
working-directory: ./integration | ||
run: npm init -y && npm install @clerk/backend | ||
|
||
- name: Run Playwright tests | ||
run: npm run test:integration:${{ matrix.test-name }} | ||
env: | ||
INTEGRATION_INSTANCE_KEYS: ${{ secrets.INTEGRATION_INSTANCE_KEYS }} | ||
MAILSAC_API_KEY: ${{ secrets.MAILSAC_API_KEY }} | ||
E2E_CLERK_VERSION: 'latest' | ||
|
||
- name: Upload Playwright Report for ${{ matrix.test-name }} | ||
uses: actions/upload-artifact@v3 | ||
if: always() | ||
with: | ||
name: playwright-report-${{ github.ref }}-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.test-name }} | ||
path: playwright-report/ | ||
retention-days: 1 |
Oops, something went wrong.