Skip to content

Commit

Permalink
Standardize GitHub Actions workflow
Browse files Browse the repository at this point in the history
With most other Dexa projects.
  • Loading branch information
rileytomasek committed Oct 13, 2024
1 parent cd0ff68 commit 532d8c7
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 43 deletions.
41 changes: 41 additions & 0 deletions .github/actions/install-node-pnpm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
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: '20'
required: false

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

- name: Install pnpm
uses: pnpm/action-setup@v4
id: pnpm-install
with:
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@v4
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
67 changes: 24 additions & 43 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,32 @@
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:
- 18
- 20
- 21
- 22

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

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Install pnpm
uses: pnpm/action-setup@v3
id: pnpm-install
with:
version: 9.7.0
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-
- uses: actions/checkout@v4
- uses: ./.github/actions/install-node-pnpm
- run: pnpm run typecheck

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

- name: Run test
run: pnpm run test
format:
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/install-node-pnpm
- run: pnpm run format

0 comments on commit 532d8c7

Please sign in to comment.