Skip to content

Commit

Permalink
feat: use composite action
Browse files Browse the repository at this point in the history
  • Loading branch information
tobeycodes committed Sep 20, 2024
1 parent 64e2efb commit 4efe1a4
Show file tree
Hide file tree
Showing 4 changed files with 196 additions and 207 deletions.
75 changes: 75 additions & 0 deletions .github/action/common.yml
Original file line number Diff line number Diff line change
@@ -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: 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
if: ${{ inputs.isBuild == 'true' }}

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


- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts-${{ inputs.runner }}-${{ inputs.node-version }}
if: ${{ inputs.isBuild == 'false' }}
196 changes: 0 additions & 196 deletions .github/workflows/ci-common.yml

This file was deleted.

110 changes: 99 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,110 @@
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:
- 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:
- 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:
- 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:
- 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:
- 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
Loading

0 comments on commit 4efe1a4

Please sign in to comment.