-
Notifications
You must be signed in to change notification settings - Fork 0
155 lines (126 loc) Β· 4.14 KB
/
build-and-test.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
149
150
151
152
153
154
155
name: "Build and Test"
on:
push:
branches:
- "master"
jobs:
build-natively-with-gradle:
name: "Build natively with Gradle"
runs-on: "ubuntu-latest"
steps:
- name: "Check out source code"
uses: "actions/checkout@v4.2.2"
- name: "Set up JDK 21"
uses: "actions/setup-java@v4.5.0"
with:
java-version: "21"
distribution: "corretto"
- name: "Validate Gradle wrapper"
uses: "gradle/actions/wrapper-validation@v3.5.0"
- name: "Set up Gradle"
uses: "gradle/actions/setup-gradle@v3.5.0"
- name: "Build with Gradle"
run: "gradle build"
- name: "Upload 'AdventOfCode.jar' artifact"
uses: "actions/upload-artifact@v4.4.3"
with:
name: "AdventOfCode.jar"
path: "build/libs/AdventOfCode.jar"
if-no-files-found: "error"
- name: "Upload Ktlint reports artifact"
if: "${{ always() }}"
uses: "actions/upload-artifact@v4.4.3"
with:
name: "Ktlint Reports"
path: "build/reports/ktlint"
if-no-files-found: "error"
- name: "Upload test summary artifact"
if: "${{ always() }}"
uses: "actions/upload-artifact@v4.4.3"
with:
name: "Test Summary"
path: "build/reports/tests/test"
if-no-files-found: "error"
- name: "Upload coverage report artifact"
if: "${{ always() }}"
uses: "actions/upload-artifact@v4.4.3"
with:
name: "Coverage Report"
path: "build/reports/jacoco/test"
if-no-files-found: "error"
run-jar-natively:
name: "Run JAR archive natively"
needs: "build-natively-with-gradle"
runs-on: "ubuntu-latest"
steps:
- name: "Download 'AdventOfCode.jar' artifact"
uses: "actions/download-artifact@v4.1.8"
with:
name: "AdventOfCode.jar"
path: "."
- name: "Set up JDK 21"
uses: "actions/setup-java@v4.5.0"
with:
java-version: "21"
distribution: "corretto"
- name: "Run JAR archive"
run: "java -jar AdventOfCode.jar 2024"
build-docker-image:
name: "Build Docker Image"
runs-on: "ubuntu-latest"
steps:
- name: "Check out source code"
uses: "actions/checkout@v4.2.2"
- name: "Lint Dockerfile"
uses: "luke142367/Docker-Lint-Action@v1.1.1"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: "Set up Docker Buildx"
uses: "docker/setup-buildx-action@v3.7.1"
- name: "Build Docker Image"
uses: "docker/build-push-action@v6.9.0"
with:
tags: "pfolta/advent-of-code:latest"
outputs: "type=docker, dest=AdventOfCode.tar"
push: false
- name: "Upload Docker image artifact"
uses: "actions/upload-artifact@v4.4.3"
with:
name: "Docker Image"
path: "AdventOfCode.tar"
if-no-files-found: "error"
run-docker-image:
name: "Run Docker Image"
needs: "build-docker-image"
runs-on: "ubuntu-latest"
steps:
- name: "Download Docker image artifact"
uses: "actions/download-artifact@v4.1.8"
with:
name: "Docker Image"
path: "."
- name: "Load Docker image"
run: |
docker load --input AdventOfCode.tar
docker image ls pfolta/advent-of-code
- name: "Run Docker image"
uses: "addnab/docker-run-action@v3"
with:
image: "pfolta/advent-of-code:latest"
run: "java -jar AdventOfCode.jar 2024"
publish-coverage-data:
name: "Publish coverage data to Codecov"
needs: ["run-jar-natively", "run-docker-image"]
runs-on: "ubuntu-latest"
steps:
- name: "Check out source code"
uses: "actions/checkout@v4.2.2"
- name: "Download coverage report artifact"
uses: "actions/download-artifact@v4.1.8"
with:
name: "Coverage Report"
path: "build/reports/jacoco/test"
- name: "Publish coverage data to Codecov"
uses: "codecov/codecov-action@v5.0.4"
with:
token: "${{ secrets.CODECOV_TOKEN }}"