Skip to content

config as java code #2070

config as java code

config as java code #2070

Workflow file for this run

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@v4
- 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@v4
- 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@v4
- 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