-
Notifications
You must be signed in to change notification settings - Fork 10
264 lines (254 loc) · 7.85 KB
/
pull-request-check.yaml
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
name: "pull request check"
on:
pull_request:
types: [opened, reopened, edited, synchronize]
permissions:
contents: write
id-token: write # required to use OIDC authentication
jobs:
semantic-validate:
name: semantic-validate
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: amannn/action-semantic-pull-request@v5.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with :
types: |
feat
fix
docs
refactor
test
build
chore
revert
scopes: |
be
fe
be+fe
cdk
others
subjectPattern: ^[\s\w-\.]{5,100}$
subjectPatternError: |
The subject "{subject}" found in the pull request title "{title}"
didn't match the configured pattern. Please ensure that the subject
1) contains only alphanumeric characters,'_','-',' '.
2) length between 5 and 100.
requireScope: true
pyflakes:
needs: semantic-validate
runs-on: ubuntu-latest
permissions:
checks: write
contents: read
pull-requests: read
steps:
- name: Checkout
uses: actions/checkout@v3
- name: pyflakes
uses: reviewdog/action-pyflakes@master
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-review
level: error
git-secrets:
needs: semantic-validate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Checkout awslabs/git-secrets
uses: actions/checkout@v3
with:
submodules: recursive
repository: awslabs/git-secrets
ref: master
path: git-secrets
- name: Install git-secrets
run: cd git-secrets && sudo make install && cd ..
- name: Run git-secrets
run: |
git-secrets --register-aws
git secrets --add --allowed 'source/constructs/lib/common/constants.ts'
git-secrets --scan
opensource-license-review:
needs: semantic-validate
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v3
- name: Dependency Review
uses: actions/dependency-review-action@v3
with:
fail-on-severity: moderate
- name: archive production artifacts
uses: actions/upload-artifact@v3
with:
name: build-artifacts
path: |
.git/**/*
deployment/**/*
docs/**/*
${{ github.workspace }}/source/portal
${{ github.workspace }}/source/constructs
deploy_vtag.yml
CHANGELOG.md
.cfnnagignore
.cfnnag_global_suppress_list
.cfnnag_*
semgrep-scan:
needs: semantic-validate
runs-on: ubuntu-latest
container:
# A Docker image with Semgrep installed. Do not change this.
image: returntocorp/semgrep
# Skip any PR created by dependabot to avoid permission issues:
if: (github.actor != 'dependabot[bot]')
permissions:
actions: read
contents: read
security-events: write
steps:
# Fetch project source with GitHub Actions Checkout.
- uses: actions/checkout@v3
# Run the "semgrep ci" command on the command line of the docker image.
- run: semgrep ci --config auto --sarif --output=semgrep.sarif
- name: Upload SARIF file for GitHub Advanced Security Dashboard
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: semgrep.sarif
if: always()
viperlight:
runs-on: ubuntu-latest
needs: semantic-validate
env:
CI: "false"
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Viperlight Scan
run: |
wget -q https://viperlight-scanner.s3.amazonaws.com/latest/.viperlightrc
wget -q https://viperlight-scanner.s3.amazonaws.com/latest/viperlight.zip
unzip -q viperlight.zip -d viperlight
rm -r ./viperlight.zip
cd viperlight
./install.sh
viperlight --version
echo "Content scanning utility installation complete `date`"
echo "Starting content scanning `date` in `pwd`"
echo "github.workspace is...>>>>>"
ls -l ${{ github.workspace }}/source
cd ${{ github.workspace }}/source
viperlight scan -m files-contents -m files-aws -m files-binary -m files-entropy -m files-secrets
echo "Completed content scanning `date`"
py-test:
runs-on: ubuntu-latest
needs: semantic-validate
env:
CI: 'true'
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: '${{ github.event.pull_request.head.ref }}'
repository: '${{ github.event.pull_request.head.repo.full_name }}'
- uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install dependencies
run: |
cd source/constructs/api
pip3 install -r requirements.txt
pip3 install pytest==7.4.2
pip3 install pytest-mock==3.11.1
pip3 install httpx==0.25.0
pip3 install anyio==3.6.2
pip3 install mock==5.1.0
pip3 install mock-alchemy==0.2.6
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_CN }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_CN }}
aws-region: ${{ secrets.AWS_REGION_CN }}
- name: Test with pytest
run: |
cd source/constructs/api
python -m pytest pytest -s
cdk-unit-test:
runs-on: ubuntu-latest
needs: semantic-validate
env:
CI: "false"
steps:
- name: demo test
run: |
true
api-unit-test:
runs-on: ubuntu-latest
needs: semantic-validate
env:
CI: "false"
steps:
- name: demo test
run: |
true
code-build-portal:
needs: [cdk-unit-test, api-unit-test]
runs-on: ubuntu-latest
env:
CI: "false"
steps:
- name: Checkout source
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: '18.x'
- name: Build source
run: |
echo "Build FE START>>>>>>>>>>>>>>>"
cd ${{ github.workspace }}/source/portal
rm -rf node_modules
npm install --legacy-peer-deps
npm run build
echo "Build FE END>>>>>>>>>>>>>>>"
echo "FE Content is shown as below:"
ls -L ${{ github.workspace }}/source/portal
code-build-backend:
needs: [cdk-unit-test, api-unit-test]
runs-on: ubuntu-latest
env:
CI: "false"
steps:
- name: Checkout source
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: '18.x'
- name: Install CDK
run: |
npm install -g aws-cdk
cdk --version
- name: Build source
run: |
echo "Build BE START>>>>>>>>>>>>>>>"
cd ${{ github.workspace }}/source/constructs
rm -rf node_modules
npm install --legacy-peer-deps
cdk synth
echo "Build BE END>>>>>>>>>>>>>>>"
echo "BE Content is shown as below:"
ls -L ${{ github.workspace }}/source/constructs/cdk.out