-
Notifications
You must be signed in to change notification settings - Fork 3
173 lines (169 loc) · 5.17 KB
/
ci.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
name: Java CI
on:
push:
branches: [master]
pull_request:
branches: [master]
env:
REGISTRY_NAME: github.com
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
java-version: [21]
go-version: ["1.22.0"]
os: [ubuntu-latest]
# https://github.com/actions/example-services/blob/master/.github/workflows/postgres-service.yml
services:
postgres:
image: postgres:17
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: 123456
POSTGRES_DB: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
redis:
image: redis:7.4.1-alpine
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps port 6379 on service container to the host
- 6379:6379
steps:
- uses: actions/checkout@v4.2.1
with:
submodules: recursive
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: "zulu"
java-version: ${{ matrix.java-version }}
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Run db migration
run: cd migration && go build -o migrate migration.go && ./migrate up
env:
POSTGRES_HOST: localhost
# POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }} # get randomly assigned published port
POSTGRES_PORT: 5432
POSTGRES_USER: postgres
POSTGRES_PASSWORD: 123456
POSTGRES_DB: postgres
POSTGRES_SSLMODE: disable
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Unit Test with Gradle
# run: ./gradlew flywayMigrate && ./gradlew build
run: ./gradlew test
env:
CI: true
- name: Unit Test with Maven
# run: ./gradlew flywayMigrate && ./gradlew build
run: ./mvnw test && ./mvnw surefire-report:report-only
env:
CI: true
build:
runs-on: ${{ matrix.os }}
needs: [test]
strategy:
matrix:
java-version: [21, 22]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v4.2.1
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: "zulu"
java-version: ${{ matrix.java-version }}
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build with Gradle
run: ./gradlew build -x test
build-maven:
runs-on: ${{ matrix.os }}
needs: [build]
strategy:
matrix:
java-version: [21]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v4.2.1
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: "zulu"
java-version: ${{ matrix.java-version }}
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build with Maven
run: ./mvnw package -Dmaven.test.skip=true
build-docker:
runs-on: ubuntu-latest
needs: [build, build-maven]
steps:
- uses: actions/checkout@master
# Container build
- name: Build docker with gradle
id: build-docker-g
run: |
docker build . -t ${{ env.REGISTRY_NAME }}/damingerdai/hoteler-g:${{ github.sha }} -f Dockerfile
- name: Image digest for gradle
run: echo ${{ steps.build-docker-g.outputs.digest }}
- name: Build docker with maven
id: build-docker-m
run: |
docker build . -t ${{ env.REGISTRY_NAME }}/damingerdai/hoteler-m:${{ github.sha }} -f maven.Dockerfile
- name: Image digest for maven
run: echo ${{ steps.build-docker-m.outputs.digest }}
build-bazel:
runs-on: ${{ matrix.os }}
needs: [build]
strategy:
matrix:
java-version: [21]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v4.2.1
- uses: bazel-contrib/setup-bazel@0.9.1
with:
# Avoid downloading Bazel every time.
bazelisk-cache: true
# Store build cache per workflow.
disk-cache: ${{ github.workflow }}
# Share repository cache between workflows.
repository-cache: true
- name: Build with bazel
run: bazel build //:hoteler