-
Notifications
You must be signed in to change notification settings - Fork 0
112 lines (95 loc) · 2.64 KB
/
pr-build.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
name: PR Build
on:
pull_request:
branches: [ main ]
paths:
- 'gradle/**'
- '**.gradle'
- 'gradle.properties'
- 'sd-app/**'
- 'sd-ft/**'
- '.github/workflows/pr-build.yml'
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'debug'
type: choice
options:
- info
- warning
- debug
jobs:
build-and-unit-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Build + unit tests
run: ./gradlew :sd-app:build
- name: Upload unit tests report
if: always()
uses: actions/upload-artifact@v4
with:
name: unit-tests-report
path: |
sd-app/build/reports/tests/test/**/*
- name: Upload JAR
uses: actions/upload-artifact@v4
with:
name: app-jar
path: sd-app/build/libs/service-discovery.jar
functional-tests:
needs: build-and-unit-tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Download JAR
uses: actions/download-artifact@v4
with:
name: app-jar
path: sd-app/build/libs/
- name: Start Spring Boot app
run: java -jar sd-app/build/libs/service-discovery.jar &
- name: Wait for Spring Boot to start
run: |
echo "Waiting for Spring Boot to start..."
sleep 3
- name: Run functional tests
run: ./gradlew --no-daemon :sd-ft:cucumber
- name: Stop Spring Boot app
run: |
echo "Stopping Spring Boot app..."
pkill -f 'java -jar sd-app/build/libs/service-discovery.jar'
- name: Archive Cucumber test reports
if: always()
uses: actions/upload-artifact@v4
with:
name: cucumber-tests-report
path: |
sd-ft/reports/cucumber-report.html
build-docker-image:
needs: build-and-unit-tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download JAR
uses: actions/download-artifact@v4
with:
name: app-jar
path: sd-app/build/libs/
- name: Build Docker Image
run: docker build -t myapp:${{ github.sha }} sd-app/