-
Notifications
You must be signed in to change notification settings - Fork 1
214 lines (183 loc) · 6.29 KB
/
pre-merge-checks.yml
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
name: build and test
on:
push:
branches:
- main
pull_request:
types:
- opened
- reopened
- ready_for_review
- synchronize
env:
SAM_CLI_TELEMETRY: "0"
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11.2'
- uses: pre-commit/[email protected]
with:
extra_args: "detect-secrets --all-files"
test-node-delete-user-data:
runs-on: ubuntu-latest
timeout-minutes: 15
defaults:
run:
working-directory: ./lambdas/delete-user-data
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: '**/package-lock.json' # Need this so it looks in lambdas/delete-user-data for the package-lock
- name: Install dependencies
run: npm ci
- name: Linting
run: npm run lint
- name: Unit tests
run: npm run test
test-java:
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
cache: gradle
- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Build and unit tests
run: ./gradlew clean build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Perform Static Analysis
if: ${{ github.actor != 'dependabot[bot]' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew sonar
api-test:
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
id-token: write
packages: read
contents: read
defaults:
run:
working-directory: ./api-tests
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: '**/package-lock.json'
- name: Setup .npmrc
run: |
cp .npmrc.template .npmrc && \
sed -i s/GITHUB_PAT_WITH_READ:PACKAGES/${{ secrets.GITHUB_TOKEN }}/ .npmrc
- name: Install dependencies
run: npm ci
- name: Linting
run: npm run lint
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
cache: gradle
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Calculate queue name
# SQS queue names have a max length of 80 and cannot contain special characters
run: |
branch_name=${{ github.head_ref || github.sha }}
queue_name=`echo $branch_name | sed 's/[^[:alnum:]-]/\_/g' | cut -c1-60`
echo "queue_name=stubQueue_branch_$queue_name" >> $GITHUB_OUTPUT
id: extract_queue_name
- name: Setup app secrets
run: |
cp ../local-running/core.local.secrets.template.yaml ../local-running/core.local.secrets.yaml && \
sed -i s/CIMIT_API_KEY/${{ secrets.API_KEY_CIMIT }}/ ../local-running/core.local.secrets.yaml && \
sed -i s/EVCS_API_KEY/${{ secrets.API_KEY_EVCS }}/ ../local-running/core.local.secrets.yaml && \
sed -i s/ASYNC_QUEUE_API_KEY/${{ secrets.ASYNC_QUEUE_API_KEY }}/ ../local-running/core.local.secrets.yaml && \
sed -i s/ASYNC_QUEUE_NAME/${{ steps.extract_queue_name.outputs.queue_name }}/ ../local-running/core.local.secrets.yaml && \
sed -i s/TICF_API_KEY/${{ secrets.TICF_API_KEY }}/ ../local-running/core.local.secrets.yaml
sed -i s/DCMAW_ASYNC_SECRET/${{ secrets.DCMAW_ASYNC_SECRET }}/ ../local-running/core.local.secrets.yaml
- name: Local API tests
env:
ASYNC_QUEUE_NAME: ${{ steps.extract_queue_name.outputs.queue_name }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MANAGEMENT_CIMIT_STUB_API_KEY: ${{ secrets.MANAGEMENT_CIMIT_STUB_API_KEY }}
EVCS_STUB_API_KEY: ${{ secrets.API_KEY_EVCS }}
CRI_STUB_GEN_CRED_API_KEY: ${{ secrets.CRI_STUB_GEN_CRED_API_KEY }}
MANAGEMENT_TICF_API_KEY: ${{ secrets.MANAGEMENT_TICF_API_KEY }}
CIMIT_INTERNAL_API_KEY: ${{ secrets.API_KEY_CIMIT }}
run: npm run test:ci
- name: Upload API test report
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: API test report
path: api-tests/reports/
retention-days: 7
sam-build:
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
cache: gradle
- uses: aws-actions/setup-sam@v2
with:
use-installer: true
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- run: sam build -t deploy/template.yaml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}