-
Notifications
You must be signed in to change notification settings - Fork 0
164 lines (155 loc) · 5.07 KB
/
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
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
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
GRADLE_OPTS: "-Dorg.gradle.console=plain -Dorg.gradle.caching=true -Dkotlin.caching.enabled=true"
jobs:
compile:
name: Build / compile
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Gradle and Java
uses: ./.github/gradle-action
with:
# Allows this job to write to the cache every time it runs
gradle-cache-read-only: false
- name: Start Gradle Daemon
run: gradle --info
- run: gradle testClasses
- name: Gradle Tasks Summary
run: cat build/reports/build-times.md >> $GITHUB_STEP_SUMMARY
detekt:
name: Code Analysis / detekt
runs-on: ubuntu-latest
needs:
- compile
steps:
- uses: actions/checkout@v4
- name: detekt report
uses: natiginfo/[email protected]
with:
args: |
--report md:build/reports/detekt/detekt.md
- name: Detekt Summary
run: cat build/reports/detekt/detekt.md >> $GITHUB_STEP_SUMMARY
ktlint:
name: Code Analysis / ktlint
runs-on: ubuntu-latest
needs:
- compile
steps:
- uses: actions/checkout@v4
- uses: nbadal/action-ktlint-setup@v1
- name: ktlint version
run: ktlint --version
- name: run ktlin
run: ktlint --relative >> $GITHUB_STEP_SUMMARY
test:
name: Tests / test
runs-on: ubuntu-latest
needs:
- detekt
- ktlint
steps:
- uses: actions/checkout@v4
- name: Set up Gradle and Java
uses: ./.github/gradle-action
- name: Run tests
run: gradle koverHtmlReport -x accessibilityTest
- name: Gradle Tasks Summary
run: cat build/reports/build-times.md >> $GITHUB_STEP_SUMMARY
- name: Setup Pandoc
uses: r-lib/actions/setup-pandoc@v2
- name: Output Kover summary
# Adapted from https://github.com/Kotlin/kotlinx-kover/issues/419#issuecomment-1632572084
run: |
pandoc build/reports/kover/html/index.html -f html -t gfm | \
sed -n '/# project-starter: Overall Coverage Summary/,/<\/div>/p' | \
grep -v "</div>" >> $GITHUB_STEP_SUMMARY
- name: Test Summary Report
uses: phoenix-actions/test-reporting@v12
if: always()
with:
name: Kotest Report
path: "build/test-results/test/TEST-*.xml"
reporter: java-junit
output-to: "step-summary"
only-summary: "true"
build-docker:
name: Package / Docker / build
runs-on: ubuntu-latest
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
needs:
- test
steps:
- uses: actions/checkout@v4
- name: Set up Gradle and Java
uses: ./.github/gradle-action
- name: Docker / Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Docker / Set up Buildx
uses: docker/setup-buildx-action@v3
- name: Docker / Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker / Create Image
run: gradle dockerBuild
- name: Gradle Tasks Summary
run: cat build/reports/build-times.md >> $GITHUB_STEP_SUMMARY
- name: Docker / List images
run: docker images
- name: Docker / Get image name
id: dockerImageName
run: echo "dockerImageName=$(gradle -q dockerImageName)" >> "$GITHUB_OUTPUT"
- name: Docker / Get image metadata
id: dockerImageMetadata
uses: docker/metadata-action@v5
with:
images: ${{ steps.dockerImageName.outputs.dockerImageName }}
- name: Docker / Analyse image
uses: docker/scout-action@v1
with:
command: quickview
image: ${{ steps.dockerImageName.outputs.dockerImageName }}
write-comment: false
summary: true
check-if-prod:
if: ${{ github.ref == 'refs/heads/main' }}
name: Check if prod
runs-on: ubuntu-latest
needs:
- test
steps:
- run: echo "This is a push to main branch. Following with release and deploy"
create-release:
name: Creates a GitHub Release
runs-on: ubuntu-latest
needs:
- check-if-prod
- build-docker
# Docs:
# https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs
permissions:
contents: write
packages: read # to preserve default permissions
steps:
- uses: actions/checkout@v4
- name: Set up Gradle and Java
uses: ./.github/gradle-action
- name: Create Github Release
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }}
run: |
RELEASE_TITLE=$(gradle releaseDate --quiet)
TAG_NAME="v${{ github.run_number }}-$(git log HEAD -1 --pretty=format:'%h')"
gh release create "$TAG_NAME" --title "$RELEASE_TITLE" --generate-notes --latest
- name: Gradle Tasks Summary
run: cat build/reports/build-times.md >> $GITHUB_STEP_SUMMARY