Skip to content

Commit def5c74

Browse files
authored
Revamp CI setup (#52)
* Revamp CI setup * tweak * add comment * build before tests to generate github graphql stuff
1 parent 1723769 commit def5c74

5 files changed

Lines changed: 161 additions & 47 deletions

File tree

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/.github/** @Andarist @bluwy
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Setup CI
2+
description: Setup CI
3+
4+
inputs:
5+
node-version:
6+
description: Node.js version
7+
required: false
8+
default: 24
9+
skip-cache:
10+
description: "Whether to skip the cache"
11+
required: false
12+
default: "false"
13+
14+
runs:
15+
using: composite
16+
steps:
17+
- name: Set up pnpm
18+
uses: pnpm/action-setup@91ab88e2619ed1f46221f0ba42d1492c02baf788 # v6.0.6
19+
20+
- name: Set up Node.js ${{ inputs.node-version }}
21+
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
22+
with:
23+
node-version: ${{ inputs.node-version }}
24+
package-manager-cache: ${{ inputs.skip-cache != 'true' }}
25+
cache: ${{ inputs.skip-cache != 'true' && 'pnpm' || '' }}
26+
27+
- name: Install dependencies
28+
shell: bash
29+
run: pnpm install --frozen-lockfile

.github/dependabot.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "npm" # See documentation for possible values
9+
directory: "/" # Location of package manifests
10+
schedule:
11+
interval: "weekly"
12+
cooldown:
13+
default-days: 7

.github/workflows/ci.yml

Lines changed: 68 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,83 @@
1-
name: CI Checks
1+
name: CI
2+
23
on:
34
pull_request:
4-
push:
5+
# merge queue is required so all commits on target branches trigger this workflow
6+
# despite lack of the push event trigger here
7+
merge_group:
58
branches:
69
- main
710

811
permissions:
9-
contents: write
12+
contents: read
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.sha }}
16+
cancel-in-progress: true
1017

1118
jobs:
12-
ci-checks:
19+
build:
20+
name: Build
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Check out repo
24+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
25+
with:
26+
persist-credentials: false
27+
28+
- uses: ./.github/actions/ci-setup
29+
30+
- name: Build
31+
run: pnpm build
32+
33+
lint:
34+
name: Lint
1335
runs-on: ubuntu-latest
1436
steps:
15-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
37+
- name: Check out repo
38+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
1639
with:
17-
fetch-depth: 2
18-
- name: Use Node.js
19-
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
40+
persist-credentials: false
41+
42+
- uses: ./.github/actions/ci-setup
43+
44+
- name: Lint
45+
run: pnpm lint
46+
47+
- name: Format
48+
run: pnpm format:check
49+
50+
test:
51+
name: Test
52+
runs-on: ubuntu-latest
53+
timeout-minutes: 20
54+
permissions:
55+
contents: write # integration tests create and push temporary branches
56+
steps:
57+
- name: Check out repo
58+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2059
with:
21-
node-version: 24.x
22-
- name: Extract pnpm version and install
23-
run: |
24-
VERSION=$(cat package.json | grep '"packageManager": "pnpm@' | sed 's/.*"pnpm@\([^"]*\)".*/\1/')
25-
npm install -g pnpm@$VERSION
26-
- uses: actions/cache@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2
60+
fetch-depth: 2 # integration tests read the two most recent local commits
61+
persist-credentials: false
62+
63+
- uses: ./.github/actions/ci-setup
2764
with:
28-
path: ~/.pnpm-store
29-
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
30-
- run: pnpm install --frozen-lockfile
31-
- run: pnpm build
32-
- run: pnpm lint
33-
- run: pnpm format:check
34-
- run: pnpm test:integration
65+
skip-cache: true # avoid cache poisoning from this only job with write access, just in case
66+
67+
- name: Build
68+
run: pnpm build
69+
70+
- name: Integration tests
71+
run: pnpm test:integration
3572
env:
3673
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37-
HEAD_OID: ${{ github.base_ref }}
74+
75+
ci-ok:
76+
name: CI OK
77+
runs-on: ubuntu-latest
78+
if: always()
79+
needs: [build, lint, test]
80+
steps:
81+
- name: Exit with error if some jobs are not successful
82+
if: ${{ always() && (contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')) }}
83+
run: exit 1

.github/workflows/publish.yml

Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,66 @@
1-
name: Release & Publish
1+
name: Publish
22

33
on:
44
push:
55
branches:
66
- main
77

8-
permissions:
9-
contents: write
10-
pull-requests: write
11-
id-token: write
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: false
11+
queue: max
12+
13+
permissions: {}
1214

1315
jobs:
14-
release-and-publish:
16+
version:
17+
name: Version
1518
runs-on: ubuntu-latest
19+
timeout-minutes: 10
20+
outputs:
21+
hasChangesets: ${{ steps.changesets.outputs.hasChangesets }}
22+
permissions:
23+
contents: write # to create version commits (changesets/action)
24+
pull-requests: write # to create pull request (changesets/action)
1625
steps:
17-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
26+
- name: Check out repo
27+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
28+
with:
29+
persist-credentials: false
30+
31+
- uses: ./.github/actions/ci-setup
1832
with:
19-
token: ${{ secrets.GITHUB_TOKEN }}
20-
- name: Use Node.js
21-
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
33+
skip-cache: true # avoid cache poisoning attacks
34+
35+
- name: Create or update release pull request
36+
id: changesets
37+
uses: changesets/action@63a615b9cd06ba9a3e6d13796c7fbcb080a60a0b # v1.8.0
38+
39+
publish:
40+
name: Publish
41+
if: needs.version.outputs.hasChangesets == 'false'
42+
needs: version
43+
runs-on: ubuntu-latest
44+
environment: npm
45+
timeout-minutes: 10
46+
permissions:
47+
contents: write # to create release (changesets/action)
48+
id-token: write # to use OpenID Connect token for trusted publishing (changesets/action)
49+
steps:
50+
- name: Check out repo
51+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2252
with:
23-
node-version: 24.x
24-
- name: Extract pnpm version and install
25-
run: |
26-
VERSION=$(cat package.json | grep '"packageManager": "pnpm@' | sed 's/.*"pnpm@\([^"]*\)".*/\1/')
27-
npm install -g pnpm@$VERSION
28-
- name: Cache pnpm modules
29-
uses: actions/cache@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2
53+
persist-credentials: false
54+
55+
- uses: ./.github/actions/ci-setup
3056
with:
31-
path: ~/.pnpm-store
32-
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
33-
- run: pnpm install --frozen-lockfile
34-
- run: pnpm build
35-
- name: Run Changeset Workflow
36-
uses: changesets/action@c48e67d110a68bc90ccf1098e9646092baacaa87 # v1.6.0
37-
env:
38-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
skip-cache: true # avoid cache poisoning attacks
58+
59+
- name: Build
60+
run: pnpm build
61+
62+
- name: Publish to npm
63+
uses: changesets/action@63a615b9cd06ba9a3e6d13796c7fbcb080a60a0b # v1.8.0
3964
with:
4065
publish: pnpm changeset publish
4166
commitMode: github-api

0 commit comments

Comments
 (0)