-
Notifications
You must be signed in to change notification settings - Fork 10
82 lines (80 loc) · 2.82 KB
/
Copy pathbuild-test-coverage.yml
File metadata and controls
82 lines (80 loc) · 2.82 KB
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
# Reusable workflow to build, run unit and integration test and coverage analysis, referenced by workflow-*.yml pipelines.
name: Build, tests and coverage analysis
on:
workflow_call:
secrets:
coveralls_repo_token:
required: true
inputs:
checkout_ref:
description: 'The reference to checkout before running the acceptance tests. Used to run the tests on a fork.'
required: true
type: string
outputs:
project_version:
description: "The project version"
value: ${{ jobs.build-test.outputs.project_version }}
jobs:
build-test:
name: Build and tests
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
java-distribution: [ temurin ]
java-version: [ 11, 17, 20, 21, 22, 23 ]
runs-on: ${{ matrix.os }}
outputs:
project_version: ${{ steps.get_project_version.outputs.project_version }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.checkout_ref }}
- name: Setup JDK ${{ matrix.java }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java-version }}
distribution: ${{ matrix.java-distribution }}
cache: 'gradle'
- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@v4
- name: Get project version
id: get_project_version
run: |
PROJECT_VERSION=$(./gradlew properties -q | grep "version:" | awk '{print $2}')
echo "project_version=$PROJECT_VERSION" >> $GITHUB_OUTPUT
- name: Semantic versioning check
run: |
if [[ "${{steps.get_project_version.outputs.project_version}}" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
echo "Project version ${{steps.get_project_version.outputs.project_version}} is valid"
else
echo "Project version ${{steps.get_project_version.outputs.project_version}} is not valid"; exit 1;
fi
- name: Lint
run: ./gradlew spotlessJavaCheck
- name: Build
run: ./gradlew build -x test
- name: Unit tests
run: ./gradlew unit-tests
- name: Integration tests
run: ./gradlew integration-tests
coverage:
name: Test coverage analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.checkout_ref }}
- name: Setup JDK
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: 'gradle'
- name: Validate Gradle wrapper
uses: gradle/actions/wrapper-validation@v4
- name: Test coverage
run: ./gradlew unit-tests jacocoTestReport coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.coveralls_repo_token }}
CI_BRANCH: ${{ inputs.checkout_ref }}