Skip to content

Commit b05c766

Browse files
Implement validation workflow
1 parent 91f0a00 commit b05c766

File tree

3 files changed

+79
-2
lines changed

3 files changed

+79
-2
lines changed

.github/BRANCH_PROTECTION_SETUP.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Branch Protection Setup Guide
2+
3+
To enforce the lint and format checks before PRs can be merged, follow these steps:
4+
5+
## 1. Go to Branch Protection Settings
6+
7+
1. Navigate to your repository on GitHub
8+
2. Go to Settings → Branches
9+
3. Click "Add rule" or edit the existing rule for `main`
10+
11+
## 2. Configure Protection Rules
12+
13+
Set these options:
14+
15+
-**Require a pull request before merging**
16+
-**Require status checks to pass before merging**
17+
- Search for and add: `Lint and Format Check`
18+
-**Require branches to be up to date before merging**
19+
-**Do not allow bypassing the above settings**
20+
21+
## 3. Optional Additional Settings
22+
23+
-**Dismiss stale PR approvals when new commits are pushed**
24+
-**Require review from CODEOWNERS**
25+
26+
## Notes
27+
28+
- The lint/format workflow only runs on PRs, not on pushes to main
29+
- Your existing deploy workflow will continue to run independently
30+
- PRs will be blocked from merging if formatting or TypeScript issues are found
31+
- Contributors can fix issues by running `npm run format` and `npm run typecheck`
32+
33+
## Testing
34+
35+
Create a test PR with formatting issues to verify the workflow blocks merging as expected.

.github/workflows/validate.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Validate
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
# Concurrency configuration to cancel previous runs on new commits
8+
concurrency:
9+
group: validate-${{ github.event.pull_request.number }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
validate:
14+
name: ${{ matrix.check }}
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
check:
19+
- TypeScript Check
20+
- Lint Check
21+
- Format Check
22+
include:
23+
- check: TypeScript Check
24+
command: typecheck
25+
- check: Lint Check
26+
command: lint
27+
- check: Format Check
28+
command: format:check
29+
steps:
30+
- uses: actions/checkout@v4
31+
- uses: actions/setup-node@v4
32+
with:
33+
node-version: '22'
34+
cache: 'npm'
35+
cache-dependency-path: 'package-lock.json'
36+
- name: Install dependencies
37+
run: npm ci
38+
- name: Run ${{ matrix.check }}
39+
run: npm run ${{ matrix.command }}

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
"clear": "npm run prebuild -- clean && docusaurus clear",
1515
"serve": "docusaurus serve",
1616
"typecheck": "tsc",
17-
"format": "prettier --write ."
17+
"format": "prettier .",
18+
"format:check": "npm run format -- --check",
19+
"format:write": "npm run format -- --write",
20+
"lint": "echo 0;"
1821
},
1922
"dependencies": {
2023
"@docusaurus/core": "^3.8.1",
@@ -50,7 +53,7 @@
5053
]
5154
},
5255
"engines": {
53-
"node": ">=22.0"
56+
"node": ">=22"
5457
},
5558
"prettier": "@harperdb/code-guidelines/prettier"
5659
}

0 commit comments

Comments
 (0)