Skip to content

Commit

Permalink
feat(ci): split Node.js setup into separate composite action
Browse files Browse the repository at this point in the history
  • Loading branch information
jkomyno committed Oct 1, 2024
1 parent f123e19 commit c7ce8dd
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 24 deletions.
44 changes: 44 additions & 0 deletions .github/actions/setup-node/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: 'Setup (Node.js)'

description: 'Setup Node.js and pnpm'

inputs:
node-version:
description: 'The Node.js version to use'
required: true
default: 'lts'
pnpm-version:
description: 'The pnpm version to use'
required: true
default: 'latest'

runs:
# Read about composite actions in:
# https://docs.github.com/en/actions/sharing-automations/avoiding-duplication.
#
# Composite actions cannot use secrets, and are logged as a single step.
using: 'composite'
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}

- uses: pnpm/action-setup@v4
with:
version: ${{ inputs.pnpm-version }}
run_install: false
standalone: true
dest: ~/setup-pnpm

- name: Cache pnpm modules
uses: actions/cache@v4
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-${{ matrix.node }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-${{ matrix.node }}-node-
- name: Install dependencies
run: pnpm install --frozen-lockfile
shell: bash
30 changes: 7 additions & 23 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,40 +25,24 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
node: ['20.9.0']
node: ['20.17.0']
pnpm: ['9.11.0']

name: "Build: ${{ matrix.os }}, Node.js ${{ matrix.node }}"

env:
CI: 1

steps:
- name: Prepare git
run: git config --global core.autocrlf false

- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 20

- uses: pnpm/action-setup@v4
with:
version: 8.15.8
run_install: false
standalone: true
dest: ~/setup-pnpm
fetch-depth: 0

- name: Cache pnpm modules
uses: actions/cache@v4
- name: Setup (Node.js)
uses: ./.github/actions/setup-node
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-${{ matrix.node }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-${{ matrix.node }}-node-
- name: Install dependencies
run: pnpm i
node-version: ${{ matrix.node }}
pnpm-version: ${{ matrix.pnpm }}

- name: Transpile TS to JS
run: pnpm build
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.9.0
20.17.0

0 comments on commit c7ce8dd

Please sign in to comment.