-
Notifications
You must be signed in to change notification settings - Fork 16
59 lines (57 loc) · 2.06 KB
/
code_analysis.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
name: Code Analysis
on:
workflow_dispatch:
pull_request:
branches: [main]
paths-ignore:
- "**.md"
- "docs/**"
jobs:
is_java_project:
runs-on: ubuntu-latest
outputs:
pom_exists: ${{ steps.check_files.outputs.files_exists }}
checkstyle_active: ${{ steps.check_checkstyle.outputs.checkstyle_active }}
spotbugs_active: ${{ steps.check_spotbugs.outputs.spotbugs_active }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Check file existence
id: check_files
uses: andstor/file-existence-action@v2
with:
files: "pom.xml"
- name: check_checkstyle
id: check_checkstyle
run: echo "checkstyle_active=$(if grep -q "<artifactId>maven-checkstyle-plugin</artifactId>" pom.xml; then echo "true"; else echo "false"; fi)" >> $GITHUB_OUTPUT
- name: check_spotbugs
id: check_spotbugs
run: echo "spotbugs_active=$(if grep -q "<artifactId>spotbugs-maven-plugin</artifactId>" pom.xml; then echo "true"; else echo "false"; fi)" >> $GITHUB_OUTPUT
run_checkstyle:
needs: [is_java_project]
if: needs.is_java_project.outputs.pom_exists == 'true' && needs.is_java_project.outputs.checkstyle_active == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: "17"
cache: "maven"
- name: Run style checks
run: mvn -B checkstyle:check --file pom.xml
run_spotbugs:
needs: [is_java_project]
if: needs.is_java_project.outputs.pom_exists == 'true' && needs.is_java_project.outputs.spotbugs_active == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: "17"
cache: "maven"
- name: Run static code analysis
run: mvn -B compile spotbugs:check --file pom.xml