-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (51 loc) · 1.83 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
name: Build and Test
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Define BUILD_LABEL
env:
INPUT: ${{ github.head_ref || github.ref_name }}
run: |
echo "BUILD_LABEL=${INPUT//\//_}" >> $GITHUB_ENV
# - name: Echo env
# run: env | sort
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@56b90f209b02bf6d1deae490e9ef18b21a389cd4
# 1.1.0
# From https://docs.sonarqube.org/latest/analysis/github-integration/
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Set build version
# Cannot use ${BUILD_LABEL} with gradle-build-action, so stuff version
# into gradle.properties
run: sed -i 's/^version.*/version = '${BUILD_LABEL}'/;' ./gradle.properties
- name: Run tests
uses: gradle/gradle-build-action@982da8e78c05368c70dac0351bb82647a9e9a5d2
# 2.11.1
with:
# Only write to the cache for builds on the 'main' branch (default - but here for documentation)
cache-read-only: ${{ github.ref != 'refs/heads/main' }}
arguments: check javadoc publish -s
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}