Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize package.json scripts #15

Merged
merged 3 commits into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/actions/install-node-pnpm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: 'Install Node and pnpm'
description: 'Install Node and pnpm with caching for fast install'

inputs:
node-version:
description: 'The version of Node to install'
default: '18'
required: false
pnpm-version:
description: 'The version of pnpm to install'
default: '8'
required: false

runs:
using: "composite"
steps:
- name: Install Node
uses: actions/setup-node@v3
with:
node-version: ${{ inputs.node-version }}

- name: Install pnpm
uses: pnpm/action-setup@v2
id: pnpm-install
with:
version: ${{ inputs.pnpm-version }}
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT

- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

# Run install with optional filter if present
- name: Install pnpm dependencies
shell: bash
run: pnpm install --frozen-lockfile
70 changes: 31 additions & 39 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,40 @@
name: CI

on: [push, pull_request]
on:
push:
branches:
- master
pull_request:

jobs:
test:
name: Test Node.js ${{ matrix.node-version }}
types:
name: Types
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
node-version:
- 21
- 20
- 18

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Install pnpm
uses: pnpm/action-setup@v2
id: pnpm-install
with:
version: 8
run_install: false
- uses: actions/checkout@v4
- uses: ./.github/actions/install-node-pnpm
- run: pnpm run typecheck

- 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:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/install-node-pnpm
- run: pnpm run lint

- name: Install dependencies
run: pnpm install --frozen-lockfile
format:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/install-node-pnpm
- run: pnpm run format

- name: Run test
run: pnpm run test
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/install-node-pnpm
- run: pnpm run test
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,20 @@
],
"scripts": {
"build": "tsc --project tsconfig.dist.json",
"prebuild": "rimraf dist",
"clean": "rimraf node_modules dist",
"dev": "tsc --watch",
"prepare": "run-s build",
"release": "np",
"predocs": "rimraf docs/pages/docs",
"docs": "run-s docs:*",
"docs:typedoc": "typedoc",
"docs": "pnpm run docs:transform && pnpm run docs:typedoc",
"docs:transform": "tsx docs/bin/transform-docs.ts",
"test": "run-p test:*",
"test:lint": "eslint --cache --cache-location ./node_modules/.cache/eslint .",
"test:format": "prettier --check \"**/*.{js,ts,tsx}\"",
"test:unit": "dotenv -e .env.example -- vitest",
"test:typecheck": "tsc --noEmit"
"docs:typedoc": "typedoc",
"format": "prettier --check \"**/*.{js,ts,tsx}\"",
"lint": "eslint --cache --cache-location ./node_modules/.cache/eslint .",
"prebuild": "rimraf dist",
"predocs": "rimraf docs/pages/docs",
"prepare": "pnpm run build",
"prepublishOnly": "pnpm run lint && pnpm run typecheck",
"release": "np",
"test": "dotenv -e .env.example -- vitest",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@fastify/deepmerge": "^1.3.0",
Expand All @@ -86,7 +86,6 @@
"eslint": "^8.54.0",
"globby": "^14.0.0",
"np": "^8.0.4",
"npm-run-all": "^4.1.5",
"prettier": "^2.8.8",
"rimraf": "^5.0.5",
"tsx": "^4.1.4",
Expand Down Expand Up @@ -114,5 +113,6 @@
"rules": {
"no-console": "off"
}
}
},
"packageManager": "pnpm@8.6.12"
}
Loading