Skip to content

Commit

Permalink
chore(ci): breakup GH test.yml
Browse files Browse the repository at this point in the history
turbopack and turborepo tests are often blocking each other and
there is no good reason to keep them all in one workflow. This
PR separates them. Since linting and JS packages are not cleanly
separated between the projects, they get their own workflows as well
  • Loading branch information
mehulkar committed Apr 23, 2024
1 parent 08aa2be commit de3ec73
Show file tree
Hide file tree
Showing 4 changed files with 663 additions and 441 deletions.
136 changes: 136 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
name: Test
on:
push:
branches: [main]
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

permissions:
actions: write
contents: read
pull-requests: read

jobs:
determine_jobs:
name: Determine jobs to run
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v3

- name: CI related changes
id: ci
uses: technote-space/get-diff-action@v6
with:
PATTERNS: |
.github/actions/**
.github/workflows/lint.yml
- name: Rust related changes
id: rust
uses: technote-space/get-diff-action@v6
with:
PATTERNS: |
pnpm-lock.yaml
package.json
Cargo.**
crates/**
shim/**
xtask/**
.cargo/**
rust-toolchain
!**.md
!**.mdx
- name: Formatting related changes
id: format
uses: technote-space/get-diff-action@v6
with:
PATTERNS: |
**/*.{yml,yaml,md,mdx,js,jsx,ts,tsx,json,toml,css}
outputs:
rust: ${{ steps.ci.outputs.diff != '' || steps.rust.outputs.diff != '' }}
format: ${{ steps.ci.outputs.diff != '' || steps.format.outputs.diff != '' }}

rust_lint:
needs: [determine_jobs]
if: needs.determine_jobs.outputs.rust == 'true'
name: Rust lints
runs-on:
- "self-hosted"
- "linux"
- "x64"
- "metal"
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Rust
uses: ./.github/actions/setup-rust
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

- name: Run cargo fmt check
run: |
cargo fmt --check
- name: Check Cargo.toml formatting (taplo)
run: npx @taplo/cli@0.5.2 format --check

- name: Check licenses
uses: EmbarkStudios/cargo-deny-action@v1
with:
command: check licenses

format_lint:
name: Formatting
runs-on:
- "self-hosted"
- "linux"
- "x64"
- "metal"
needs: determine_jobs
if: needs.determine_jobs.outputs.format == 'true'
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
TURBO_REMOTE_ONLY: true
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Turborepo Environment
uses: ./.github/actions/setup-turborepo-environment
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

- name: Install Global Turbo
uses: ./.github/actions/install-global-turbo

- name: Lint
# Filters some workspaces out:
# - Other `@vercel/*` packages because ??
run: |
turbo run lint \
--filter=!@vercel/devlow-bench \
--filter=!@vercel/experimental-nft-next-plugin \
--filter=!@vercel/experimental-nft-next-plugin \
--filter=!turbopack-bump-action \
--filter=!next-integration-stat \
--env-mode=strict
cleanup:
name: Cleanup
needs:
- rust_lint
- format_lint
if: always()
uses: ./.github/workflows/pr-clean-caches.yml
secrets: inherit
103 changes: 103 additions & 0 deletions .github/workflows/test-js-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Test
on:
push:
branches: [main]
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

permissions:
actions: write
contents: read
pull-requests: read

jobs:
determine_jobs:
name: Determine jobs to run
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: CI related changes
id: ci
uses: technote-space/get-diff-action@v6
with:
PATTERNS: |
.github/actions/**
.github/workflows/test-js-packages.yml
- name: /packages related changes
id: packages
uses: technote-space/get-diff-action@v6
with:
PATTERNS: |
packages/**
- name: Docs related changes
id: docs
uses: technote-space/get-diff-action@v6
with:
PATTERNS: |
docs/**
outputs:
ci: ${{ steps.ci.outputs.diff != ''}}
packages: ${{ steps.packages.outputs.diff != '' }}
docs: ${{ steps.docs.outputs.diff != '' }}

js_packages:
name: JS Package Tests
timeout-minutes: 30
if: needs.determine_jobs.outputs.ci == 'true' || needs.determine_jobs.outputs.packages == 'true' || needs.determine_jobs.outputs.docs == 'true'
needs: [determine_jobs]
runs-on: ${{ matrix.os.runner }}
strategy:
fail-fast: false
matrix:
os:
- name: ubuntu
runner:
- "self-hosted"
- "linux"
- "x64"
- "metal"
- name: macos
runner: macos-latest
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
TURBO_REMOTE_ONLY: true

steps:
# on main -> current + prev commit
# pr -> pr commits + base commit
- name: Determine fetch depth
id: fetch-depth
run: |
echo "depth=$(( ${{ github.event.pull_request.commits || 1 }} + 1 ))" >> $GITHUB_OUTPUT
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
fetch-depth: ${{ steps.fetch-depth.outputs.depth }}

- name: Setup Turborepo Environment
uses: ./.github/actions/setup-turborepo-environment
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
node-version: "20"

- name: Install Global Turbo
uses: ./.github/actions/install-global-turbo

- name: Run tests
# We manually set TURBO_API to an empty string to override Hetzner env
# We filter out turborepo-repository because it's a native package and needs
# to run when turbo core changes. This job (`js_packages`) does not run on turborpeo core
# changes, and we don't want to enable that beahvior for _all_ our JS packages.
run: |
TURBO_API= turbo run check-types test --filter=docs --filter="!turborepo-repository" --filter={./packages/*}...[${{ github.event.pull_request.base.sha || 'HEAD^1' }}] --color --env-mode=strict
Loading

0 comments on commit de3ec73

Please sign in to comment.