From d2d090a4c4a7d481f0da661803e2e65a15b99fd7 Mon Sep 17 00:00:00 2001 From: John Freeman Date: Mon, 1 Aug 2022 16:41:14 +0100 Subject: [PATCH] Refactored to reuse workflows To remove duplicate workflow config. --- .github/workflows/maven-build.yml | 51 +++++++++++++++++++++++++++++++ .github/workflows/verify.yml | 44 ++------------------------ 2 files changed, 54 insertions(+), 41 deletions(-) create mode 100644 .github/workflows/maven-build.yml diff --git a/.github/workflows/maven-build.yml b/.github/workflows/maven-build.yml new file mode 100644 index 00000000..d6c83a34 --- /dev/null +++ b/.github/workflows/maven-build.yml @@ -0,0 +1,51 @@ +name: Maven build +on: + workflow_call: +env: + JAVA_TOOL_OPTIONS: >- + -XX:TieredStopAtLevel=1 + -XX:+UseParallelGC + -Dstyle.color=always + -Djansi.force=true + +jobs: + build: + name: Maven build + runs-on: ubuntu-20.04 + strategy: + matrix: + maven-version: + - '3.3.9' + - '3.6.1' + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 2 + - name: Set up JDK + uses: actions/setup-java@v3 + with: + java-version: 8 + distribution: 'temurin' + # Since code changes to this project are infrequent, and most commits + # change the pom.xml, we cache by date interval rather than file hash. + - name: Calculate cache interval + run: | + leveler="$(wc -c <<< "$GITHUB_REPOSITORY")" + echo "::set-output name=CACHE_INTERVAL::$(date +%Y)-$(($(($leveler + $(date +%-j))) / 30))" + id: cache-interval + - name: Cache local Maven repository + uses: actions/cache@v3 + with: + path: | + ~/.m2/repository + !~/.m2/repository/com/github/gantsign/maven + key: ${{ runner.os }}-maven-${{ steps.cache-interval.outputs.CACHE_INTERVAL }} + - name: Build with Maven + run: .github/scripts/build.sh + env: + MAVEN_VERSION: ${{ matrix.maven-version }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Code coverage report + if: matrix.maven-version == '3.6.1' + uses: codecov/codecov-action@v3.1.0 diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index b2329571..bef142b0 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -11,52 +11,14 @@ env: -Djansi.force=true jobs: - build: - name: Maven build - runs-on: ubuntu-20.04 - strategy: - matrix: - maven-version: - - '3.3.9' - - '3.6.1' - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 2 - - name: Set up JDK - uses: actions/setup-java@v3 - with: - java-version: 8 - distribution: 'temurin' - # Since code changes to this project are infrequent, and most commits - # change the pom.xml, we cache by date interval rather than file hash. - - name: Calculate cache interval - run: | - leveler="$(wc -c <<< "$GITHUB_REPOSITORY")" - echo "::set-output name=CACHE_INTERVAL::$(date +%Y)-$(($(($leveler + $(date +%-j))) / 30))" - id: cache-interval - - name: Cache local Maven repository - uses: actions/cache@v3 - with: - path: | - ~/.m2/repository - !~/.m2/repository/com/github/gantsign/maven - key: ${{ runner.os }}-maven-${{ steps.cache-interval.outputs.CACHE_INTERVAL }} - - name: Build with Maven - run: .github/scripts/build.sh - env: - MAVEN_VERSION: ${{ matrix.maven-version }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Code coverage report - if: matrix.maven-version == '3.6.1' - uses: codecov/codecov-action@v3.1.0 + call-maven-build: + uses: './.github/workflows/maven-build.yml' build-all: if: ${{ always() }} name: Build (matrix) runs-on: ubuntu-20.04 - needs: build + needs: call-maven-build steps: - name: Check build matrix status run: "[[ '${{ needs.build.result }}' == 'success' ]] || exit 1"