Skip to content

Commit da3e1e5

Browse files
pkerschbaumnzakas
andauthored
ci: setup checks for update of branch main and for PRs (#86)
Co-authored-by: Nicholas C. Zakas <[email protected]>
1 parent a7b2a22 commit da3e1e5

File tree

2 files changed

+53
-2
lines changed

2 files changed

+53
-2
lines changed

.github/workflows/ci.yml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: CI
2+
3+
# configure concurrency: cancel pending and in-progress workflow runs if a new commit to the same branch is pushed (`github.head_ref` is the source branch of PRs, `github.ref_name` is the branch name of non-PR events)
4+
concurrency:
5+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
6+
cancel-in-progress: true
7+
8+
on:
9+
push:
10+
branches:
11+
- main
12+
pull_request:
13+
branches:
14+
- main
15+
types:
16+
- opened # new PR was created
17+
- synchronize # the last commit of the `head_ref` (= source branch) changed, e.g. a new commit was pushed or the source branch was rebased
18+
- ready_for_review # the PR switched from draft to non-draft
19+
- reopened # PR had been closed and got reopened
20+
21+
jobs:
22+
check:
23+
name: Checks (typechecking, linting, formatting)
24+
# run only if triggered by push on a branch or by a PR event for a PR which is not a draft
25+
if: ${{ !github.event.pull_request || github.event.pull_request.draft == false }}
26+
runs-on: ubuntu-24.04
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- name: Install Node.js
31+
uses: actions/setup-node@v4
32+
with:
33+
node-version-file: ".nvmrc"
34+
cache: npm
35+
36+
- name: Install dependencies
37+
run: |
38+
npm ci
39+
40+
- name: Typecheck everything (tsc)
41+
run: |
42+
npm run build:types
43+
44+
- name: Lint everything (eslint)
45+
run: |
46+
npm run lint
47+
48+
- name: Check formatting of everything (prettier)
49+
run: |
50+
npm run fmt

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212
"build:preview": "vite preview",
1313
"build:readme": "node tools/update-readme.js",
1414
"start": "vite",
15+
"build:types": "tsc",
1516
"lint": "npm-run-all --parallel lint:js",
1617
"lint:fix": "npm-run-all --parallel lint:fix:*",
17-
"lint:js": "eslint .",
18-
"lint:fix:js": "eslint . --fix",
18+
"lint:js": "eslint --max-warnings 0 .",
19+
"lint:fix:js": "eslint --max-warnings 0 . --fix",
1920
"fmt": "prettier --check .",
2021
"fmt:fix": "prettier --write ."
2122
},

0 commit comments

Comments
 (0)