-
-
Notifications
You must be signed in to change notification settings - Fork 52
181 lines (151 loc) · 6.62 KB
/
ci.yml
File metadata and controls
181 lines (151 loc) · 6.62 KB
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
name: CI
on:
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 25
uses: actions/setup-java@v4
with:
java-version: '25'
distribution: 'temurin'
cache: maven
- name: Install dependencies for acknowledgments script
run: |
sudo apt-get update
sudo apt-get install -y jq curl
- name: Generate acknowledgments data
run: |
chmod +x scripts/generate-acknowledgments.sh
./scripts/generate-acknowledgments.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build JAR without tests
run: mvn compile package -DskipTests
- name: Create bundle
run: mkdir staging && cp target/*.jar staging
- name: Upload JAR artifact
uses: actions/upload-artifact@v4
with:
name: jar-artifact
path: staging/
retention-days: 1
unit-tests:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 25
uses: actions/setup-java@v4
with:
java-version: '25'
distribution: 'temurin'
cache: maven
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Run unit tests
run: mvn test
env:
DOCKER_HOST: unix:///var/run/docker.sock
SPRING_PROFILES_ACTIVE: test,ci
- name: Upload coverage reports as artifact
uses: actions/upload-artifact@v4
with:
name: coverage-reports
path: |
target/site/jacoco/
retention-days: 30
e2e-tests:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download JAR artifact
uses: actions/download-artifact@v4
with:
name: jar-artifact
path: staging/
- name: Copy JAR to target directory for Docker build
run: |
mkdir -p target
cp staging/*.jar target/
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: docker-${{ runner.os }}-${{ github.sha }}
restore-keys: |
docker-${{ runner.os }}-
- name: Build docker image
uses: docker/build-push-action@v6
with:
platforms: linux/amd64
context: .
push: false
load: true
tags: dedicatedcode/reitti:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
- name: Move Docker cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Start docker-compose
run: docker compose -f docker-compose.ci.yml up -d
working-directory: e2e
- name: Wait for app to be ready
run: |
timeout 60 bash -c 'until curl -f http://localhost:8080; do sleep 2; done'
working-directory: e2e
- name: Cache npm dependencies
uses: actions/cache@v4
with:
path: e2e/node_modules
key: npm-${{ runner.os }}-${{ hashFiles('e2e/package-lock.json') }}
restore-keys: |
npm-${{ runner.os }}-
- name: Install dependencies
run: npm ci
working-directory: e2e
- name: Cache Playwright browsers
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: playwright-${{ runner.os }}-${{ hashFiles('e2e/package-lock.json') }}
restore-keys: |
playwright-${{ runner.os }}-
- name: Install Playwright browsers
run: npx playwright install --with-deps
working-directory: e2e
- name: Run Playwright tests
run: CI=1 npx playwright test --project=chromium --project=firefox --project=webkit
env:
BASE_URL: http://localhost:8080
working-directory: e2e
- name: Upload Playwright test results
uses: actions/upload-artifact@v4
if: failure()
with:
name: playwright-test-results
path: e2e/test-results/
retention-days: 30
- name: Upload Playwright report
uses: actions/upload-artifact@v4
if: failure()
with:
name: playwright-report
path: e2e/playwright-report/
retention-days: 30
- name: Stop docker-compose
run: docker compose -f docker-compose.ci.yml down
working-directory: e2e
if: always()