From 441f3c51d8f64e9d1bc74c65b0c5912aa0bc9745 Mon Sep 17 00:00:00 2001 From: Toby Schrapel Date: Thu, 19 Sep 2024 08:59:56 -0600 Subject: [PATCH 1/4] feat: use parallel jobs in github actions --- .github/workflows/ci-common.yml | 175 ++++++++++++++++++++++++++++++++ .github/workflows/ci.yml | 66 ++---------- 2 files changed, 181 insertions(+), 60 deletions(-) create mode 100644 .github/workflows/ci-common.yml diff --git a/.github/workflows/ci-common.yml b/.github/workflows/ci-common.yml new file mode 100644 index 000000000000..646a05cd1236 --- /dev/null +++ b/.github/workflows/ci-common.yml @@ -0,0 +1,175 @@ +name: CI Common + +on: + 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: + build: + runs-on: ${{ inputs.runner }} + steps: + - uses: actions/checkout@v4 + - 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 + run: pnpm install + + - name: Build + run: pnpm run build + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: build-artifacts-${{ inputs.runner }}-${{ inputs.node-version }} + path: | + target/ + crates/ + dist/ + packages/**/dist/ + + lint: + needs: build + runs-on: ${{ inputs.runner }} + steps: + - uses: actions/checkout@v4 + - 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' + + - name: Download build artifacts + uses: actions/download-artifact@v4 + with: + name: build-artifacts-${{ inputs.runner }}-${{ inputs.node-version }} + + - name: Install dependencies + run: pnpm install + + - name: Lint + run: pnpm run lint + # Only lint on linux to avoid \r\n line ending errors + if: inputs.runner == 'ubuntu-latest' + + test: + needs: build + runs-on: ${{ inputs.runner }} + steps: + - uses: actions/checkout@v4 + - 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' + + - name: Download build artifacts + uses: actions/download-artifact@v4 + with: + name: build-artifacts-${{ inputs.runner }}-${{ inputs.node-version }} + + - name: Install dependencies + run: pnpm install + + - name: Test + run: pnpm run test + + integration-tests: + needs: build + runs-on: ${{ inputs.runner }} + steps: + - uses: actions/checkout@v4 + - 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' + + - name: Download build artifacts + uses: actions/download-artifact@v4 + with: + name: build-artifacts-${{ inputs.runner }}-${{ 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: Install dependencies + run: pnpm install + + - name: Integration Tests + run: pnpm run test:integrations + + playwright: + needs: build + runs-on: ${{ inputs.runner }} + steps: + - uses: actions/checkout@v4 + - 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' + + - name: Download build artifacts + uses: actions/download-artifact@v4 + with: + name: build-artifacts-${{ inputs.runner }}-${{ inputs.node-version }} + + - name: Install dependencies + run: pnpm install + + - name: Install Playwright Browsers + run: npx playwright install --with-deps + + - name: Run Playwright tests + run: npm run test:ui diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 36b252596438..02f00b843b07 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,68 +9,14 @@ permissions: contents: read jobs: - tests: + version-matrix: strategy: fail-fast: false matrix: node-version: [20] runner: [ubuntu-latest, windows-latest, macos-14] - - runs-on: ${{ matrix.runner }} - timeout-minutes: 30 - - steps: - - uses: actions/checkout@v4 - - uses: pnpm/action-setup@v4 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.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 - run: pnpm install - - - name: Build - run: pnpm run build - - - name: Lint - run: pnpm run lint - # Only lint on linux to avoid \r\n line ending errors - if: matrix.runner == 'ubuntu-latest' - - - name: Test - run: pnpm run test - - - name: Integration Tests - run: pnpm run test:integrations - - - name: Install Playwright Browsers - run: npx playwright install --with-deps - - - name: Run Playwright tests - run: npm run test:ui + uses: ./.github/workflows/ci-common.yml + with: + node-version: ${{ matrix.node-version }} + runner: ${{ matrix.runner }} + secrets: inherit From c7cebc09e74857873ec407efe3cb86fa5a747131 Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Thu, 19 Sep 2024 15:27:29 -0400 Subject: [PATCH 2/4] Skip entire lint job instead of just step --- .github/workflows/ci-common.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-common.yml b/.github/workflows/ci-common.yml index 646a05cd1236..8f2be0caad6a 100644 --- a/.github/workflows/ci-common.yml +++ b/.github/workflows/ci-common.yml @@ -70,6 +70,8 @@ jobs: packages/**/dist/ lint: + # Only lint on linux to avoid \r\n line ending errors + if: inputs.runner == 'ubuntu-latest' needs: build runs-on: ${{ inputs.runner }} steps: @@ -92,8 +94,6 @@ jobs: - name: Lint run: pnpm run lint - # Only lint on linux to avoid \r\n line ending errors - if: inputs.runner == 'ubuntu-latest' test: needs: build From 64e2efbc31a798f3db21759563e0b08434229c55 Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Thu, 19 Sep 2024 15:28:52 -0400 Subject: [PATCH 3/4] Run integration tests in separate jobs --- .github/workflows/ci-common.yml | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-common.yml b/.github/workflows/ci-common.yml index 8f2be0caad6a..0ce0303d0369 100644 --- a/.github/workflows/ci-common.yml +++ b/.github/workflows/ci-common.yml @@ -122,6 +122,27 @@ jobs: 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 - uses: pnpm/action-setup@v4 @@ -145,7 +166,7 @@ jobs: run: pnpm install - name: Integration Tests - run: pnpm run test:integrations + run: pnpm run test:integrations ${{ matrix.integration }} playwright: needs: build From 7785b34f4cbb4b0b97195218c8a98fd05d3a9512 Mon Sep 17 00:00:00 2001 From: Toby Schrapel Date: Fri, 20 Sep 2024 09:02:34 -0600 Subject: [PATCH 4/4] feat: use composite action --- .github/actions/common/action.yml | 75 ++++++++++++ .github/workflows/ci-common.yml | 196 ------------------------------ .github/workflows/ci.yml | 120 ++++++++++++++++-- .github/workflows/matrix.yml | 22 ++++ 4 files changed, 206 insertions(+), 207 deletions(-) create mode 100644 .github/actions/common/action.yml delete mode 100644 .github/workflows/ci-common.yml create mode 100644 .github/workflows/matrix.yml diff --git a/.github/actions/common/action.yml b/.github/actions/common/action.yml new file mode 100644 index 000000000000..d91837c76ab2 --- /dev/null +++ b/.github/actions/common/action.yml @@ -0,0 +1,75 @@ +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' + + - 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 }} diff --git a/.github/workflows/ci-common.yml b/.github/workflows/ci-common.yml deleted file mode 100644 index 0ce0303d0369..000000000000 --- a/.github/workflows/ci-common.yml +++ /dev/null @@ -1,196 +0,0 @@ -name: CI Common - -on: - 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: - build: - runs-on: ${{ inputs.runner }} - steps: - - uses: actions/checkout@v4 - - 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 - run: pnpm install - - - name: Build - run: pnpm run build - - - name: Upload build artifacts - uses: actions/upload-artifact@v4 - with: - name: build-artifacts-${{ inputs.runner }}-${{ inputs.node-version }} - path: | - target/ - crates/ - dist/ - packages/**/dist/ - - 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 - - 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' - - - name: Download build artifacts - uses: actions/download-artifact@v4 - with: - name: build-artifacts-${{ inputs.runner }}-${{ inputs.node-version }} - - - name: Install dependencies - run: pnpm install - - - name: Lint - run: pnpm run lint - - test: - needs: build - runs-on: ${{ inputs.runner }} - steps: - - uses: actions/checkout@v4 - - 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' - - - name: Download build artifacts - uses: actions/download-artifact@v4 - with: - name: build-artifacts-${{ inputs.runner }}-${{ inputs.node-version }} - - - name: Install dependencies - run: pnpm install - - - 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 - - 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' - - - name: Download build artifacts - uses: actions/download-artifact@v4 - with: - name: build-artifacts-${{ inputs.runner }}-${{ 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: Install dependencies - run: pnpm install - - - name: Integration Tests - run: pnpm run test:integrations ${{ matrix.integration }} - - playwright: - needs: build - runs-on: ${{ inputs.runner }} - steps: - - uses: actions/checkout@v4 - - 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' - - - name: Download build artifacts - uses: actions/download-artifact@v4 - with: - name: build-artifacts-${{ inputs.runner }}-${{ inputs.node-version }} - - - name: Install dependencies - run: pnpm install - - - name: Install Playwright Browsers - run: npx playwright install --with-deps - - - name: Run Playwright tests - run: npm run test:ui diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 02f00b843b07..06883c36aa8a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,22 +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: - version-matrix: + 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 }} + isBuild: true + + 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: + runner: ${{ inputs.runner }} + node-version: ${{ inputs.node-version }} + + - name: Lint + run: pnpm run lint + + 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: - node-version: [20] - runner: [ubuntu-latest, windows-latest, macos-14] - uses: ./.github/workflows/ci-common.yml - with: - node-version: ${{ matrix.node-version }} - runner: ${{ matrix.runner }} - secrets: inherit + 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 ${{ matrix.integration }} + + 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 + + - name: Run Playwright tests + run: npm run test:ui diff --git a/.github/workflows/matrix.yml b/.github/workflows/matrix.yml new file mode 100644 index 000000000000..b48d386fd5c4 --- /dev/null +++ b/.github/workflows/matrix.yml @@ -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