-
Notifications
You must be signed in to change notification settings - Fork 8
79 lines (78 loc) · 3.06 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
name: Build and test
on:
# Capture this event so that gradle caches are updated when a PR is merged to develop
# More information on why: https://github.com/gradle/gradle-build-action#using-the-caches-read-only
push:
branches:
- develop
paths:
- 'src/**'
- '.github/**'
pull_request:
types: [opened, synchronize, reopened]
paths:
- 'src/**'
- '.github/**'
permissions:
contents: write # Required for https://github.com/gradle/actions/tree/main/setup-gradle#github-dependency-graph-support
pull-requests: write # https://github.com/gradle/actions/tree/main/setup-gradle#adding-job-summary-as-a-pull-request-comment
actions: read # Required for https://github.com/dorny/test-reporter
checks: write # Required for https://github.com/dorny/test-reporter
# Cancels previous workflow run on PR if a new one is started (does not affect push to develop).
# This is because github.head_ref is empty on push events so defaults to the unique github.run_id.
# More info: https://docs.github.com/en/actions/using-jobs/using-concurrency
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
BuildAndPackageWithUnitTests:
name: Build, test and package code
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # SonarCloud: Shallow clones should be disabled for a better relevancy of analysis
# Setting up both JDK 11 and 17
# 11 is used for compiling and running tests
# 17 is required by sonar
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4
with:
cache-read-only: ${{ github.ref != 'refs/heads/develop' }}
gradle-home-cache-cleanup: true
dependency-graph: generate-and-submit
add-job-summary-as-pr-comment: always
- name: Build and test source
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
working-directory: ./src
run: ./gradlew build jacocoTestReport sonar -Dsonar.projectKey=nordic-institute_xrd4j -Dsonar.organization=nordic-institute -Dsonar.host.url=https://sonarcloud.io
- name: Test report
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: Unit and integration tests
path: src/**/build/test-results/**/TEST-*.xml
reporter: java-junit
list-suites: 'failed'
list-tests: 'failed'
- name: Build example-adapter
working-directory: ./example-adapter
run: ./gradlew --include-build ../src build