From 054b09251189ddaf160ff926f882d78d57706dd4 Mon Sep 17 00:00:00 2001 From: Rishabh Gupta Date: Sat, 11 Nov 2023 01:30:49 +0530 Subject: [PATCH] Seggregated workflows --- .github/workflows/build.yml | 45 +++------------------------- .github/workflows/unit-test.yml | 53 +++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 41 deletions(-) create mode 100644 .github/workflows/unit-test.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6b2ef96..006fc26 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,13 +1,7 @@ name: Spring Boot Build on: - pull_request: - branch_protection_rule: - types: [created, deleted] - check_run: - types: - - created - - rerequested + workflow_call: jobs: gradle-build: @@ -17,36 +11,13 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - - name: Cache Gradle dependencies - uses: actions/cache@v2 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} - restore-keys: | - gradle-${{ runner.os }}- - - name: Set up JDK 20.0.1 uses: actions/setup-java@v1 with: java-version: 20.0.1 - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - - name: Build with Gradle - run: ./gradlew build --stacktrace - - unit-test: - needs: gradle-build - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Cache Gradle dependencies + id: gradle-cache uses: actions/cache@v2 with: path: | @@ -56,16 +27,8 @@ jobs: restore-keys: | gradle-${{ runner.os }}- - - name: Set up JDK 20.0.1 - uses: actions/setup-java@v1 - with: - java-version: 20.0.1 - - name: Grant execute permission for gradlew run: chmod +x gradlew - - name: Use cached Gradle build - run: ./gradlew assemble --stacktrace - - - name: Run Tests - run: ./gradlew test --stacktrace + - name: Build with Gradle + run: ./gradlew build --stacktrace \ No newline at end of file diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml new file mode 100644 index 0000000..da0f106 --- /dev/null +++ b/.github/workflows/unit-test.yml @@ -0,0 +1,53 @@ +name: Spring Boot Unit Tests + +on: + pull_request: + branch_protection_rule: + types: [ created, deleted ] + check_run: + types: + - created + - rerequested + +jobs: + unit-test: + runs-on: ubuntu-latest + + outputs: + job-status: ${{ steps.run-tests.outputs.job-status }} + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up JDK 20.0.1 + uses: actions/setup-java@v1 + with: + java-version: 20.0.1 + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Restore Gradle build caches + id: gradle-cache-restore + uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + gradle-${{ runner.os }}- + + - name: Checkout code + if: steps.gradle-cache-restore.outputs.cache-hit != 'true' + uses: actions/checkout@v2 + + - name: Rerun build job + if: steps.gradle-cache-restore.outputs.cache-hit != 'true' + uses: ./.github/workflow/build.yml + continue-on-error: false + + - name: Run Tests + id: run-tests + run: ./gradlew test --stacktrace