Skip to content

Commit

Permalink
chore: unify workflow setup and add more checks
Browse files Browse the repository at this point in the history
  • Loading branch information
samrith-s committed Dec 10, 2023
1 parent 0b70313 commit b808411
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 52 deletions.
29 changes: 29 additions & 0 deletions .github/actions/setup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Setup

inputs:
lockfile:
required: true
default: "./yarn.lock"
working-directory:
required: false
default: "."
node-version:
required: false,
default: 18

runs:
using: "composite"
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
cache: yarn
cache-dependency-path: ${{ inputs.lockfile }}

- name: Install dependencies
working-directory: ${{ inputs.working-directory }}
run: yarn install --frozen-lockfile --prefer-offline
60 changes: 23 additions & 37 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,45 @@ on:
push:
branches:
- main
paths-ignore:
- "docs/**"
- "README.md"
pull_request:
paths-ignore:
- "docs/**"
- "README.md"

concurrency:
group: checks
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

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

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn
cache-dependency-path: "**/yarn.lock"

- name: Install dependencies
run: yarn install --frozen-lockfile --prefer-offline
- name: Setup
uses: ./.github/actions/setup.yml

- name: Lint
run: yarn lint

tests:
name: Tests
types:
name: Types
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup.yml

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn
cache-dependency-path: "**/yarn.lock"
- name: Type check
run: yarn tsc -p .

- name: Install dependencies
run: yarn install --frozen-lockfile --prefer-offline
tests:
name: Tests
runs-on: ubuntu-latest
steps:
- name: Setup
uses: ./.github/actions/setup.yml

- name: Test
run: yarn test --max-workers="75%" --coverage
Expand All @@ -55,18 +51,8 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn
cache-dependency-path: "**/yarn.lock"

- name: Install dependencies
run: yarn install --frozen-lockfile --prefer-offline
- name: Setup
uses: ./.github/actions/setup.yml

- name: Build
run: yarn build
33 changes: 19 additions & 14 deletions .github/workflows/github-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,39 @@ permissions:
id-token: write

concurrency:
group: pages
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

env:
BUILD_PATH: docs
BUILD_PATH: "./docs"

jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- name: Setup
uses: ./.github/actions/setup.yml
with:
working-directory: ${{ env.BUILD_PATH }}

- name: Lint check
run: yarn lint:docs

build:
name: Build
needs: check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
- name: Setup
uses: ./.github/actions/setup.yml
with:
node-version: 18
cache: yarn
cache-dependency-path: ${{ env.BUILD_PATH }}/yarn.lock
working-directory: ${{ env.BUILD_PATH }}

- name: Setup Pages
- name: Setup pages
id: pages
uses: actions/configure-pages@v4

- name: Install dependencies
working-directory: ${{ env.BUILD_PATH }}
run: yarn install --frozen-lockfile --ignore-scripts --prefer-offline

- name: Build
working-directory: ${{ env.BUILD_PATH }}
run: |
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"build": "NODE_ENV=production rollup -c rollup.config.js --bundleConfigAsCjs && size-limit",
"clean": "rm -rf lib/",
"test": "jest",
"lint": "eslint {src,docs}/**/*.ts --cache",
"lint": "eslint src/**/*.ts --cache",
"lint:docs": "eslint docs/**/*.ts --cache",
"prettify": "prettier --write {src,tests,docs}/**/*",
"docs": "yarn --cwd docs"
},
Expand Down

0 comments on commit b808411

Please sign in to comment.