Skip to content

Commit

Permalink
chore(ci): split build into standalone jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
kettanaito committed Dec 15, 2024
1 parent ecc0990 commit 850b97f
Showing 1 changed file with 96 additions and 36 deletions.
132 changes: 96 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,52 +7,86 @@ on:
workflow_dispatch:

jobs:
build:
build-18:
name: build (18)
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
node-version: [18, 20]
outputs:
node-version: ${{ matrix.node-version }}
steps:
- name: Checkout
uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
- name: Set up pnpm
uses: pnpm/action-setup@v4
with:
version: 9.14.0

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
node-version: 18
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Lint
run: pnpm lint

- name: Build
run: pnpm build

- name: Cache build output
uses: actions/cache@v4
with:
path: ./lib
key: ${{ runner.os }}-node-${{ matrix.node-version }}-build-${{ github.sha }}
key: ${{ runner.os }}-node-18-build-${{ github.sha }}
restore-keys: |
${{ runner.os }}-build-${{ matrix.node-version }}
${{ runner.os }}-build-18
test_unit:
name: test (unit)
needs: build
if: ${{ needs.build.outputs.node-version == '18' }}
build-20:
name: build (20)
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
- name: Set up pnpm
uses: pnpm/action-setup@v4
with:
version: 9.14.0

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Lint
run: pnpm lint

- name: Build
run: pnpm build

- name: Cache build output
uses: actions/cache@v4
with:
path: ./lib
key: ${{ runner.os }}-node-20-build-${{ github.sha }}
restore-keys: |
${{ runner.os }}-build-20
test-unit-18:
name: test (unit) (18)
needs: build-18
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up pnpm
uses: pnpm/action-setup@v4
with:
version: 9.14.0

Expand All @@ -76,40 +110,33 @@ jobs:
- name: Install Playwright browsers
run: pnpm exec playwright install

- name: Lint
run: pnpm lint

- name: Unit tests
run: pnpm test:unit

test-node:
name: test (node.js)
needs: build
if: ${{ needs.build.outputs.node-version == '18' || needs.build.outputs.node-version == '20' }}
test-node-18:
name: test (node.js) (18)
needs: build-18
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
node-version: [18, 20]
steps:
- name: Checkout
uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
- name: Set up pnpm
uses: pnpm/action-setup@v4
with:
version: 9.14.0

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
node-version: 18
cache: 'pnpm'

- name: Restore build cache
uses: actions/cache@v4
with:
path: ./lib
key: ${{ runner.os }}-node-${{ matrix.node-version }}-build-${{ github.sha }}
key: ${{ runner.os }}-node-18-build-${{ github.sha }}
restore-keys: |
${{ runner.os }}-node-18-build-
Expand All @@ -119,16 +146,49 @@ jobs:
- name: Node.js tests
run: pnpm test:node

test-node-20:
name: test (node.js) (20)
needs: build-20
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up pnpm
uses: pnpm/action-setup@v4
with:
version: 9.14.0

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'

- name: Restore build cache
uses: actions/cache@v4
with:
path: ./lib
key: ${{ runner.os }}-node-20-build-${{ github.sha }}
restore-keys: |
${{ runner.os }}-node-20-build-
- name: Install dependencies
run: pnpm install

- name: Node.js tests
run: pnpm test:node

test-browser:
name: test (browser)
needs: build
if: ${{ needs.build.outputs.node-version == '18' }}
needs: build-18
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
- name: Set up pnpm
uses: pnpm/action-setup@v4
with:
version: 9.14.0

Expand Down Expand Up @@ -164,14 +224,14 @@ jobs:

test-native:
name: test (react-native)
needs: build
if: ${{ needs.build.outputs.node-version == '18' }}
needs: build-18
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
- name: Set up pnpm
uses: pnpm/action-setup@v4
with:
version: 9.14.0

Expand Down

0 comments on commit 850b97f

Please sign in to comment.