-
Notifications
You must be signed in to change notification settings - Fork 0
148 lines (145 loc) · 5.61 KB
/
ci.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
name: build
on:
pull_request:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v4
with:
# Fetch tags to allow constructing version string
fetch-depth: 0
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: adopt
java-version: 21
- name: Install a newer curl
# Integration tests utilize --retry-all-errors, which is added in curl 7.71.0
run: |
curl -vL https://github.com/moparisthebest/static-curl/releases/download/v7.78.0/curl-amd64 -o /tmp/curl
sudo install /tmp/curl /usr/local/bin/curl
echo "/usr/local/bin" >> $GITHUB_PATH
- name: Set version
run: |
echo "VERSION=$(./scripts/version.sh)" >> $GITHUB_ENV
- name: Setup Gradle
uses: gradle/actions/[email protected]
- name: Build and test
run: ./gradlew build --info
- name: Add coverage report to PR
if: ${{ github.event_name == 'pull_request' }}
uses: madrapps/[email protected]
continue-on-error: true # Commenting doesn't work from forked PRs, because those have no access to secrets
with:
title: Unit and integration test coverage
update-comment: true
paths: ${{ github.workspace }}/server/build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: 78 # Current coverage
min-coverage-changed-files: 80 # Okay target for now
- name: Add feature test coverage report to PR
if: ${{ github.event_name == 'pull_request' }}
uses: madrapps/[email protected]
continue-on-error: true
with:
title: Feature test coverage
update-comment: true
paths: ${{ github.workspace }}/build/reports/jacoco/featureTestReport/featureTestReport.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: 75
min-coverage-changed-files: 80
- name: Save test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test results
path: "**/build/reports/tests/test/"
- name: Save coverage reports
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage
path: "build/reports/jacoco"
- name: Save swagger ui
if: always()
uses: actions/upload-artifact@v4
with:
name: swagger ui
path: api-doc/build/swagger-ui
- name: Output docker image
run: |
docker image save vauhtijuoksu/vauhtijuoksu-api:${{ env.VERSION }} -o vauhtijuoksu-api.tar
- name: Save Docker image
uses: actions/upload-artifact@v4
with:
name: vauhtijuosu-api.tar
path: vauhtijuoksu-api.tar
publish:
if: github.ref == 'refs/heads/main' && vars.DEPLOY_TO_PROD == 'true'
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v4
with:
# Fetch tags to allow constructing version string
fetch-depth: 0
- name: Set version
run: |
echo "VERSION=$(./scripts/version.sh)" >> $GITHUB_ENV
- uses: actions/download-artifact@v4
with:
name: swagger ui
path: swagger-ui
- uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Upload rendered specification to Azure
run: |
az storage blob upload-batch -s swagger-ui -d '$web' --account-name vauhtijuoksu --overwrite
- uses: actions/download-artifact@v4
with:
name: vauhtijuosu-api.tar
path: .
- run: |
docker load --input vauhtijuoksu-api.tar
- uses: azure/docker-login@v1
with:
login-server: vauhtijuoksu.azurecr.io
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
- name: Push docker image to ACR
run: |
docker tag vauhtijuoksu/vauhtijuoksu-api:${{ env.VERSION }} vauhtijuoksu.azurecr.io/vauhtijuoksu/vauhtijuoksu-api:${{ env.VERSION }}
docker push vauhtijuoksu.azurecr.io/vauhtijuoksu/vauhtijuoksu-api:${{ env.VERSION }}
- uses: azure/[email protected]
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
cluster-name: vauhtijuoksu
resource-group: Vauhtijuoksu-Azure-Sponsorship
- uses: azure/[email protected]
id: install
- name: Deploy mock server to AKS
run: |
helm upgrade --install mockserver deployment/mockserver
- name: Deploy Redis to AKS
run: |
kubectl delete secret vauhtijuoksu-api-redis --ignore-not-found
kubectl create secret generic vauhtijuoksu-api-redis --from-literal=REDIS__PASSWORD=${{ secrets.REDIS_PASSWORD }}
helm upgrade --install redis oci://registry-1.docker.io/bitnamicharts/redis \
--set architecture=standalone \
--set auth.existingSecret=vauhtijuoksu-api-redis \
--set auth.existingSecretPasswordKey=REDIS__PASSWORD \
--version 18.1.5
- name: Deploy API server to AKS
run: |
helm upgrade --install vauhtijuoksu-api deployment/api-server \
--set database.address=${{ secrets.DATABASE_ADDRESS }} \
--set database.user=${{ secrets.DATABASE_USERNAME }} \
--set database.database=${{ secrets.DATABASE_DATABASE }} \
--set image.tag=${{ env.VERSION }}