From ea3e36065fdc5e68504e6188d1300d371bad6d1a Mon Sep 17 00:00:00 2001 From: RoiArthurB Date: Tue, 23 Apr 2024 13:44:27 +0700 Subject: [PATCH] [GHA] Add workflow for Pull Request This new workflow would build the new project as well as running SpotBugs (from maven plugin) and display review at the end of the workflow - Related #123 --- .github/workflows/travis-build.yaml | 24 +++++++++++++++ .github/workflows/trigger-compilation.yaml | 2 +- .github/workflows/trigger-pr.yaml | 35 ++++++++++++++++++++++ gama.annotations/pom.xml | 20 ++++++++++--- gama.parent/pom.xml | 12 ++++++++ gama.processor/pom.xml | 12 ++++++++ 6 files changed, 100 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/trigger-pr.yaml diff --git a/.github/workflows/travis-build.yaml b/.github/workflows/travis-build.yaml index f35c171054..8ba8b68283 100644 --- a/.github/workflows/travis-build.yaml +++ b/.github/workflows/travis-build.yaml @@ -27,6 +27,10 @@ on: required: false IS_STABLE_RELEASE: type: boolean + RUN_SPOTBUGS: + required: false + default: false + type: boolean secrets: GAMA_KEYSTORE_BASE64: required: false @@ -97,6 +101,26 @@ jobs: - name: Compiling gama run: bash $GITHUB_WORKSPACE/travis/build.sh -e -B ${{ inputs.mvn_extra_arguments }} + # Spotbugs + - name: Running SpotBugs + if: "${{ inputs.RUN_SPOTBUGS }}" + run: | + cd ${{ github.workspace }}/gama.annotations + mvn verify spotbugs:spotbugs + cd ${{ github.workspace }}/gama.processor + mvn verify spotbugs:spotbugs + cd ${{ github.workspace }}/gama.parent + + - uses: actions/upload-artifact@v4 + if: "${{ inputs.RUN_SPOTBUGS }}" + with: + name: result-spotbugs + if-no-files-found: error + compression-level: 9 + overwrite: true + path: | + ${{ github.workspace }}/**/spotbugsXml.xml + - name: Install SSH key # Consider it's a release and want to update p2 site for it if: "${{ inputs.get_all_archives_for_release }}" diff --git a/.github/workflows/trigger-compilation.yaml b/.github/workflows/trigger-compilation.yaml index b426dc95a5..8eba976b3b 100644 --- a/.github/workflows/trigger-compilation.yaml +++ b/.github/workflows/trigger-compilation.yaml @@ -15,7 +15,7 @@ on: jobs: - ci-handler: + ci-release: if: ${{ contains(github.event.head_commit.message, 'ci release') }} runs-on: ubuntu-latest steps: diff --git a/.github/workflows/trigger-pr.yaml b/.github/workflows/trigger-pr.yaml new file mode 100644 index 0000000000..741f3e9c2c --- /dev/null +++ b/.github/workflows/trigger-pr.yaml @@ -0,0 +1,35 @@ +# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created +# For more information see: https://github.com/actions/setup-java#apache-maven-with-a-settings-path + +name: "Pull Request validation" + +on: + # Triggers the workflow on pull request events + pull_request: + workflow_dispatch: # For manual trigger + +jobs: + + compiling-gama: + name: Compiling GAMA + uses: ./.github/workflows/travis-build.yaml + with: + get_testing_compiled_archives: false + get_all_archives_for_release: false + RUN_SPOTBUGS: true + + spotbugs-result: + name: Display Spotbugs results + runs-on: ubuntu-latest + needs: compiling-gama + steps: + - uses: actions/download-artifact@v4 + with: + name: result-spotbugs + + - name: Display structure of downloaded files + run: ls -lahR + + - uses: jwgmeligmeyling/spotbugs-github-action@master + with: + path: '**/spotbugsXml.xml' \ No newline at end of file diff --git a/gama.annotations/pom.xml b/gama.annotations/pom.xml index 50b3ac8c58..85f3be63b0 100644 --- a/gama.annotations/pom.xml +++ b/gama.annotations/pom.xml @@ -139,9 +139,9 @@ - org.apache.maven.plugins - maven-deploy-plugin - ${maven.plugins.version} + org.apache.maven.plugins + maven-deploy-plugin + ${maven.plugins.version} org.apache.maven.wagon @@ -154,7 +154,7 @@ org.apache.maven.plugins maven-compiler-plugin - ${maven-compiler-plugin.version} + ${maven-compiler-plugin.version} ${jdk.version} ${jdk.version} @@ -187,6 +187,18 @@ ${tycho.version} + + + com.github.spotbugs + spotbugs-maven-plugin + 4.8.4.0 + + true + false + + + eclipse-plugin diff --git a/gama.parent/pom.xml b/gama.parent/pom.xml index b117031295..d383fd3f7e 100644 --- a/gama.parent/pom.xml +++ b/gama.parent/pom.xml @@ -464,6 +464,18 @@ + + + + com.github.spotbugs + spotbugs-maven-plugin + 4.8.4.0 + + true + false + + diff --git a/gama.processor/pom.xml b/gama.processor/pom.xml index f95bd5d478..dad710fbae 100644 --- a/gama.processor/pom.xml +++ b/gama.processor/pom.xml @@ -190,6 +190,18 @@ target-platform-configuration ${tycho.version} + + + + com.github.spotbugs + spotbugs-maven-plugin + 4.8.4.0 + + true + false + + eclipse-plugin