diff --git a/.github/workflows/build-project.yml b/.github/workflows/build-project.yml new file mode 100644 index 00000000..620e7584 --- /dev/null +++ b/.github/workflows/build-project.yml @@ -0,0 +1,34 @@ +name: Build project + +on: + push: + pull_request: + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + java: [11, 17] + name: "Java ${{ matrix.java }} build" + steps: + - name: Checkout project + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + - name: Set up Java + uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0 + with: + distribution: "temurin" + java-version: "${{ matrix.java }}" + cache: "maven" + - name: Verify build + run: mvn -B verify + sonar: + needs: build + if: github.base_ref == 'main' && github.event_name == 'pull_request' + name: Prepare analysis context + uses: WrenSecurity/.github/.github/workflows/sonar-pull-prepare.yml@main + with: + pull_request: ${{ toJSON(github.event.pull_request) }} \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index dd7faf69..00000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Build - -on: [push, pull_request] - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - java: [11, 17] - name: "Java ${{ matrix.java }} build" - steps: - - uses: actions/checkout@v4 - - name: Set up JDK - uses: actions/setup-java@v3 - with: - java-version: ${{ matrix.java }} - distribution: 'temurin' - - name: Cache Maven packages - uses: actions/cache@v3 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2 - - name: Run the Maven verify phase - run: mvn -B verify --file pom.xml diff --git a/.github/workflows/sonar-trigger.yml b/.github/workflows/sonar-trigger.yml new file mode 100644 index 00000000..2c807472 --- /dev/null +++ b/.github/workflows/sonar-trigger.yml @@ -0,0 +1,30 @@ +name: Trigger Sonar analysis + +on: + workflow_run: + workflows: + - Build project + types: + - completed + +permissions: + contents: read + +jobs: + prepare: + if: github.event.workflow_run.conclusion == 'success' + uses: WrenSecurity/.github/.github/workflows/sonar-prepare.yml@main + name: Prepare analysis context + with: + workflow_run: ${{ toJSON(github.event.workflow_run) }} + trigger: + needs: prepare + if: needs.prepare.outputs.sonar_allowed + name: Trigger Sonar analysis + uses: WrenSecurity/.github/.github/workflows/sonar-maven.yml@main + with: + java_version: 17 + project_key: 'WrenSecurity_wrenicf-java-framework' + pull_request: ${{ needs.prepare.outputs.pull_request }} + secrets: + sonar_token: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/pom.xml b/pom.xml index b2557754..79702531 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ org.wrensecurity wrensec-parent - 4.0.2 + 4.2.0 org.wrensecurity.wrenicf