-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.projenrc.js
161 lines (153 loc) · 4.43 KB
/
.projenrc.js
1
2
3
4
5
6
7
8
9
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
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
const { AwsCdkTypeScriptApp, FileBase, TextFile, YamlFile } = require('projen');
const project = new AwsCdkTypeScriptApp({
name: '@ahammond/hugo-cdk',
authorName: 'Andrew Hammond',
cdkVersion: '2.0.0-rc.24',
defaultReleaseBranch: 'main',
npmRegistryUrl: 'https://npm.pkg.github.com',
repositoryUrl: 'https://github.com/ahammond/hugo-cdk.git',
cdkDependencies: ['aws-cdk-lib'], // Kinda obsolete in a cdk v2 world.
cdkVersionPinning: true,
deps: ['aws-lambda', 'source-map-support'],
devDeps: [
'@types/aws-lambda',
'@aws-cdk/assert',
'esbuild',
'eslint-config-prettier',
'eslint-plugin-prettier',
'codecov',
'jsii-release',
'prettier',
],
jestOptions: {
jestConfig: {
collectCoverageFrom: ['src/**/*.ts'],
},
},
});
// include prettier
project.eslint.config.extends = [...project.eslint.config.extends, 'plugin:prettier/recommended'];
const prettierrc = new TextFile(project, '.prettierrc.js', {
lines: [
`// ${FileBase.PROJEN_MARKER}`,
'module.exports = {',
' semi: true,',
" trailingComma: 'all',",
' singleQuote: true,',
' printWidth: 120,',
' tabWidth: 2,',
'};',
],
});
// Enforce conventional commits https://www.conventionalcommits.org/
// https://github.com/marketplace/actions/semantic-pull-request
// If you add a new directory under src, you should also add it here in the scopes.
// Note deps and meta are for dependencies and metadata related stuff respectively
// For the 'uses', please look up the latest version from
// https://github.com/amannn/action-semantic-pull-request/releases
const prLinter = new YamlFile(project, '.github/workflows/pr-linter.yml', {
obj: {
name: 'Lint PR',
on: {
pull_request_target: {
types: ['opened', 'edited', 'synchronize'],
},
},
jobs: {
main: {
'runs-on': 'ubuntu-latest',
// eslint-disable-next-line quote-props
steps: [
{
env: {
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}',
},
with: {
scopes: 'deps doc meta core s3 static-site waf',
validateSingleCommit: true,
},
},
],
},
},
},
});
// Codecov config support
new YamlFile(project, 'codecov.yml', {
obj: {
codecov: {
require_ci_to_pass: 'yes',
coverage: {
precision: 2,
round: 'down',
range: '70...100',
status: {
project: {
// Controls for the entire project
default: {
target: 'auto',
threshold: '10%', // Allow total coverage to drop by this much while still succeeding.
paths: ['src'],
if_ci_failed: 'error',
only_pulls: true,
},
// Controls for just the code changed by the PR
patch: {
default: {
base: 'auto',
target: 'auto',
threshold: '10%', // Code in src that is changed by PR must have at least this much coverage.
paths: ['src'],
if_ci_failed: 'error',
only_pulls: true,
},
},
},
},
},
parsers: {
gcov: {
branch_detection: {
conditional: 'yes',
loop: 'yes',
method: 'no',
macro: 'no',
},
},
},
comment: {
layout: 'reach,diff,flags,files,footer',
behavior: 'default',
require_changes: 'no',
},
},
},
});
// Codecov build support
// We don't have working releases yet.
// To run codecov manually, grab the CODECOV_TOKEN from
// https://app.codecov.io/gh/ahammond/hugo-cdk/settings
// and then `npx codecov`
const buildSteps = project.buildWorkflow.jobs.build.steps;
let projenBuildIdx = buildSteps.findIndex((obj, _idx) => {
return obj.name == 'build';
});
if (projenBuildIdx < 0) {
throw new Error('Did not find build step');
}
buildSteps.splice(projenBuildIdx + 1, 0, {
name: 'Codecov',
uses: 'codecov/codecov-action@v2',
with: {
token: '${{ secrets.CODECOV_TOKEN }}',
// directory: 'coverage',
// files: ./coverage1.xml,./coverage2.xml # optional
flags: 'unittests',
// name: codecov-umbrella
fail_ci_if_error: true,
verbose: true,
},
});
project.synth();