Skip to content

Commit 32834c4

Browse files
chore(ci): improve ci (#281)
Co-authored-by: Sebastian Beltran <[email protected]>
1 parent ad8c212 commit 32834c4

File tree

5 files changed

+121
-42
lines changed

5 files changed

+121
-42
lines changed

.github/workflows/ci.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
12+
env:
13+
FORCE_COLOR: 1
14+
15+
jobs:
16+
quality:
17+
name: Lint & Format
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Harden Runner
22+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
23+
with:
24+
egress-policy: audit
25+
26+
- name: Checkout code
27+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
28+
29+
- name: Setup Node.js
30+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
31+
with:
32+
node-version-file: '.nvmrc'
33+
cache: 'npm'
34+
35+
- name: Install dependencies
36+
run: npm ci
37+
38+
- name: Run linting
39+
run: node --run lint
40+
41+
- name: Check formatting
42+
run: node --run format:check
43+
44+
test:
45+
name: Test & Coverage
46+
runs-on: ubuntu-latest
47+
48+
steps:
49+
- name: Harden Runner
50+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
51+
with:
52+
egress-policy: audit
53+
54+
- name: Checkout code
55+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
56+
57+
- name: Setup Node.js
58+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
59+
with:
60+
node-version-file: '.nvmrc'
61+
cache: 'npm'
62+
63+
- name: Install dependencies
64+
run: npm ci
65+
66+
- name: Run tests with coverage
67+
run: node --run test:ci
68+
69+
- name: Upload coverage to Codecov
70+
if: always()
71+
uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d # v5.4.2
72+
with:
73+
files: ./lcov.info
74+
75+
- name: Upload test results to Codecov
76+
if: always()
77+
uses: codecov/test-results-action@f2dba722c67b86c6caa034178c6e4d35335f6706 # v1.1.0
78+
with:
79+
files: ./junit.xml

.github/workflows/pr.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ npm-debug.log
44

55
# Default Output Directory
66
out
7+
8+
# Tests
9+
lcov.info
10+
junit.xml

package-lock.json

Lines changed: 35 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
"lint:fix": "eslint --fix . --no-warn-ignored",
1010
"format": "prettier .",
1111
"format:write": "prettier --write .",
12+
"format:check": "prettier --check .",
1213
"test": "node --test",
1314
"test:coverage": "node --experimental-test-coverage --test",
15+
"test:ci": "node --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=lcov.info --test-reporter=junit --test-reporter-destination=junit.xml --test-reporter=@reporters/github --test-reporter-destination=stdout --test-reporter=spec --test-reporter-destination=stdout --test",
1416
"test:update-snapshots": "node --test --test-update-snapshots",
1517
"test:watch": "node --test --watch",
1618
"prepare": "husky",
@@ -23,6 +25,7 @@
2325
},
2426
"devDependencies": {
2527
"@eslint/js": "^9.27.0",
28+
"@reporters/github": "^1.7.2",
2629
"@types/mdast": "^4.0.4",
2730
"@types/node": "^22.15.3",
2831
"eslint": "^9.27.0",

0 commit comments

Comments
 (0)