@happychef/algorithm 1.2.10 → 1.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci-cd.yml +234 -103
- package/BRANCH_PROTECTION_SETUP.md +167 -0
- package/README.md +144 -144
- package/__tests__/filters.test.js +276 -276
- package/__tests__/isDateAvailable.test.js +175 -175
- package/__tests__/isTimeAvailable.test.js +168 -168
- package/__tests__/restaurantData.test.js +422 -422
- package/__tests__/tableHelpers.test.js +247 -247
- package/assignTables.js +149 -123
- package/changes/2025/December/PR4___.md +16 -0
- package/changes/2025/December/PR5___.md +16 -0
- package/changes/2025/December/PR6__del_.md +18 -0
- package/changes/2025/December/PR7_add__change.md +22 -0
- package/jest.config.js +23 -23
- package/package.json +1 -1
- package/tableHelpers.js +2 -2
- package/test-detailed-filter.js +100 -100
- package/test-lunch-debug.js +110 -110
- package/test-max-arrivals-filter.js +79 -79
- package/test-timezone-debug.js +47 -47
|
@@ -1,103 +1,234 @@
|
|
|
1
|
-
name: CI/CD Pipeline
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- main
|
|
7
|
-
pull_request:
|
|
8
|
-
branches:
|
|
9
|
-
- main
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
- name:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
1
|
+
name: CI/CD Pipeline
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
pull_request:
|
|
8
|
+
branches:
|
|
9
|
+
- main
|
|
10
|
+
types: [opened, synchronize, reopened]
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
test:
|
|
14
|
+
name: Run Tests
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
|
|
17
|
+
strategy:
|
|
18
|
+
matrix:
|
|
19
|
+
node-version: [18.x, 20.x]
|
|
20
|
+
|
|
21
|
+
steps:
|
|
22
|
+
- name: Checkout code
|
|
23
|
+
uses: actions/checkout@v4
|
|
24
|
+
|
|
25
|
+
- name: Setup Node.js ${{ matrix.node-version }}
|
|
26
|
+
uses: actions/setup-node@v4
|
|
27
|
+
with:
|
|
28
|
+
node-version: ${{ matrix.node-version }}
|
|
29
|
+
cache: 'npm'
|
|
30
|
+
|
|
31
|
+
- name: Install dependencies
|
|
32
|
+
run: npm ci
|
|
33
|
+
|
|
34
|
+
- name: Run tests
|
|
35
|
+
id: test-run
|
|
36
|
+
run: npm test -- --verbose 2>&1 | tee test-output.txt
|
|
37
|
+
continue-on-error: true
|
|
38
|
+
|
|
39
|
+
- name: Run tests with coverage
|
|
40
|
+
if: always()
|
|
41
|
+
run: npm run test:coverage
|
|
42
|
+
continue-on-error: true
|
|
43
|
+
|
|
44
|
+
- name: Generate test summary
|
|
45
|
+
if: always()
|
|
46
|
+
run: |
|
|
47
|
+
echo "## Test Results for Node.js ${{ matrix.node-version }}" >> $GITHUB_STEP_SUMMARY
|
|
48
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
49
|
+
|
|
50
|
+
# Extract test results
|
|
51
|
+
TEST_OUTPUT=$(cat test-output.txt)
|
|
52
|
+
|
|
53
|
+
if echo "$TEST_OUTPUT" | grep -q "Tests:.*failed"; then
|
|
54
|
+
echo "❌ **Tests Failed**" >> $GITHUB_STEP_SUMMARY
|
|
55
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
56
|
+
|
|
57
|
+
# Extract summary line
|
|
58
|
+
SUMMARY=$(echo "$TEST_OUTPUT" | grep "Test Suites:" | tail -1)
|
|
59
|
+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
|
|
60
|
+
echo "$SUMMARY" >> $GITHUB_STEP_SUMMARY
|
|
61
|
+
echo "$TEST_OUTPUT" | grep "Tests:" | tail -1 >> $GITHUB_STEP_SUMMARY
|
|
62
|
+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
|
|
63
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
64
|
+
|
|
65
|
+
# Show failed tests
|
|
66
|
+
echo "### Failed Tests:" >> $GITHUB_STEP_SUMMARY
|
|
67
|
+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
|
|
68
|
+
echo "$TEST_OUTPUT" | grep -A 10 "FAIL" | head -30 >> $GITHUB_STEP_SUMMARY
|
|
69
|
+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
|
|
70
|
+
else
|
|
71
|
+
echo "✅ **All Tests Passed!**" >> $GITHUB_STEP_SUMMARY
|
|
72
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
73
|
+
|
|
74
|
+
# Extract summary line
|
|
75
|
+
SUMMARY=$(echo "$TEST_OUTPUT" | grep "Test Suites:" | tail -1)
|
|
76
|
+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
|
|
77
|
+
echo "$SUMMARY" >> $GITHUB_STEP_SUMMARY
|
|
78
|
+
echo "$TEST_OUTPUT" | grep "Tests:" | tail -1 >> $GITHUB_STEP_SUMMARY
|
|
79
|
+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
|
|
80
|
+
fi
|
|
81
|
+
|
|
82
|
+
- name: Comment PR with test results
|
|
83
|
+
if: always() && github.event_name == 'pull_request' && matrix.node-version == '20.x'
|
|
84
|
+
uses: actions/github-script@v7
|
|
85
|
+
with:
|
|
86
|
+
script: |
|
|
87
|
+
const fs = require('fs');
|
|
88
|
+
const testOutput = fs.readFileSync('test-output.txt', 'utf8');
|
|
89
|
+
|
|
90
|
+
// Check if tests failed
|
|
91
|
+
const hasFailed = testOutput.includes('FAIL');
|
|
92
|
+
const summaryLine = testOutput.match(/Test Suites:.*$/m)?.[0] || '';
|
|
93
|
+
const testsLine = testOutput.match(/Tests:.*$/m)?.[0] || '';
|
|
94
|
+
|
|
95
|
+
let comment = '';
|
|
96
|
+
|
|
97
|
+
if (hasFailed) {
|
|
98
|
+
comment = `## ❌ Tests Failed on Node.js ${{ matrix.node-version }}
|
|
99
|
+
|
|
100
|
+
**Summary:**
|
|
101
|
+
\`\`\`
|
|
102
|
+
${summaryLine}
|
|
103
|
+
${testsLine}
|
|
104
|
+
\`\`\`
|
|
105
|
+
|
|
106
|
+
### 🔴 Failed Tests Details:
|
|
107
|
+
|
|
108
|
+
`;
|
|
109
|
+
|
|
110
|
+
// Extract failed test details
|
|
111
|
+
const failedTests = testOutput.match(/FAIL.*\n(.*\n){0,15}/g) || [];
|
|
112
|
+
failedTests.forEach(fail => {
|
|
113
|
+
const lines = fail.split('\n').slice(0, 10);
|
|
114
|
+
comment += '\`\`\`\n' + lines.join('\n') + '\n\`\`\`\n\n';
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
comment += `
|
|
118
|
+
### 💡 What to do:
|
|
119
|
+
1. Review the failed test(s) above
|
|
120
|
+
2. Fix the issues in your code
|
|
121
|
+
3. Push the changes to this PR
|
|
122
|
+
4. Tests will run automatically again
|
|
123
|
+
|
|
124
|
+
**This PR cannot be merged until all tests pass.**
|
|
125
|
+
`;
|
|
126
|
+
} else {
|
|
127
|
+
comment = `## ✅ All Tests Passed on Node.js ${{ matrix.node-version }}
|
|
128
|
+
|
|
129
|
+
**Summary:**
|
|
130
|
+
\`\`\`
|
|
131
|
+
${summaryLine}
|
|
132
|
+
${testsLine}
|
|
133
|
+
\`\`\`
|
|
134
|
+
|
|
135
|
+
### 🎉 Great work!
|
|
136
|
+
All tests are passing. This PR is ready to be reviewed and merged.
|
|
137
|
+
|
|
138
|
+
**Next steps:**
|
|
139
|
+
- Wait for code review (if required)
|
|
140
|
+
- Merge when ready
|
|
141
|
+
`;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Post comment
|
|
145
|
+
github.rest.issues.createComment({
|
|
146
|
+
issue_number: context.issue.number,
|
|
147
|
+
owner: context.repo.owner,
|
|
148
|
+
repo: context.repo.repo,
|
|
149
|
+
body: comment
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
- name: Upload coverage reports
|
|
153
|
+
uses: codecov/codecov-action@v4
|
|
154
|
+
if: matrix.node-version == '20.x'
|
|
155
|
+
with:
|
|
156
|
+
files: ./coverage/lcov.info
|
|
157
|
+
flags: unittests
|
|
158
|
+
name: codecov-umbrella
|
|
159
|
+
fail_ci_if_error: false
|
|
160
|
+
env:
|
|
161
|
+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
|
162
|
+
|
|
163
|
+
publish:
|
|
164
|
+
name: Publish to NPM
|
|
165
|
+
needs: test
|
|
166
|
+
runs-on: ubuntu-latest
|
|
167
|
+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
|
|
168
|
+
|
|
169
|
+
steps:
|
|
170
|
+
- name: Checkout code
|
|
171
|
+
uses: actions/checkout@v4
|
|
172
|
+
|
|
173
|
+
- name: Setup Node.js
|
|
174
|
+
uses: actions/setup-node@v4
|
|
175
|
+
with:
|
|
176
|
+
node-version: '20.x'
|
|
177
|
+
registry-url: 'https://registry.npmjs.org'
|
|
178
|
+
cache: 'npm'
|
|
179
|
+
|
|
180
|
+
- name: Install dependencies
|
|
181
|
+
run: npm ci
|
|
182
|
+
|
|
183
|
+
- name: Run tests
|
|
184
|
+
run: npm test
|
|
185
|
+
|
|
186
|
+
- name: Check if version changed
|
|
187
|
+
id: version-check
|
|
188
|
+
run: |
|
|
189
|
+
PACKAGE_VERSION=$(node -p "require('./package.json').version")
|
|
190
|
+
NPM_VERSION=$(npm view @happychef/algorithm version 2>/dev/null || echo "0.0.0")
|
|
191
|
+
echo "Package version: $PACKAGE_VERSION"
|
|
192
|
+
echo "NPM version: $NPM_VERSION"
|
|
193
|
+
if [ "$PACKAGE_VERSION" != "$NPM_VERSION" ]; then
|
|
194
|
+
echo "version_changed=true" >> $GITHUB_OUTPUT
|
|
195
|
+
echo "Version changed from $NPM_VERSION to $PACKAGE_VERSION"
|
|
196
|
+
else
|
|
197
|
+
echo "version_changed=false" >> $GITHUB_OUTPUT
|
|
198
|
+
echo "Version unchanged: $PACKAGE_VERSION"
|
|
199
|
+
fi
|
|
200
|
+
|
|
201
|
+
- name: Publish to NPM
|
|
202
|
+
if: steps.version-check.outputs.version_changed == 'true'
|
|
203
|
+
run: |
|
|
204
|
+
npm publish --access public
|
|
205
|
+
echo "## 📦 NPM Package Published" >> $GITHUB_STEP_SUMMARY
|
|
206
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
207
|
+
echo "✅ Successfully published @happychef/algorithm@$(node -p "require('./package.json').version")" >> $GITHUB_STEP_SUMMARY
|
|
208
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
209
|
+
echo "🔗 [View on NPM](https://www.npmjs.com/package/@happychef/algorithm)" >> $GITHUB_STEP_SUMMARY
|
|
210
|
+
env:
|
|
211
|
+
NODE_AUTH_TOKEN: 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
|
|
212
|
+
|
|
213
|
+
- name: Skip publishing (version unchanged)
|
|
214
|
+
if: steps.version-check.outputs.version_changed == 'false'
|
|
215
|
+
run: |
|
|
216
|
+
echo "## ⏭️ Publishing Skipped" >> $GITHUB_STEP_SUMMARY
|
|
217
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
218
|
+
echo "Version $(node -p "require('./package.json').version") is already published" >> $GITHUB_STEP_SUMMARY
|
|
219
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
220
|
+
echo "💡 Bump the version in package.json to trigger publishing" >> $GITHUB_STEP_SUMMARY
|
|
221
|
+
|
|
222
|
+
- name: Create Git Tag
|
|
223
|
+
if: steps.version-check.outputs.version_changed == 'true'
|
|
224
|
+
run: |
|
|
225
|
+
PACKAGE_VERSION=$(node -p "require('./package.json').version")
|
|
226
|
+
git config user.name "github-actions[bot]"
|
|
227
|
+
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
228
|
+
git tag -a "v$PACKAGE_VERSION" -m "Release v$PACKAGE_VERSION"
|
|
229
|
+
git push origin "v$PACKAGE_VERSION"
|
|
230
|
+
echo "## 🏷️ Git Tag Created" >> $GITHUB_STEP_SUMMARY
|
|
231
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
232
|
+
echo "Created and pushed tag: v$PACKAGE_VERSION" >> $GITHUB_STEP_SUMMARY
|
|
233
|
+
env:
|
|
234
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# Branch Protection Setup Guide
|
|
2
|
+
|
|
3
|
+
This guide explains how to configure GitHub branch protection rules to require all tests to pass before merging pull requests.
|
|
4
|
+
|
|
5
|
+
## Why Branch Protection?
|
|
6
|
+
|
|
7
|
+
Branch protection ensures:
|
|
8
|
+
- ✅ All tests must pass before merging PRs
|
|
9
|
+
- ✅ No direct pushes to main without review (optional)
|
|
10
|
+
- ✅ Code quality is maintained
|
|
11
|
+
- ✅ Broken code never reaches production
|
|
12
|
+
|
|
13
|
+
## Setup Instructions
|
|
14
|
+
|
|
15
|
+
### Step 1: Go to Branch Protection Settings
|
|
16
|
+
|
|
17
|
+
1. Navigate to your GitHub repository: `https://github.com/thibaultvandesompele2/15-happy-algorithm`
|
|
18
|
+
2. Click on **Settings** (tab at the top)
|
|
19
|
+
3. In the left sidebar, click **Branches** (under "Code and automation")
|
|
20
|
+
4. Click **Add branch protection rule** (or **Add rule**)
|
|
21
|
+
|
|
22
|
+
### Step 2: Configure the Rule
|
|
23
|
+
|
|
24
|
+
#### Basic Settings:
|
|
25
|
+
1. **Branch name pattern**: Enter `main`
|
|
26
|
+
|
|
27
|
+
#### Required Settings:
|
|
28
|
+
|
|
29
|
+
✅ **Check these boxes:**
|
|
30
|
+
|
|
31
|
+
1. ☑️ **Require a pull request before merging**
|
|
32
|
+
- This prevents direct pushes to main
|
|
33
|
+
- Optional: Set "Required number of approvals" to 1 or more
|
|
34
|
+
|
|
35
|
+
2. ☑️ **Require status checks to pass before merging**
|
|
36
|
+
- This is the CRITICAL setting for test enforcement
|
|
37
|
+
- Check: **Require branches to be up to date before merging**
|
|
38
|
+
|
|
39
|
+
3. In the **Status checks** search box, you'll see:
|
|
40
|
+
- `Run Tests` (your test job)
|
|
41
|
+
|
|
42
|
+
☑️ **Select both Node.js test jobs:**
|
|
43
|
+
- `Run Tests (18.x)`
|
|
44
|
+
- `Run Tests (20.x)`
|
|
45
|
+
|
|
46
|
+
*Note: These will appear after the first workflow run completes*
|
|
47
|
+
|
|
48
|
+
4. ☑️ **Do not allow bypassing the above settings** (recommended)
|
|
49
|
+
- Even admins must follow these rules
|
|
50
|
+
|
|
51
|
+
#### Optional but Recommended:
|
|
52
|
+
|
|
53
|
+
5. ☑️ **Require conversation resolution before merging**
|
|
54
|
+
- All PR comments must be resolved
|
|
55
|
+
|
|
56
|
+
6. ☑️ **Require linear history**
|
|
57
|
+
- Prevents messy merge commits
|
|
58
|
+
|
|
59
|
+
### Step 3: Save
|
|
60
|
+
|
|
61
|
+
1. Scroll to the bottom
|
|
62
|
+
2. Click **Create** or **Save changes**
|
|
63
|
+
|
|
64
|
+
## What Happens After Setup
|
|
65
|
+
|
|
66
|
+
### On Pull Requests:
|
|
67
|
+
- GitHub automatically runs the CI/CD tests
|
|
68
|
+
- You'll see status checks at the bottom of the PR
|
|
69
|
+
- **Merge button will be DISABLED** until all tests pass
|
|
70
|
+
- If tests fail, you must fix them before merging
|
|
71
|
+
|
|
72
|
+
### Visual Indicators:
|
|
73
|
+
|
|
74
|
+
**Tests Running:**
|
|
75
|
+
```
|
|
76
|
+
⏳ Run Tests (18.x) — In progress
|
|
77
|
+
⏳ Run Tests (20.x) — In progress
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**Tests Passed:**
|
|
81
|
+
```
|
|
82
|
+
✅ Run Tests (18.x) — Passed
|
|
83
|
+
✅ Run Tests (20.x) — Passed
|
|
84
|
+
🟢 Merge pull request button is ENABLED
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Tests Failed:**
|
|
88
|
+
```
|
|
89
|
+
❌ Run Tests (18.x) — Failed
|
|
90
|
+
❌ Run Tests (20.x) — Failed
|
|
91
|
+
🔴 Merge pull request button is DISABLED
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Testing the Protection
|
|
95
|
+
|
|
96
|
+
### Create a Test PR:
|
|
97
|
+
|
|
98
|
+
1. Create a new branch:
|
|
99
|
+
```bash
|
|
100
|
+
git checkout -b test-branch-protection
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
2. Make a small change:
|
|
104
|
+
```bash
|
|
105
|
+
echo "# Test" >> test-file.txt
|
|
106
|
+
git add test-file.txt
|
|
107
|
+
git commit -m "Test branch protection"
|
|
108
|
+
git push origin test-branch-protection
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
3. Go to GitHub and create a pull request
|
|
112
|
+
|
|
113
|
+
4. Observe:
|
|
114
|
+
- Tests run automatically
|
|
115
|
+
- Merge button is disabled until tests complete
|
|
116
|
+
- After tests pass, merge button becomes available
|
|
117
|
+
|
|
118
|
+
## Workflow Behavior
|
|
119
|
+
|
|
120
|
+
### For Pull Requests:
|
|
121
|
+
- ✅ Runs all 70 tests on Node.js 18.x and 20.x
|
|
122
|
+
- ✅ Must pass before merge is allowed
|
|
123
|
+
- ✅ Shows test summary in PR
|
|
124
|
+
- ❌ Does NOT publish to npm (only tests)
|
|
125
|
+
|
|
126
|
+
### For Pushes to Main:
|
|
127
|
+
- ✅ Runs all tests
|
|
128
|
+
- ✅ If version changed AND tests pass → publishes to npm
|
|
129
|
+
- ✅ Creates git tag
|
|
130
|
+
- ✅ Shows summary of all actions
|
|
131
|
+
|
|
132
|
+
## Troubleshooting
|
|
133
|
+
|
|
134
|
+
### "Status checks not found"
|
|
135
|
+
- The status checks only appear after the first workflow run completes
|
|
136
|
+
- Push this branch protection setup, wait for workflow to run, then configure protection
|
|
137
|
+
|
|
138
|
+
### "Can't find Run Tests in status checks"
|
|
139
|
+
- Make sure the workflow has run at least once
|
|
140
|
+
- Check the Actions tab to see workflow runs
|
|
141
|
+
- The job name must match exactly: `Run Tests`
|
|
142
|
+
|
|
143
|
+
### "Tests are running but merge button isn't disabled"
|
|
144
|
+
- You need to enable "Require status checks to pass before merging"
|
|
145
|
+
- Make sure you selected the specific test jobs (18.x and 20.x)
|
|
146
|
+
|
|
147
|
+
## Quick Setup Checklist
|
|
148
|
+
|
|
149
|
+
- [ ] Go to Settings → Branches
|
|
150
|
+
- [ ] Add branch protection rule for `main`
|
|
151
|
+
- [ ] Enable "Require status checks to pass before merging"
|
|
152
|
+
- [ ] Select `Run Tests (18.x)` and `Run Tests (20.x)`
|
|
153
|
+
- [ ] Enable "Do not allow bypassing"
|
|
154
|
+
- [ ] Save the rule
|
|
155
|
+
- [ ] Test with a PR
|
|
156
|
+
|
|
157
|
+
## Additional Security (Optional)
|
|
158
|
+
|
|
159
|
+
For additional security, you can also enable:
|
|
160
|
+
|
|
161
|
+
- **Require deployments to succeed** - Wait for tests before deploying
|
|
162
|
+
- **Lock branch** - Temporarily prevent all changes
|
|
163
|
+
- **Restrict who can push** - Only specific users/teams can push
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
**Result:** After setup, no code can be merged to `main` without passing all 70 tests! 🎉
|