-
Notifications
You must be signed in to change notification settings - Fork 8
179 lines (174 loc) · 6.55 KB
/
build-core.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
name: Build Core
on:
push:
branches:
- main
- develop
- release/*
- feature/*
- fix/*
pull_request:
branches:
- main
- develop
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
MAVEN_CLI_OPTS: "-T 8 -s ci/ci_maven_settings.xml --batch-mode --errors --fail-at-end --show-version --no-transfer-progress -DinstallAtEnd=true -DdeployAtEnd=true"
MAVEN_PROFILES: ""
COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
strategy:
matrix:
build: [
{
type: "frontend",
maven-projects: "ui"
},
{
type: "backend",
maven-projects: "!ui"
}
]
steps:
- uses: actions/checkout@v3
- name: Set up JDK 19
uses: actions/setup-java@v3
with:
java-version: '19'
distribution: 'temurin'
cache: maven
- uses: s4u/maven-settings-action@v2.8.0
with:
path: ci/ci_maven_settings.xml
githubServer: false
servers: '[
{
"id": "ghcr.io",
"username": "${{github.actor}}",
"password": "${{secrets.GITHUB_TOKEN}}"
}
]'
- name: Build '${{ matrix.build.type }}' with Maven and push Docker Images
if: github.event_name != 'pull_request' && (github.ref_name == 'develop' || github.ref_name == 'main' || startsWith(github.ref_name, 'release/'))
run: mvn $MAVEN_PROFILES $MAVEN_CLI_OPTS --projects '${{ matrix.build.maven-projects }}' deploy
- name: Build '${{ matrix.build.type }}' with Maven
if: github.event_name == 'pull_request' || startsWith(github.ref_name, 'feature/') || startsWith(github.ref_name, 'fix/')
run: mvn $MAVEN_PROFILES $MAVEN_CLI_OPTS --projects '${{ matrix.build.maven-projects }}' clean org.jacoco:jacoco-maven-plugin:prepare-agent install -q org.jacoco:jacoco-maven-plugin:report -Pcoverage verify
- name: Build Coveralls Report
if: ${{ env.COVERALLS_TOKEN != '' && matrix.build.type == 'backend' && (github.event_name == 'pull_request' || startsWith(github.ref_name, 'feature/') || startsWith(github.ref_name, 'fix/')) }}
run: mvn jacoco:report coveralls:report -DrepoToken=$COVERALLS_TOKEN
env:
GITHUB_TOKEN: ${{ github.token }}
COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
- name: Log test output on failure
if: failure() || cancelled()
run: find . -type f -path "*test-reports/*-output.txt" -exec tail -n +1 {} +
deploy-staging-environment:
needs: build
if: github.event_name != 'pull_request' && (github.ref_name == 'develop' || github.ref_name == 'main' || startsWith(github.ref_name, 'release/'))
runs-on: self-hosted
env:
STAGING_VM_IP: ${{ github.ref_name == 'develop' && '10.3.7.166' || '10.3.7.145' }}
STAGING_VM_HOSTNAME: ${{ github.ref_name == 'develop' && 'develop.stage.slm.vfk' || 'main.stage.slm.vfk' }}
steps:
- name: Deploy stack von staging VM
uses: appleboy/ssh-action@v0.1.10
with:
host: ${{env.STAGING_VM_IP}}
username: vfk
key: ${{secrets.RUNNER_PRIVATE_KEY}}
envs: STAGING_VM_HOSTNAME,STAGING_VM_IP
script: |
cd /staging/tmp/slm/stack/compose || true
docker-compose down --volumes || true
docker system prune -f
sudo rm -r /staging/tmp && mkdir /staging/tmp && cd /staging/tmp
git clone -b ${{github.ref_name}} https://github.com/${{github.repository}}.git
cd /staging/tmp/slm
CORE_VERSION=$(cat pom.xml | grep -oPm1 "(?<=<revision>)[^<]+")
cd /staging/tmp/slm/stack/compose
sed -ir "s/^[#]*\s*SLM_HOSTNAME=.*/SLM_HOSTNAME=$STAGING_VM_HOSTNAME/" .env
sed -ir "s/^[#]*\s*SLM_IP=.*/SLM_IP=$STAGING_VM_IP/" .env
sed -ir "s/^[#]*\s*SLM_VERSION=.*/SLM_VERSION=$CORE_VERSION/" .env
echo ${{secrets.GITHUB_TOKEN}} | docker login -u${{github.actor}} --password-stdin ghcr.io
docker-compose pull
docker-compose up -d --force-recreate
- name: Test stack running on staging VM
uses: appleboy/ssh-action@v0.1.10
with:
host: ${{env.STAGING_VM_IP}}
username: vfk
key: ${{secrets.RUNNER_PRIVATE_KEY}}
script: |
cd /staging/tmp/slm/tests/backend
mvn test -Dtest=DockerStackTests
test-external-components:
needs: deploy-staging-environment
if: github.event_name != 'pull_request' && (github.ref_name == 'develop' || github.ref_name == 'main' || startsWith(github.ref_name, 'release/'))
runs-on: self-hosted
container:
image: maven:3.9-eclipse-temurin-19-focal
volumes:
- /tmp/.m2:/root/.m2
strategy:
matrix:
tests: [
{
component: "AWX",
test-class: "AWXTests"
},
{
component: "Consul",
test-class: "ConsulTests"
},
{
component: "Keycloak",
test-class: "KeycloakTests"
},
{
component: "Vault",
test-class: "VaultTests"
}
]
env:
TARGET_HOST: ${{ github.ref_name == 'develop' && '10.3.7.166' || '10.3.7.145' }}
steps:
- uses: actions/checkout@v3
- name: Run tests for '${{ matrix.tests.component }}' with Maven
run: |
cd tests/backend
mvn test -Dtest=${{ matrix.tests.test-class }}
test-internal-components:
needs: test-external-components
if: github.event_name != 'pull_request' && (github.ref_name == 'develop' || github.ref_name == 'main' || startsWith(github.ref_name, 'release/'))
runs-on: self-hosted
container:
image: maven:3.9-eclipse-temurin-19-focal
strategy:
matrix:
tests: [
{
component: "Notification Service",
test-class: "NotificationServiceTests"
},
{
component: "Resource Management",
test-class: "ResourceManagementTests"
},
{
component: "Service Management",
test-class: "ServiceManagementTests"
}
]
env:
TARGET_HOST: ${{ github.ref_name == 'develop' && '10.3.7.166' || '10.3.7.145' }}
steps:
- uses: actions/checkout@v3
- name: Run tests for '${{ matrix.tests.component }}' with Maven
run: |
cd tests/backend
mvn test -Dtest=${{ matrix.tests.test-class }}