Skip to content

Commit a553ad8

Browse files
feat: split GitHub Actions workflows into separate files for tests, type checking, linting, and formatting
1 parent 42cd120 commit a553ad8

File tree

4 files changed

+204
-0
lines changed

4 files changed

+204
-0
lines changed

.github/workflows/format.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Format
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
format:
11+
name: Prettier
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
node-version: [20.x]
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Use Node.js ${{ matrix.node-version }}
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: ${{ matrix.node-version }}
25+
cache: 'npm'
26+
27+
- name: Install dependencies
28+
run: npm ci
29+
30+
- name: Check formatting
31+
id: format
32+
run: npm run format:check
33+
continue-on-error: true
34+
35+
- name: Create Status Comment
36+
if: github.event_name == 'pull_request' && steps.format.outcome == 'failure'
37+
uses: actions/github-script@v7
38+
with:
39+
script: |
40+
const message = `## Format Check Results\n\n❌ Prettier format check failed. Please run \`npm run format\` to fix formatting issues.`;
41+
42+
github.rest.issues.createComment({
43+
issue_number: context.issue.number,
44+
owner: context.repo.owner,
45+
repo: context.repo.repo,
46+
body: message
47+
});
48+
49+
- name: Check for failures
50+
if: steps.format.outcome == 'failure'
51+
run: exit 1

.github/workflows/lint.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
lint:
11+
name: ESLint
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
node-version: [20.x]
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Use Node.js ${{ matrix.node-version }}
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: ${{ matrix.node-version }}
25+
cache: 'npm'
26+
27+
- name: Install dependencies
28+
run: npm ci
29+
30+
- name: Run linting
31+
id: lint
32+
run: npm run lint
33+
continue-on-error: true
34+
35+
- name: Create Status Comment
36+
if: github.event_name == 'pull_request' && steps.lint.outcome == 'failure'
37+
uses: actions/github-script@v7
38+
with:
39+
script: |
40+
const message = `## Lint Results\n\n❌ ESLint check failed. Please fix the linting issues in your code.`;
41+
42+
github.rest.issues.createComment({
43+
issue_number: context.issue.number,
44+
owner: context.repo.owner,
45+
repo: context.repo.repo,
46+
body: message
47+
});
48+
49+
- name: Check for failures
50+
if: steps.lint.outcome == 'failure'
51+
run: exit 1

.github/workflows/test.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
name: Unit Tests
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
node-version: [20.x]
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Use Node.js ${{ matrix.node-version }}
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: ${{ matrix.node-version }}
25+
cache: 'npm'
26+
27+
- name: Install dependencies
28+
run: npm ci
29+
30+
- name: Run tests
31+
id: test
32+
run: npm run test:precommit
33+
continue-on-error: true
34+
35+
- name: Create Status Comment
36+
if: github.event_name == 'pull_request' && steps.test.outcome == 'failure'
37+
uses: actions/github-script@v7
38+
with:
39+
script: |
40+
const message = `## Test Results\n\n❌ Unit tests failed. Please check the test output for details.`;
41+
42+
github.rest.issues.createComment({
43+
issue_number: context.issue.number,
44+
owner: context.repo.owner,
45+
repo: context.repo.repo,
46+
body: message
47+
});
48+
49+
- name: Check for failures
50+
if: steps.test.outcome == 'failure'
51+
run: exit 1

.github/workflows/typecheck.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Type Check
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
typecheck:
11+
name: TypeScript Check
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
node-version: [20.x]
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Use Node.js ${{ matrix.node-version }}
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: ${{ matrix.node-version }}
25+
cache: 'npm'
26+
27+
- name: Install dependencies
28+
run: npm ci
29+
30+
- name: Run type checking
31+
id: typecheck
32+
run: npm run typecheck
33+
continue-on-error: true
34+
35+
- name: Create Status Comment
36+
if: github.event_name == 'pull_request' && steps.typecheck.outcome == 'failure'
37+
uses: actions/github-script@v7
38+
with:
39+
script: |
40+
const message = `## Type Check Results\n\n❌ TypeScript type checking failed. Please fix type errors in your code.`;
41+
42+
github.rest.issues.createComment({
43+
issue_number: context.issue.number,
44+
owner: context.repo.owner,
45+
repo: context.repo.repo,
46+
body: message
47+
});
48+
49+
- name: Check for failures
50+
if: steps.typecheck.outcome == 'failure'
51+
run: exit 1

0 commit comments

Comments
 (0)