Skip to content

Commit e16d722

Browse files
committed
Move example project workflow to parent, add build scripts and sonar
WE2-932 Signed-off-by: Sven Mitt <[email protected]>
1 parent a945f5b commit e16d722

File tree

5 files changed

+107
-30
lines changed

5 files changed

+107
-30
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Maven build example
2+
3+
on:
4+
push:
5+
paths:
6+
- 'example/**'
7+
- '.github/workflows/*example*'
8+
pull_request:
9+
paths:
10+
- 'example/**'
11+
- '.github/workflows/*example*'
12+
13+
defaults:
14+
run:
15+
working-directory: ./example
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- uses: actions/checkout@v3
23+
24+
- uses: actions/setup-java@v3
25+
with:
26+
distribution: zulu
27+
java-version: 11
28+
29+
- name: Cache Maven packages
30+
uses: actions/cache@v3
31+
with:
32+
path: ~/.m2
33+
key: ${{ runner.os }}-m2-v8-${{ hashFiles('**/pom.xml') }}
34+
restore-keys: ${{ runner.os }}-m2-v8
35+
36+
- name: Build
37+
run: mvn --batch-mode compile
38+
39+
- name: Test and package
40+
run: mvn --batch-mode package
41+

.github/workflows/maven-build.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
name: Maven build
22

3-
on: [ push, pull_request ]
3+
on:
4+
push:
5+
paths-ignore:
6+
- 'example/**'
7+
- '.github/workflows/*example*'
8+
pull_request:
9+
paths-ignore:
10+
- 'example/**'
11+
- '.github/workflows/*example*'
412

513
jobs:
614
build:
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: SonarCloud code analysis of example
2+
3+
on:
4+
push:
5+
paths:
6+
- 'example/**'
7+
- '.github/workflows/*example*'
8+
pull_request:
9+
paths:
10+
- 'example/**'
11+
- '.github/workflows/*example*'
12+
13+
defaults:
14+
run:
15+
working-directory: ./example
16+
17+
jobs:
18+
analyze:
19+
name: Analyze
20+
if: github.repository == 'web-eid/web-eid-authtoken-validation-java'
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
27+
- name: Set up JDK 17
28+
uses: actions/setup-java@v3
29+
with:
30+
distribution: zulu
31+
java-version: 17
32+
- name: Cache SonarCloud packages
33+
uses: actions/cache@v3
34+
with:
35+
path: ~/.sonar/cache
36+
key: ${{ runner.os }}-sonar
37+
restore-keys: ${{ runner.os }}-sonar
38+
- name: Cache Maven packages
39+
uses: actions/cache@v3
40+
with:
41+
path: ~/.m2
42+
key: ${{ runner.os }}-m2-v11-${{ hashFiles('**/pom.xml') }}
43+
restore-keys: ${{ runner.os }}-m2-v17
44+
- name: Build and analyze
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
47+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
48+
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar

.github/workflows/sonarcloud-analysis.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
name: SonarCloud code analysis
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
paths-ignore:
6+
- 'example/**'
7+
- '.github/workflows/*example*'
8+
pull_request:
9+
paths-ignore:
10+
- 'example/**'
11+
- '.github/workflows/*example*'
412

513
jobs:
614
analyze:

example/.github/workflows/maven-build.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)