From 55950202e663899523ddc37adc992493351bfec8 Mon Sep 17 00:00:00 2001 From: Daz DeBoer Date: Thu, 28 Oct 2021 14:11:50 -0600 Subject: [PATCH] Switch to use gradle-build-action This improves the 'testing' GitHub actions workflow in a number of ways: - Use 'gradle-build-action' to invoke Gradle, to optimize caching of Gradle User Home between jobs - Run each test build and the codenarc builds in parallel --- .github/workflows/testing.sh | 15 ---------- .github/workflows/testing.yml | 56 ++++++++++++++++++++++++++++------- 2 files changed, 46 insertions(+), 25 deletions(-) delete mode 100755 .github/workflows/testing.sh diff --git a/.github/workflows/testing.sh b/.github/workflows/testing.sh deleted file mode 100755 index 4f8300e0..00000000 --- a/.github/workflows/testing.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -set -eu -o pipefail - -export GRADLE_OPTS="-Xms128m" - -./gradlew clean assemble -x signArchives test --tests com.google.protobuf.gradle.ProtobufJavaPluginTest --stacktrace -./gradlew test --tests com.google.protobuf.gradle.ProtobufKotlinDslCopySpecTest --stacktrace -./gradlew test --tests com.google.protobuf.gradle.ProtobufKotlinDslPluginTest --stacktrace -./gradlew test --tests com.google.protobuf.gradle.ProtobufAndroidPluginTest --stacktrace -./gradlew -stop -./gradlew test --tests com.google.protobuf.gradle.ProtobufAndroidPluginKotlinTest --stacktrace -./gradlew test --tests com.google.protobuf.gradle.AndroidProjectDetectionTest --stacktrace -./gradlew codenarcMain || (cat ./build/reports/codenarc/main.txt && false) -./gradlew codenarcTest || (cat ./build/reports/codenarc/test.txt && false) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 741aae1d..b9922310 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -9,17 +9,53 @@ on: permissions: contents: read +env: + GRADLE_OPTS: "-Xms128m" + jobs: - tests: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v2 + with: + java-version: '8' + distribution: 'temurin' + - uses: gradle/gradle-build-action@v2 + with: + arguments: clean assemble -x signArchives --stacktrace + + test: + needs: build + strategy: + matrix: + tests: [ProtobufJavaPluginTest, ProtobufKotlinDslCopySpecTest, ProtobufKotlinDslPluginTest, ProtobufAndroidPluginTest, ProtobufAndroidPluginKotlinTest, AndroidProjectDetectionTest] runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-java@v2 - with: - java-version: '8' - distribution: 'temurin' - cache: 'gradle' + - uses: actions/checkout@v2 + - uses: actions/setup-java@v2 + with: + java-version: '8' + distribution: 'temurin' + - uses: gradle/gradle-build-action@v2 + with: + arguments: test --tests ${{ matrix.tests }} --stacktrace - - name: Build - run: .github/workflows/testing.sh + codenarc: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v2 + with: + java-version: '8' + distribution: 'temurin' + - uses: gradle/gradle-build-action@v2 + with: + arguments: codenarcMain codenarcTest --continue + - name: echo codenarcMain reports + if: failure() + run: test -f build/reports/codenarc/main.txt && cat build/reports/codenarc/main.txt + - name: echo codenarcTest reports + if: failure() + run: test -f build/reports/codenarc/test.txt && cat build/reports/codenarc/test.txt \ No newline at end of file