-
Notifications
You must be signed in to change notification settings - Fork 2
130 lines (128 loc) · 4.82 KB
/
ci.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
name: Maven CI
on:
schedule:
- cron: '42 0 * * 1'
push:
branches:
- master
pull_request:
branches:
- master
pull_request_target:
types:
- labeled
branches:
- master
release:
types:
- published
jobs:
build:
runs-on: ubuntu-latest
permissions:
checks: write
security-events: write
strategy:
matrix:
java:
- 17
- 21
event:
- ${{ github.event_name }}
exclude:
- event: pull_request_target
java: 17
steps:
- uses: actions/checkout@v4
if: ${{ github.event_name != 'pull_request_target' }}
with:
fetch-depth: 0
persist-credentials: ${{ !startsWith(github.event_name, 'pull_request') }}
- uses: actions/checkout@v4
if: ${{ github.event_name == 'pull_request_target' }}
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
persist-credentials: false
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
if: ${{ matrix.java == '17' && github.event_name != 'release' && github.event_name != 'pull_request_target' }}
uses: github/codeql-action/init@v3
with:
languages: java
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: ${{ matrix.java }}
cache: 'maven'
- name: Setup Git
run: >
git config --global user.email "[email protected]" &&
git config --global user.name "GitHub Actions"
if: ${{ !startsWith(github.event_name, 'pull_request') }}
- name: Build with Maven
run: mvn -B -V -e clean verify
- name: Upload Openliberty logfiles
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: openliberty-logs
path: '**/target/liberty/wlp/usr/servers/*/logs/**/*.log'
retention-days: 5
- name: Publish Test Report
if: ${{ (success() || failure()) && matrix.java == '21' && github.event_name == 'pull_request' }}
uses: scacap/action-surefire-report@v1
with:
report_paths: "**/target/*-reports/TEST-*.xml"
- name: Unittest Coverage
if: ${{ matrix.java == '21' && github.event_name != 'release' && github.event_name != 'pull_request_target' }}
run: >
mvn -B jacoco:report
- name: Unittest Codecov
if: ${{ matrix.java == '21' && github.event_name != 'release' && github.event_name != 'pull_request_target' }}
uses: codecov/codecov-action@v4
with:
flags: unittests
token: ${{ secrets.CODECOV_TOKEN }}
- name: Integrationstest Coverage
if: ${{ matrix.java == '21' && github.event_name != 'release' && github.event_name != 'pull_request_target' }}
run: >
mvn -B jacoco:report-integration@report-integration
- name: Integrationstest Codecov
if: ${{ matrix.java == '21' && github.event_name != 'release' && github.event_name != 'pull_request_target' }}
uses: codecov/codecov-action@v4
with:
flags: integration
token: ${{ secrets.CODECOV_TOKEN }}
- name: Perform CodeQL Analysis
if: ${{ matrix.java == '17' && github.event_name != 'release' && github.event_name != 'pull_request_target' }}
uses: github/codeql-action/analyze@v3
- name: Sonar Report
if: ${{ matrix.java == '21' && (!startsWith(github.event_name, 'pull_request') || !github.event.pull_request.head.repo.fork || contains(github.event.pull_request.labels.*.name, 'sonar')) }}
run: >
if [ "$GITHUB_EVENT_NAME" == "pull_request_target" ];
then
export GITHUB_EVENT_NAME=pull_request;
export GITHUB_REF=refs/pull/$GITHUB_PULL_REQUEST/merge;
fi &&
mvn -B -e jacoco:report jacoco:report-integration@report-integration sonar:sonar -Dsonar.organization=jonasrutishauser-github
env:
GITHUB_PULL_REQUEST: ${{ github.event.number }}
GITHUB_TOKEN: ${{ github.token }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: https://sonarcloud.io
- name: Deploy Site
if: ${{ matrix.java == '17' && github.event_name != 'release' && !startsWith(github.event_name, 'pull_request') }}
run: mvn -B -e site-deploy
env:
GITHUB_TOKEN: ${{ github.token }}
update-pr:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'sonar') }}
steps:
- name: Remove Sonar Label
uses: peter-murray/remove-labels-action@v1
with:
labels: sonar