-
Notifications
You must be signed in to change notification settings - Fork 2
219 lines (219 loc) · 7.6 KB
/
build-organisaatio-service.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
215
216
217
218
219
name: organisaatio
on:
workflow_dispatch:
push:
branches: [master]
pull_request:
jobs:
build:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:12.14
ports:
- 5433:5432
env:
POSTGRES_USER: postgres
POSTGRES_DB: organisaatio
POSTGRES_PASSWORD: postgres
POSTGRES_HOST_AUTH_METHOD: trust
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: organisaatio-ui/package-lock.json
- uses: actions/setup-java@v4
with:
java-version: "21"
distribution: "corretto"
- uses: szenius/[email protected]
with:
timezoneLinux: "Europe/Helsinki"
- name: Build frontend
working-directory: organisaatio-ui
run: |
npm ci
npm run lint
npm run prettier
CI=true npm run test
npm run build
- uses: gradle/actions/wrapper-validation@v3
- uses: gradle/actions/setup-gradle@v3
- name: Build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew clean build
- uses: actions/upload-artifact@v4
with:
name: organisaatio-service-jar
path: organisaatio-service/build/libs/organisaatio-service.jar
cypress:
runs-on: ubuntu-latest
services:
postgres:
image: postgres
ports:
- 5432:5432
env:
POSTGRES_PASSWORD: postgres
POSTGRES_HOST_AUTH_METHOD: trust
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- name: Cypress coverrage cache
uses: actions/cache@v4
env:
cache-name: cache-cypress-coverage
with:
path: organisaatio-ui/cypress-coverage
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.sha }}
- uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: organisaatio-ui/package-lock.json
- uses: actions/setup-java@v4
with:
java-version: "21"
distribution: "corretto"
- name: pre scripts
run: |
PGPASSWORD=postgres psql -c 'CREATE DATABASE organisaatio;' -h localhost -U postgres
cd mock-api && npm install && cd -
cd organisaatio-ui && npm ci --force && cd -
- uses: gradle/actions/wrapper-validation@v3
- uses: gradle/actions/setup-gradle@v3
- name: Build backend with no tests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew clean build -x test
- name: Run Cypress
run: |
cd mock-api && npm run mock-api &
cd organisaatio-ui && npm run start &
java -jar -Xms2g -Xmx2g -Dspring.config.location=classpath:application.properties,classpath:application-test-envs.properties -Dspring.profiles.active=dev -Dspring.flyway.enabled=true -Durl-virkailija=http://localhost:9000 -Dhost.virkailija=localhost:9000 -Durl-ytj=http://localhost:9000/ytj -Durl-oidservice=http://localhost:9000/oidservice -Dcas.service.organisaatio-service=http://localhost:8080/organisaatio-service-not-available organisaatio-service/build/libs/organisaatio-service.jar &
cd organisaatio-ui && npm run cypress:ci
kill $(jobs -p) || true
playwright:
timeout-minutes: 60
runs-on: ubuntu-latest
services:
postgres:
image: postgres
ports:
- 5432:5432
env:
POSTGRES_PASSWORD: postgres
POSTGRES_HOST_AUTH_METHOD: trust
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: organisaatio-ui/package-lock.json
- uses: actions/setup-java@v4
with:
java-version: "21"
distribution: "corretto"
- name: pre scripts
run: |
PGPASSWORD=postgres psql -c 'CREATE DATABASE organisaatio;' -h localhost -U postgres
cd mock-api && npm ci && cd -
cd organisaatio-ui && npm ci --force && cd -
cd playwright && npm ci && npx playwright install --with-deps && cd -
- uses: gradle/actions/wrapper-validation@v3
- uses: gradle/actions/setup-gradle@v3
- name: Build backend with no tests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew clean build -x test
- name:
run: |
cd mock-api && npm run mock-api &
cd organisaatio-ui && npm run start &
java -jar -Xms2g -Xmx2g -Dspring.config.location=classpath:application.properties,classpath:application-test-envs.properties -Dspring.profiles.active=dev -Dspring.flyway.enabled=true -Durl-virkailija=http://localhost:9000 -Dhost.virkailija=localhost:9000 -Durl-ytj=http://localhost:9000/ytj -Durl-oidservice=http://localhost:9000/oidservice -Dcas.service.organisaatio-service=http://localhost:8080/organisaatio-service-not-available organisaatio-service/build/libs/organisaatio-service.jar &
while ! nc -z localhost 3003; do
sleep 1; echo "Sleeping 3003"
done
while ! nc -z localhost 8080; do
sleep 1; echo "Sleeping 8080"
done
cd playwright && npx playwright test
kill $(jobs -p) || true
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright/playwright-report/
retention-days: 30
sonarcloud:
needs: [cypress, playwright]
runs-on: ubuntu-latest
services:
postgres:
image: postgres:12.14
ports:
- 5433:5432
env:
POSTGRES_USER: postgres
POSTGRES_DB: organisaatio
POSTGRES_PASSWORD: postgres
POSTGRES_HOST_AUTH_METHOD: trust
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set timezone
uses: szenius/[email protected]
with:
timezoneLinux: "Europe/Helsinki"
- name: Cypress coverrage cache
uses: actions/cache@v4
env:
cache-name: cache-cypress-coverage
with:
path: organisaatio-ui/cypress-coverage
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.sha }}
- uses: actions/setup-java@v4
with:
java-version: 21
distribution: "corretto"
- 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 analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew build sonarqube