Skip to content

Commit

Permalink
ci: update ci workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
alanlu-zyl committed Mar 4, 2024
1 parent 9f9d6e5 commit c020990
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 87 deletions.
139 changes: 54 additions & 85 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,120 +5,89 @@ on:
- pull_request

jobs:
build:
name: Build
lint:
timeout-minutes: 10
name: "Lint"
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x

- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: 8
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build packages
run: pnpm run build

lint:
name: Lint
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Use Node.js 20.x
- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20.x
node-version: 20
cache: "pnpm"

- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: 8
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Install deps
run: pnpm install

- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Build
run: pnpm run build

- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Lint
run: pnpm run lint

- name: Lint code
run: npx turbo lint
- name: TypeCheck
run: pnpm run typecheck

test:
name: Test
runs-on: ubuntu-latest

timeout-minutes: 20
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: ['18.x', '20.x']

os: [ubuntu-latest]
node_version: [18, 20]
include:
# Active LTS + other OS
- os: macos-latest
node_version: 20
- os: windows-latest
node_version: 20
fail-fast: false

name: "Build & Test: node-${{ matrix.node_version }}, ${{ matrix.os }}"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Assume PRs are less than 50 commits
fetch-depth: 50

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
- name: Get changed files
id: changed-files
uses: tj-actions/[email protected]
with:
node-version: ${{ matrix.node-version }}
files: |
docs/**
.github/**
!.github/workflows/ci.yml
**.md
- name: Install pnpm
if: steps.changed-files.outputs.only_changed != 'true'
uses: pnpm/action-setup@v3
with:
version: 8
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v4
- name: Set node version to ${{ matrix.node_version }}
if: steps.changed-files.outputs.only_changed != 'true'
uses: actions/setup-node@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
node-version: ${{ matrix.node_version }}
cache: "pnpm"

- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Install deps
if: steps.changed-files.outputs.only_changed != 'true'
run: pnpm install

- name: Build
if: steps.changed-files.outputs.only_changed != 'true'
run: pnpm run build

- name: Run tests
run: npx turbo test
- name: Test unit
if: steps.changed-files.outputs.only_changed != 'true'
run: pnpm run test
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "@alanlu-dev/web-kit",
"type": "module",
"private": true,
"packageManager": "[email protected]",
"description": "A monorepo starter template",
Expand All @@ -23,9 +24,10 @@
"modules:clean": "npx rimraf --glob ./**/node_modules && rm -rf pnpm-lock.yaml",
"pnpm:clean": "pnpm store prune",
"build": "turbo run build",
"check": "turbo run test lint --parallel",
"check": "turbo run test lint typecheck --parallel",
"test": "turbo run test",
"lint": "turbo run lint",
"typecheck": "turbo run typecheck",
"nuxt-demo": "pnpm --filter=@alanlu-dev/nuxt-demo",
"commit": "czg",
"changeset": "changeset",
Expand Down
3 changes: 2 additions & 1 deletion turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"outputs": ["coverage/**"],
"inputs": ["src/**/*.tsx", "src/**/*.ts", "test/**/*.ts", "test/**/*.tsx"]
},
"lint": {}
"lint": {},
"typecheck": {}
}
}

0 comments on commit c020990

Please sign in to comment.