From 6443f61014bc587e5865fe83d6ea3c0f903ebf83 Mon Sep 17 00:00:00 2001 From: Swarali Bhalerao <75970656+Swarali-31@users.noreply.github.com> Date: Sun, 13 Oct 2024 13:13:51 +0530 Subject: [PATCH] Update build.yml --- .github/workflows/build.yml | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8178509e7258..2d56cb761e82 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,18 +1,30 @@ name: Build -on: [push, pull_request] + +on: + push: + branches: [ "main", "develop" ] # Specify the branches to trigger on + pull_request: + branches: [ "main", "develop" ] jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: Checkout code + uses: actions/checkout@v4 + - name: Set up JDK uses: actions/setup-java@v4 with: - java-version: 21 + java-version: '21' distribution: 'temurin' + - name: Build with Maven run: mvn --batch-mode --update-snapshots verify + + - name: Run tests + run: mvn test # Adding a test step + - name: Upload coverage to codecov (tokenless) if: >- github.event_name == 'pull_request' && @@ -20,6 +32,7 @@ jobs: uses: codecov/codecov-action@v4 with: fail_ci_if_error: true + - name: Upload coverage to codecov (with token) if: > github.repository == 'TheAlgorithms/Java' && @@ -29,9 +42,12 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} fail_ci_if_error: true + - name: Checkstyle run: mvn checkstyle:check + - name: SpotBugs run: mvn spotbugs:check + - name: PMD run: mvn pmd:check