Skip to content

Commit

Permalink
setup(ci): use ljharb/actions/node/matrix (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb authored Jan 14, 2025
1 parent fcd4f58 commit a3efe16
Showing 1 changed file with 38 additions and 24 deletions.
62 changes: 38 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,68 +6,82 @@ name: CI

on:
push:
branches: ["main"]
branches: ["*"]
paths:
- "recipes/**"
- "package.json"
- "package-lock.json"
- ".github/workflows/*.yml"
pull_request:
branches: ["main"]
branches: ["*"]
paths:
- "recipes/**"
- "package.json"
- "package-lock.json"
- ".github/workflows/*.yml"
types:
- opened
- ready_for_review
- reopened
- synchronize

jobs:
get-matrix:
runs-on: ubuntu-latest
outputs:
latest: ${{ steps.set-matrix.outputs.requireds }}
steps:
- uses: ljharb/actions/node/matrix@main
id: set-matrix
with:
versionsAsRoot: true
type: majors
preset: ">= 22" # glob is not backported below 22.x

lint-and-types:
if: github.event.pull_request.draft == false
if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }}

runs-on: ubuntu-latest

strategy:
matrix:
node:
- version: 23.x
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
- name: Set up Node.js ${{ matrix.node.version }}
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # 4.1.0
- uses: actions/checkout@v4
with:
node-version: ${{ matrix.node.version }}
cache: 'npm'
persist-credentials: false
show-progress: false
- name: Set up Node.js LTS
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "npm"
- run: npm ci
- run: node --run lint
- run: node --run type-check

tests:
if: github.event.pull_request.draft == false
needs: [get-matrix]
runs-on: ${{ matrix.os }}

if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }}

strategy:
fail-fast: false
matrix:
node:
- version: 23.x
- version: 22.x
# glob is not backported below 22.x
node-version: ${{ fromJson(needs.get-matrix.outputs.latest) }}
os:
- macos-latest
- ubuntu-latest
- windows-latest

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
- name: Set up Node.js ${{ matrix.node.version }}
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # 4.1.0
- uses: actions/checkout@v4
with:
persist-credentials: false
show-progress: false
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node.version }}
cache: 'npm'
node-version: ${{ matrix.node-version }}
cache: "npm"
- run: npm ci
- name: Run recipe tests
run: >-
Expand Down

0 comments on commit a3efe16

Please sign in to comment.