Skip to content

Commit 7d59842

Browse files
committed
ci: update ci.yml
1 parent 2d922d1 commit 7d59842

File tree

1 file changed

+40
-20
lines changed

1 file changed

+40
-20
lines changed

.github/workflows/ci.yml

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,57 @@
1-
name: Node.js CI
1+
name: CI
22

33
on:
44
push:
5-
branches: ['main']
5+
branches:
6+
- main
7+
- develop
68
pull_request:
7-
branches: ['main']
9+
branches:
10+
- main
11+
- develop
812

913
jobs:
10-
build:
14+
test-and-lint:
1115
runs-on: ubuntu-latest
1216

13-
strategy:
14-
matrix:
15-
node-version: [18.x, 20.x]
16-
1717
steps:
18-
- uses: actions/checkout@v4
19-
- name: Use Node.js ${{ matrix.node-version }}
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
# Configure fetch-depth to 0 if you need full history for some operations
21+
# with:
22+
# fetch-depth: 0
23+
24+
- name: Setup Node.js
2025
uses: actions/setup-node@v4
2126
with:
22-
node-version: ${{ matrix.node-version }}
27+
node-version: '18' # Or your preferred Node.js version
2328
cache: 'npm'
29+
2430
- name: Install dependencies
2531
run: npm ci
26-
- name: Lint code
32+
33+
- name: Run ESLint
2734
run: npm run lint
28-
- name: Lint Markdown files
29-
run: npm run lint:md
30-
- name: Check formatting
31-
run: npm run format
32-
- name: Check Markdown formatting
33-
run: npm run format:md
34-
- name: Audit for vulnerabilities
35-
run: npm audit --omit-dev --omit=optional --omit=peer
35+
3636
- name: Run tests
3737
run: npm test
38+
39+
- name: Check README TOC consistency
40+
run: |
41+
# Run the 'toc' script to generate/update the TOC in README.md.
42+
# The 'doctoc' package should be installed as a devDependency and handled by 'npm ci'.
43+
npm run toc
44+
45+
# Check if 'doctoc' made any changes to README.md.
46+
# 'git diff --exit-code' returns a non-zero exit code if there are differences.
47+
git diff --exit-code README.md || (echo "Error: README.md Table of Contents is not up to date. Please run 'npm run toc' locally and commit the changes." && exit 1)
48+
env:
49+
CI: true # Ensure CI environment is recognized, if needed by doctoc
50+
51+
# Optional: Upload coverage to Codecov (only if enabled and token is provided)
52+
- name: Upload coverage to Codecov
53+
uses: codecov/codecov-action@v4
54+
with:
55+
token: ${{ secrets.CODECOV_TOKEN }}
56+
files: ./coverage/lcov.info # Path to your lcov coverage file
57+
if: success() && secrets.CODECOV_TOKEN # Only run if previous steps succeeded and token exists

0 commit comments

Comments
 (0)