Skip to content

Commit

Permalink
chore: refactor ci to use corepack and package manager via matrix (#11)
Browse files Browse the repository at this point in the history
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
  • Loading branch information
dominikg and bluwy authored Aug 24, 2024
1 parent d8d82fa commit bf0c19a
Show file tree
Hide file tree
Showing 5 changed files with 398 additions and 417 deletions.
93 changes: 23 additions & 70 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
name: CI

env:
# configure corepack
COREPACK_DEFAULT_TO_LATEST: 0
COREPACK_ENABLE_AUTO_PIN: 0
# configure yarn
YARN_ENABLE_IMMUTABLE_INSTALLS: 'false'

on:
push:
branches:
Expand All @@ -15,86 +22,32 @@ on:
jobs:
test:
name: Test
timeout-minutes: 10
timeout-minutes: 5
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
node: [16]
node: [20]
os: [ubuntu-latest, macos-latest, windows-latest]
pm: ["pnpm@9"]
include:
- node: 18
- node: 22
os: ubuntu-latest
pm: "pnpm@9"
- node: 22
os: ubuntu-latest
pm: "yarn@4"
- node: 22
os: ubuntu-latest
pm: "npm@10"
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2.2.4
with:
version: '7.14.1'

- name: Setup node
uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: pnpm
cache-dependency-path: '**/pnpm-lock.yaml'

- name: Install dependencies
run: pnpm install --frozen-lockfile --prefer-offline

- name: Test
run: pnpm test

test-npm:
name: Test npm
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup workspaces
run: cat package.json | jq '.workspaces = ["tests/deps/*","tests/projects/*"]' | tee package.json

- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16

- name: Install dependencies
run: npm install

- name: Test
run: npm test

test-yarn:
name: Test yarn PnP
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup workspaces
run: cat package.json | jq '.workspaces = ["tests/deps/*","tests/projects/*"]' | tee package.json

- name: Use yarn 3
run: cat package.json | jq '.packageManager = "yarn@3.2.4"' | tee package.json

- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16

- name: Enable corepack
run: corepack enable

- run: corepack enable
- name: Install dependencies
run: yarn
env:
YARN_ENABLE_IMMUTABLE_INSTALLS: false
run: corepack ${{matrix.pm}} install

- name: Test
run: yarn test
run: corepack ${{matrix.pm}} test
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
node_modules
node_modules
.yarn
.pnp.*
yarn.lock
package-lock.json
3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
auto-install-peers=false
link-workspace-packages=true
dedupe-injected-deps=false # needed for file: references to work
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,9 @@
"devDependencies": {
"uvu": "^0.5.6",
"vite": "^3.2.3"
}
},
"workspaces": [
"tests/deps/*",
"tests/projects/*"
]
}
Loading

0 comments on commit bf0c19a

Please sign in to comment.