Skip to content

Commit e33689a

Browse files
authored
Merge pull request #46 from aripalo/integ-tests
feat: integration tests
2 parents 3cd080e + aad6bf7 commit e33689a

26 files changed

Lines changed: 32676 additions & 5 deletions

.gitattributes

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/codeql/codeql-config.yml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/codeql.yml

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/gitleaks.yml

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.gitignore

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.gitleaks.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[extend]
2+
useDefault = true
3+
4+
[[rules]]
5+
id = "aws-account-id"
6+
description = "AWS account ID"
7+
regex = '''\b\d{12}\b'''
8+
tags = ["aws", "account-id", "security"]
9+
10+
[[rules.allowlists]]
11+
description = "Ignore the gitleaks configuration file itself"
12+
paths = ['''^\.gitleaks\.toml$''']
13+
14+
[[rules.allowlists]]
15+
description = "Ignore example AWS account IDs"
16+
regexes = ['''^(123456789012|111111111111|000000000000)$''']
17+
18+
[[rules]]
19+
id = "generic-api-key"
20+
21+
[[rules.allowlists]]
22+
description = "Ignore secret-like zip file names"
23+
regexTarget = "match"
24+
regexes = ['''(?i)[a-f0-9]{32,}\.zip''']

.projen/deps.json

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projen/files.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projen/tasks.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projenrc.ts

Lines changed: 105 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { AlmaCdkConstructLibrary } from "@alma-cdk/construct-library";
2-
import { cdk } from "projen";
2+
import { cdk, github, YamlFile } from "projen";
33

44
const project = new AlmaCdkConstructLibrary({
55
name: "aws-cdk-github-oidc",
@@ -25,8 +25,112 @@ const project = new AlmaCdkConstructLibrary({
2525
releaseEnvironment: "production",
2626
pnpmSettings: {
2727
trustPolicyExclude: ["jsii@5.9.35"],
28+
onlyBuiltDependencies: ["lefthook"],
2829
},
2930
codeCov: true,
3031
});
3132

33+
project.addDevDeps(
34+
"@aws-cdk/integ-runner",
35+
"@aws-cdk/integ-tests-alpha",
36+
"@aws-cdk/cloud-assembly-schema",
37+
"lefthook",
38+
);
39+
40+
/**
41+
* Run with AWS_PROFILE=<YOUR_PROFILE> pnpm run integ:test
42+
*/
43+
project.setScript("integ:test", "node ./run-integ-tests.mjs");
44+
45+
project.setScript(
46+
"prepare",
47+
"node -e \"const fs = require('node:fs'); const { spawnSync } = require('node:child_process'); if (process.env.CI || !fs.existsSync('.git')) process.exit(0); const result = spawnSync(process.execPath, ['node_modules/lefthook/bin/index.js', 'install'], { stdio: 'inherit' }); process.exit(result.status ?? 1)\"",
48+
);
49+
50+
project.setScript(
51+
"gitleaks:history",
52+
'docker run --rm -v "$PWD:/repo" -w /repo ghcr.io/gitleaks/gitleaks:latest git --verbose --config /repo/.gitleaks.toml',
53+
);
54+
project.setScript(
55+
"gitleaks:dir",
56+
'docker run --rm -v "$PWD:/repo" -w /repo ghcr.io/gitleaks/gitleaks:latest dir --verbose --config /repo/.gitleaks.toml',
57+
);
58+
59+
const gitleaksWorkflow = project.github!.addWorkflow("gitleaks");
60+
gitleaksWorkflow.on({
61+
push: {},
62+
});
63+
gitleaksWorkflow.addJobs({
64+
gitleaks: {
65+
runsOn: ["ubuntu-latest"],
66+
permissions: {
67+
contents: github.workflows.JobPermission.READ,
68+
},
69+
steps: [
70+
{
71+
name: "Checkout",
72+
uses: "actions/checkout@v5",
73+
with: {
74+
fetchDepth: 0,
75+
},
76+
},
77+
{
78+
name: "Run gitleaks",
79+
uses: "gitleaks/gitleaks-action@v2",
80+
env: {
81+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}",
82+
GITLEAKS_CONFIG: ".gitleaks.toml",
83+
},
84+
},
85+
],
86+
},
87+
});
88+
89+
const codeqlWorkflow = project.github!.addWorkflow("codeql");
90+
codeqlWorkflow.on({
91+
push: {
92+
branches: ["main"],
93+
},
94+
pullRequest: {},
95+
schedule: [{ cron: "36 4 * * 0" }],
96+
workflowDispatch: {},
97+
});
98+
codeqlWorkflow.addJobs({
99+
analyze: {
100+
name: "analyze",
101+
runsOn: ["ubuntu-latest"],
102+
permissions: {
103+
actions: github.workflows.JobPermission.READ,
104+
contents: github.workflows.JobPermission.READ,
105+
securityEvents: github.workflows.JobPermission.WRITE,
106+
},
107+
steps: [
108+
{
109+
name: "Checkout",
110+
uses: "actions/checkout@v5",
111+
},
112+
{
113+
name: "Initialize CodeQL",
114+
uses: "github/codeql-action/init@v4",
115+
with: {
116+
languages: "javascript-typescript",
117+
"config-file": "./.github/codeql/codeql-config.yml",
118+
},
119+
},
120+
{
121+
name: "Perform CodeQL Analysis",
122+
uses: "github/codeql-action/analyze@v4",
123+
},
124+
],
125+
},
126+
});
127+
128+
new YamlFile(project, ".github/codeql/codeql-config.yml", {
129+
obj: {
130+
"paths-ignore": ["test/integ.github-oidc.ts.snapshot"],
131+
},
132+
});
133+
134+
project.annotateGenerated("test/integ.github-oidc.ts.snapshot/**");
135+
32136
project.synth();

0 commit comments

Comments
 (0)