Skip to content

Commit

Permalink
chore: update workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
JeromeLin committed May 31, 2023
1 parent 2427c82 commit 49aeaa2
Show file tree
Hide file tree
Showing 2 changed files with 307 additions and 6 deletions.
290 changes: 290 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,290 @@
name: CI
on:
push:
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 7

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Lint
run: pnpm run lint

test-cli:
name: Test @zarm-design/cli on Node.js
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18, 16, 14, 12, 10]
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 7

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Test
run: pnpm --filter @zarm-design/cli run test

compile-cli:
name: Compile @zarm-design/cli
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 7

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Cache
uses: actions/cache@v3
with:
path: packages/zarm-cli/dist
key: cli-${{ github.sha }}

- name: Compile
run: pnpm --filter @zarm-design/cli run build

compile-bem:
needs: [compile-cli]
name: Compile @zarm-design/bem
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 7

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Restore Cache from @zarm-design/cli
uses: actions/cache@v3
with:
path: packages/zarm-cli/dist
key: cli-${{ github.sha }}

- name: Cache
uses: actions/cache@v3
with:
path: packages/bem/lib
key: bem-${{ github.sha }}

- name: Compile
run: pnpm --filter @zarm-design/bem run build

compile-icons:
needs: [compile-bem]
name: Compile @zarm-design/icons
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 7

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Restore Cache from @zarm-design/cli
uses: actions/cache@v3
with:
path: packages/zarm-cli/dist
key: cli-${{ github.sha }}

- name: Restore Cache from @zarm-design/bem
uses: actions/cache@v3
with:
path: packages/bem/lib
key: bem-${{ github.sha }}

- name: Cache
uses: actions/cache@v3
with:
path: packages/zarm-icons/lib
key: icons-${{ github.sha }}

- name: Compile
run: pnpm --filter @zarm-design/icons run build

Compile:
needs: [compile-icons]
name: Compile Zarm
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 7

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Restore Cache from @zarm-design/cli
uses: actions/cache@v3
with:
path: packages/zarm-cli/dist
key: cli-${{ github.sha }}

- name: Restore Cache from @zarm-design/bem
uses: actions/cache@v3
with:
path: packages/bem/lib
key: bem-${{ github.sha }}

- name: Restore Cache from @zarm-design/icons
uses: actions/cache@v3
with:
path: packages/zarm-icons/lib
key: icons-${{ github.sha }}

- name: Compile
run: |
pnpm --filter zarm run build:es
pnpm --filter zarm run build:lib
Test:
name: Test Zarm
runs-on: ubuntu-latest
strategy:
matrix:
react: ['16', '17', '18']
module: ['dom', 'dist']
env:
REACT: ${{ matrix.react }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 7

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Install React v16
if: ${{ matrix.react == '16' }}
run: pnpm --filter zarm run install-react-16

- name: Install React v18
if: ${{ matrix.react == '18' }}
run: pnpm --filter zarm run install-react-18

- name: Restore Cache from @zarm-design/cli
uses: actions/cache@v3
with:
path: packages/zarm-cli/dist
key: cli-${{ github.sha }}

- name: Restore Cache from @zarm-design/bem
uses: actions/cache@v3
with:
path: packages/bem/lib
key: bem-${{ github.sha }}

- name: Restore Cache from @zarm-design/icons
uses: actions/cache@v3
with:
path: packages/zarm-icons/lib
key: icons-${{ github.sha }}

- name: Check dist
if: ${{ matrix.module == 'dist' }}
run: pnpm --filter zarm node ./tests/dekko/dist.test.js

- name: Check bundlesize
if: ${{ matrix.module == 'dist' }}
run: pnpm --filter zarm npx bundlesize
env:
BUNDLESIZE_GITHUB_TOKEN: ${{ secrets.BUNDLESIZE_GITHUB_TOKEN }}

- name: Test
if: ${{ matrix.module == 'dom' }}
run: pnpm --filter zarm run coverage

- name: Coverage
if: ${{ matrix.module == 'dom' && matrix.react == '17' }}
run: bash <(curl -s https://codecov.io/bash)
23 changes: 17 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ jobs:
id: pnpm-install
with:
version: 7
run_install: true

- uses: actions/setup-node@v3
with:
node-version: 16
cache: 'pnpm'

- name: install packages
run: pnpm i --frozen-lockfile
Expand Down Expand Up @@ -213,17 +211,30 @@ jobs:
- name: checkout
uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 16

- uses: pnpm/action-setup@v2
name: install pnpm
id: pnpm-install
with:
version: 7
run_install: true
run_install: false

- uses: actions/setup-node@v3
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
node-version: 16
cache: 'pnpm'
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: lint
run: pnpm lint
Expand Down

0 comments on commit 49aeaa2

Please sign in to comment.