Skip to content

Commit 735791d

Browse files
authored
Merge pull request #158 from capitalone/ci-automation-and-tests
Add CI/CD automation, auto-merge for bot PRs, and meaningful unit tests
2 parents 45eb8ed + 13e6e9c commit 735791d

19 files changed

Lines changed: 11965 additions & 15367 deletions

.github/workflows/auto-merge.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Auto-merge bot PRs
2+
3+
# pull_request_target runs in the base branch context so GITHUB_TOKEN has write access.
4+
# We never checkout PR code here, only invoke gh pr merge — this is safe.
5+
on:
6+
pull_request_target:
7+
types: [opened, reopened, ready_for_review, synchronize]
8+
9+
permissions:
10+
pull-requests: write
11+
contents: write
12+
13+
jobs:
14+
auto-merge:
15+
runs-on: ubuntu-latest
16+
# Use pull_request.user.login (the PR author), not github.actor (the workflow
17+
# triggering actor), which can differ on synchronize events and is considered
18+
# a forgeable context value by SonarCloud S6549.
19+
if: |
20+
github.event.pull_request.user.login == 'dependabot[bot]' ||
21+
github.event.pull_request.user.login == 'snyk-bot'
22+
23+
steps:
24+
- name: Enable auto-merge
25+
env:
26+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
# Bind to env var before shell interpolation to prevent template injection.
28+
PR_NUMBER: ${{ github.event.pull_request.number }}
29+
PR_REPO: ${{ github.repository }}
30+
# --auto queues the merge; GitHub will merge only after all required checks pass.
31+
# Requires "Allow auto-merge" to be enabled in repo Settings → General.
32+
# If the feature is off or permissions are insufficient, we warn and exit cleanly
33+
# so the PR is not blocked — it will need manual review instead.
34+
run: |
35+
gh pr merge --auto --squash "$PR_NUMBER" \
36+
--repo "$PR_REPO" \
37+
|| echo "::warning::Auto-merge could not be enabled. Either enable 'Allow auto-merge' in repo settings or merge this PR manually once CI passes."

.github/workflows/ci.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
build-and-test:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- uses: actions/setup-node@v4
20+
with:
21+
node-version: '20'
22+
cache: 'npm'
23+
24+
- name: Install dependencies
25+
run: npm ci
26+
27+
- name: Lint
28+
run: npm run lint
29+
# tslint is deprecated — failures warn but do not block
30+
continue-on-error: true
31+
32+
- name: Test
33+
run: npm run test:ci
34+
35+
- name: Build
36+
run: npx ng build --configuration=production
37+
env:
38+
NODE_OPTIONS: --max-old-space-size=4096
39+
40+
- name: Security audit
41+
run: npm audit --audit-level=high
42+
# Snyk manages fixes via PRs; audit here surfaces new issues without blocking
43+
continue-on-error: true

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
legacy-peer-deps=true

angular.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
"options": {
109109
"main": "src/test.ts",
110110
"polyfills": "src/polyfills.ts",
111-
"tsConfig": "tsconfig.spec.json",
111+
"tsConfig": "src/tsconfig.spec.json",
112112
"karmaConfig": "karma.conf.js",
113113
"assets": [
114114
"src/favicon.ico",

karma.conf.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
SPDX-Copyright: Copyright (c) Capital One Services,LLC
2+
SPDX-Copyright: Copyright (c) Capital One Services,LLC
33
SPDX-License-Identifier: Apache-2.0
44
55
Copyright 2018 Capital One Services, LLC
@@ -20,30 +20,30 @@ See the License for the specific language governing permissions and limitations
2020
module.exports = function (config) {
2121
config.set({
2222
basePath: '',
23-
frameworks: ['jasmine', '@angular/cli'],
23+
frameworks: ['jasmine', '@angular-devkit/build-angular'],
2424
plugins: [
2525
require('karma-jasmine'),
2626
require('karma-chrome-launcher'),
2727
require('karma-jasmine-html-reporter'),
28-
require('karma-coverage-istanbul-reporter'),
29-
require('@angular/cli/plugins/karma')
28+
require('karma-coverage'),
29+
require('@angular-devkit/build-angular/plugins/karma')
3030
],
3131
client: {
3232
clearContext: false // leave Jasmine Spec Runner output visible in browser
3333
},
34-
coverageIstanbulReporter: {
35-
reports: ['html', 'lcovonly'],
36-
fixWebpackSourcePaths: true
37-
},
38-
angularCli: {
39-
environment: 'dev'
40-
},
4134
reporters: ['progress', 'kjhtml'],
4235
port: 9876,
4336
colors: true,
4437
logLevel: config.LOG_INFO,
4538
autoWatch: true,
4639
browsers: ['Chrome'],
40+
// ChromeHeadlessNoSandbox is used in CI environments where --no-sandbox is required
41+
customLaunchers: {
42+
ChromeHeadlessNoSandbox: {
43+
base: 'ChromeHeadless',
44+
flags: ['--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage']
45+
}
46+
},
4747
singleRun: false
4848
});
4949
};

0 commit comments

Comments
 (0)