Skip to content

Commit

Permalink
chore: improve GitHub Actions pipelines to reuse prepare tasks and us…
Browse files Browse the repository at this point in the history
…e PNPM version 9
  • Loading branch information
LuudJanssen committed Oct 28, 2024
1 parent d8e247d commit 7dc92a6
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 92 deletions.
28 changes: 28 additions & 0 deletions .github/actions/prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Prepare
description: Checks out the code, sets up Node.js and PNPM and installs dependencies

runs:
using: "composite"

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 9

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm

- name: Install dependencies

# Don't run scripts to prevent a malicious package from stealing tokens
# or doing other harmful things.
run: pnpm install --ignore-scripts
20 changes: 2 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,8 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 8

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm

- name: Install dependencies
run: pnpm install
- name: Prepare
uses: ./.github/actions/prepare

- name: Run builds
run: pnpm build
62 changes: 7 additions & 55 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,8 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 8

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm

- name: Install dependencies
run: pnpm install
- name: Prepare
uses: ./.github/actions/prepare

- name: Run lint commands
run: pnpm lint
Expand All @@ -42,24 +26,8 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 8

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm

- name: Install dependencies
run: pnpm install
- name: Prepare
uses: ./.github/actions/prepare

- name: Run builds
run: pnpm build
Expand All @@ -69,24 +37,8 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 8

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Prepare
uses: ./.github/actions/prepare

- name: Install dependencies
run: pnpm install

- name: Run builds
- name: Run tests
run: pnpm test
22 changes: 3 additions & 19 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,8 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Prepare
uses: ./.github/actions/prepare

- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 8

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm

- name: Install dependencies
run: pnpm install

- name: Run builds
- name: Run tests
run: pnpm test

0 comments on commit 7dc92a6

Please sign in to comment.