forked from operaton/operaton
-
Notifications
You must be signed in to change notification settings - Fork 0
138 lines (132 loc) · 4.04 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
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
131
132
133
134
135
136
137
138
# This workflow builds Operaton, and cache/restore any dependencies to improve the workflow execution time
name: build
on:
push:
branches: ["main"]
paths-ignore:
- '.github/workflows/**'
- '!.github/workflows/build.yml'
- '**/*.md'
- 'distro/**'
- 'settings/**'
- '.gitingore'
- 'LICENSE'
- 'NOTICE'
pull_request:
branches: ["main"]
paths-ignore:
- '.github/workflows/**'
- '!.github/workflows/build.yml'
- '**/*.md'
- 'distro/**'
- 'settings/**'
- '.gitingore'
- 'LICENSE'
- 'NOTICE'
permissions:
contents: read
checks: write
id-token: write
concurrency:
group: ${{github.workflow}}-${{github.ref}}
cancel-in-progress: true
jobs:
build:
name: Build
strategy:
fail-fast: true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# Prevent Shallow Clone to satisfy Sonarqube
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{runner.os}}-m2-${{hashFiles('**/pom.xml')}}
restore-keys: ${{runner.os}}-m2
- name: Maven Build
shell: bash
run: |
echo "Creating a flag file 'executeJacoco' for each module containing tests. \
This triggers activation of the 'coverage' profile."
find . -type d | while read -r dir; do
if [[ -d "$dir/src/test/java" || -d "$dir/target/generated-test-sources/java" ]]; then
# Create an empty file target/executeJacoco if the condition is met
mkdir -p "$dir/target"
touch "$dir/target/executeJacoco"
fi
done
./mvnw install -DskipTests=true -Dmaven.javadoc.skip=true
- name: Upload Build Artifacts
id: upload-build-artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: build-artifacts
path: |
${{github.workspace}}/**/jacoco.xml
${{github.workspace}}/**/target/surefire-reports/*.xml
retention-days: 30
- name: Upload Distros
id: upload-distros
uses: actions/upload-artifact@v4
with:
name: distros
path: |
${{github.workspace}}/distro/*/assembly/target/*.gz
static_analysis:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: release-artifacts
- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{runner.os}}-sonar
restore-keys: ${{runner.os}}-sonar
- name: Sonarqube Analysis
if: env.SONAR_TOKEN && (github.ref == 'refs/heads/main' || github.event_name == 'pull_request')
needs: build
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
SONAR_TOKEN: ${{secrets.SONAR_TOKEN}}
shell: bash
run: |
./mvnw -N org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
-Dsonar.projectKey=operaton_operaton \
-Dsonar.coverage.jacoco.xmlReportPaths=$(find $(pwd) -name jacoco.xml | paste -sd ',' -)
continue-on-error: true
reports:
name: Publish Test Report
needs: build
runs-on: ubuntu-latest
steps:
- name: Publish Test Report
if: always()
#https://github.com/marketplace/actions/junit-report-action
uses: mikepenz/action-junit-report@v4
with:
report_paths: ${{github.workspace}}/**/target/surefire-reports/*.xml
require_passed_tests: true