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: use parallel jobs in github actions #14463

Closed
wants to merge 5 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
78 changes: 78 additions & 0 deletions .github/actions/common/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: 'Common'
description: 'Run the common steps'
inputs:
node-version:
description: 'Node.js version'
required: true
type: string
runner:
description: 'Runner'
required: true
type: string
isBuild:
description: 'Whether to build the project'
required: false
default: 'false'
type: boolean
runs:
using: 'composite'
steps:
- uses: pnpm/action-setup@v4

- name: Use Node.js ${{ inputs.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
cache: 'pnpm'

# Cargo already skips downloading dependencies if they already exist
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

# Cache the `oxide` Rust build
- name: Cache oxide build
uses: actions/cache@v4
with:
path: |
./target/
./crates/node/*.node
./crates/node/index.js
./crates/node/index.d.ts
key: ${{ runner.os }}-oxide-${{ hashFiles('./crates/**/*') }}

- name: Install dependencies
shell: bash
run: pnpm install

- name: Build
shell: bash
run: pnpm run build
if: inputs.isBuild == 'true'
env:
CARGO_PROFILE_RELEASE_LTO: 'off'
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER: 'lld-link'

- name: Upload build artifacts
uses: actions/upload-artifact@v4
if: inputs.isBuild == 'true'
with:
name: build-artifacts-${{ inputs.runner }}-${{ inputs.node-version }}
path: |
target/
crates/
dist/
packages/**/dist/

- name: Download build artifacts
uses: actions/download-artifact@v4
if: inputs.isBuild == 'false'
with:
name: build-artifacts-${{ inputs.runner }}-${{ inputs.node-version }}
143 changes: 92 additions & 51 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,79 +1,120 @@
name: CI

on:
push:
branches: [next]
pull_request:
workflow_call:
inputs:
node-version:
description: 'Node.js version'
required: true
default: '20'
type: string
runner:
description: 'Runner'
required: true
default: 'ubuntu-latest'
type: string

permissions:
contents: read

jobs:
tests:
strategy:
fail-fast: false
matrix:
node-version: [20]
runner: [ubuntu-latest, windows-latest, macos-14]

runs-on: ${{ matrix.runner }}
timeout-minutes: 30

build:
runs-on: ${{ inputs.runner }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
- name: Common
uses: ./.github/actions/common
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
runner: ${{ inputs.runner }}
node-version: ${{ inputs.node-version }}
isBuild: true

# Cargo already skips downloading dependencies if they already exist
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

# Cache the `oxide` Rust build
- name: Cache oxide build
uses: actions/cache@v4
lint:
# Only lint on linux to avoid \r\n line ending errors
if: inputs.runner == 'ubuntu-latest'
needs: build
runs-on: ${{ inputs.runner }}
steps:
- uses: actions/checkout@v4

- name: Common
uses: ./.github/actions/common
with:
path: |
./target/
./crates/node/*.node
./crates/node/index.js
./crates/node/index.d.ts
key: ${{ runner.os }}-oxide-${{ hashFiles('./crates/**/*') }}

- name: Install dependencies
run: pnpm install

- name: Build
run: pnpm run build
env:
CARGO_PROFILE_RELEASE_LTO: 'off'
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER: 'lld-link'
runner: ${{ inputs.runner }}
node-version: ${{ inputs.node-version }}

- name: Lint
run: pnpm run lint
# Only lint on linux to avoid \r\n line ending errors
if: matrix.runner == 'ubuntu-latest'

test:
needs: build
runs-on: ${{ inputs.runner }}
steps:
- uses: actions/checkout@v4

- name: Common
uses: ./.github/actions/common
with:
runner: ${{ inputs.runner }}
node-version: ${{ inputs.node-version }}

- name: Test
run: pnpm run test

integration-tests:
needs: build
runs-on: ${{ inputs.runner }}

strategy:
fail-fast: false
matrix:
integration:
- cli/index
- cli/config
- cli/plugins
- cli/upgrade
- postcss/index
- postcss/config
- postcss/core-as-postcss-plugin
- postcss/next
- vite/index
- vite/config
- vite/astro
- vite/vue
- vite/nuxt
- vite/css-modules

steps:
- uses: actions/checkout@v4

- name: Common
uses: ./.github/actions/common
with:
runner: ${{ inputs.runner }}
node-version: ${{ inputs.node-version }}

# https://github.com/actions/download-artifact/issues/14
- name: Fix permissions for executable files in packages/@tailwindcss-standalone/dist/
run: chmod +x packages/@tailwindcss-standalone/dist/*

- name: Integration Tests
run: pnpm run test:integrations
run: pnpm run test:integrations ${{ matrix.integration }}
env:
GITHUB_WORKSPACE: ${{ github.workspace }}

playwright:
needs: build
runs-on: ${{ inputs.runner }}
steps:
- uses: actions/checkout@v4

- name: Common
uses: ./.github/actions/common
with:
runner: ${{ inputs.runner }}
node-version: ${{ inputs.node-version }}

- name: Install Playwright Browsers
run: npx playwright install --with-deps

Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/matrix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Matrix

on:
push:
branches: [next]
pull_request:

permissions:
contents: read

jobs:
version-matrix:
strategy:
fail-fast: false
matrix:
node-version: [20]
runner: [ubuntu-latest, windows-latest, macos-14]
uses: ./.github/workflows/ci.yml
with:
node-version: ${{ matrix.node-version }}
runner: ${{ matrix.runner }}
secrets: inherit