83 lines (80 loc) · 2.54 KB
/
build_and_test_reusable.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
name: Reusable build and test
on:
workflow_call:
inputs:
do-build:
required: true
type: boolean
module:
required: true
type: string
gradle-cache-read-only:
required: false
type: boolean
default: true
jobs:
build_module:
name: Build
if: inputs.do-build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# required for correct codecov upload
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
- name: Install system packages
if: inputs.module == 'save-agent' || inputs.module == 'save-demo-agent'
# libcurl is needed for ktor-client-curl
run: sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev
- name: Retrieve Kotlin version
run: |
kv=$(cat gradle/libs.versions.toml | grep '^kotlin =' | awk -F'[=]' '{print $2}' | tr -d '" ')
echo KOTLIN_VERSION=$kv >> $GITHUB_ENV
- name: Cache konan
uses: actions/cache@v4
with:
path: ~/.konan
key: ${{ runner.os }}-gradle-konan-${{ env.KOTLIN_VERSION }}
- name: Build ${{ inputs.module }}
uses: gradle/gradle-build-action@v3
with:
gradle-version: wrapper
gradle-home-cache-cleanup: true
# we need to write cache for PRs
cache-read-only: ${{ inputs.gradle-cache-read-only }}
arguments: |
:${{ inputs.module }}:build
-x detekt
-x spotlessCheck
-Pdetekt.multiplatform.disabled=true
-PgprUser=${{ github.actor }}
-PgprKey=${{ secrets.GITHUB_TOKEN }}
--scan
--build-cache
- name: Upload gradle reports ${{ inputs.module }}
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: gradle-reports-${{ inputs.module }}
path: '${{ inputs.module }}/build/reports/'
retention-days: 1
- name: Upload frontend distribution
if: inputs.module == 'save-frontend'
uses: actions/upload-artifact@v4
with:
name: save-frontend
path: 'save-frontend/build/libs/save-frontend-*-distribution.jar'
retention-days: 1
build_module_skipped:
name: Build
if: ${{ !inputs.do-build }}
runs-on: ubuntu-latest
steps:
- name: Do nothing
run: |
echo "Build of ${{ inputs.module }} is skipped"