From e3120981df4c55f8b9b9724e76a3b1b9a0c67cfa Mon Sep 17 00:00:00 2001 From: David Nestorovic Date: Thu, 10 Aug 2023 14:18:15 +0200 Subject: [PATCH] Add concurrency in maven and gradle functional testing workflows --- .../workflows/test-native-gradle-plugin.yml | 48 +++++++++++++------ .../workflows/test-native-maven-plugin.yml | 32 ++++++++++--- build-logic/common-plugins/build.gradle.kts | 1 + ...graalvm.build.github-actions-helper.gradle | 37 ++++++++++++++ native-gradle-plugin/build.gradle | 1 + native-maven-plugin/build.gradle.kts | 1 + 6 files changed, 99 insertions(+), 21 deletions(-) create mode 100644 build-logic/common-plugins/src/main/groovy/org.graalvm.build.github-actions-helper.gradle diff --git a/.github/workflows/test-native-gradle-plugin.yml b/.github/workflows/test-native-gradle-plugin.yml index 2035f2ee5..e8bc21dd7 100644 --- a/.github/workflows/test-native-gradle-plugin.yml +++ b/.github/workflows/test-native-gradle-plugin.yml @@ -22,14 +22,34 @@ concurrency: cancel-in-progress: ${{ github.event_name == 'pull_request' || github.repository != 'graalvm/native-build-tools' }} jobs: + populate-matrix: + name: "Set matrix" + runs-on: "ubuntu-20.04" + timeout-minutes: 5 + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - name: "☁️ Checkout repository" + uses: actions/checkout@v3 + - name: "πŸ”§ Prepare environment" + uses: graalvm/setup-graalvm@v1 + with: + java-version: '17' + distribution: 'graalvm' + github-token: ${{ secrets.GITHUB_TOKEN }} + - name: "πŸ•ΈοΈ Populate matrix" + id: set-matrix + run: | + ./gradlew :native-gradle-plugin:dumpFunctionalTestList + test-native-gradle-plugin: name: "Sanity checks" - runs-on: ${{ matrix.os }} + runs-on: "ubuntu-20.04" + timeout-minutes: 60 + needs: populate-matrix strategy: fail-fast: false - matrix: - java-version: [ 17 ] - os: [ ubuntu-20.04 ] + matrix: ${{fromJson(needs.populate-matrix.outputs.matrix)}} steps: - name: "☁️ Checkout repository" uses: actions/checkout@v3 @@ -45,6 +65,7 @@ jobs: with: name: unit-tests-results path: native-gradle-plugin/build/reports/tests/test/ + functional-testing-gradle-plugin-dev: name: "Functional testing (GraalVM Dev Build)" runs-on: ${{ matrix.os }} @@ -79,17 +100,13 @@ jobs: name: functional-tests-results-graalvm-dev path: native-gradle-plugin/build/reports/tests/functionalTest/ functional-testing-gradle-plugin: - name: "Functional testing" + name: "πŸ§ͺ Gradle: ${{ matrix.test }} on ${{ matrix.os }} with gradle version: ${{ matrix.gradle-version }}" runs-on: ${{ matrix.os }} + timeout-minutes: 60 + needs: populate-matrix strategy: fail-fast: false - matrix: - gradle-version: ["current", "7.4"] - gradle-config-cache-version: ["current", "8.0.1"] - # Following versions are disabled temporarily in order to speed up PR testing - # "7.3.3", "7.2", "7.1", "6.8.3" - java-version: [ 17 ] - os: [ ubuntu-20.04 ] + matrix: ${{fromJson(needs.populate-matrix.outputs.matrix)}} steps: - name: "☁️ Checkout repository" uses: actions/checkout@v3 @@ -98,9 +115,9 @@ jobs: java-version: ${{ matrix.java-version }} github-token: ${{ secrets.GITHUB_TOKEN }} - name: "❓ Check and test the plugin" - run: ./gradlew :native-gradle-plugin:functionalTest -DgradleVersion=${{ matrix.gradle-version }} + run: ./gradlew :native-gradle-plugin:functionalTest -DgradleVersion=${{ matrix.gradle-version }} --tests ${{ matrix.test }} - name: "❓ Check and test the plugin with configuration cache" - run: ./gradlew :native-gradle-plugin:configCacheFunctionalTest -DgradleVersion=${{ matrix.gradle-config-cache-version }} + run: ./gradlew :native-gradle-plugin:configCacheFunctionalTest -DgradleVersion=${{ matrix.gradle-config-cache-version }} --tests ${{ matrix.test }} - name: "πŸ“œ Upload functional tests results" if: always() uses: actions/upload-artifact@v2 @@ -111,6 +128,7 @@ jobs: name: "Windows Gradle plugin functional testing" if: ${{ false }} # Disabled due to https://github.com/gradle/native-platform/issues/274 + needs: populate-matrix runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -128,7 +146,7 @@ jobs: run: ./gradlew :native-gradle-plugin:functionalTest --no-daemon --fail-fast - name: "πŸ“œ Upload tests results" if: always() - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: windows-gradle-functional-tests-results path: native-gradle-plugin/build/reports/tests/ diff --git a/.github/workflows/test-native-maven-plugin.yml b/.github/workflows/test-native-maven-plugin.yml index e8953121d..8932316bc 100644 --- a/.github/workflows/test-native-maven-plugin.yml +++ b/.github/workflows/test-native-maven-plugin.yml @@ -22,14 +22,34 @@ concurrency: cancel-in-progress: ${{ github.event_name == 'pull_request' || github.repository != 'graalvm/native-build-tools' }} jobs: + populate-matrix: + name: "Set matrix" + runs-on: "ubuntu-20.04" + timeout-minutes: 5 + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - name: "☁️ Checkout repository" + uses: actions/checkout@v3 + - name: "πŸ”§ Prepare environment" + uses: graalvm/setup-graalvm@v1 + with: + java-version: '17' + distribution: 'graalvm' + github-token: ${{ secrets.GITHUB_TOKEN }} + - name: "πŸ•ΈοΈ Populate matrix" + id: set-matrix + run: | + ./gradlew :native-maven-plugin:dumpFunctionalTestList + test-native-maven-plugin: - name: "Maven plugin tests" + name: "πŸ§ͺ Maven: ${{ matrix.test }} on ${{ matrix.os }}" runs-on: ${{ matrix.os }} + timeout-minutes: 60 + needs: populate-matrix strategy: fail-fast: false - matrix: - java-version: [ 17 ] - os: [ ubuntu-20.04 ] + matrix: ${{fromJson(needs.populate-matrix.outputs.matrix)}} steps: - name: "☁️ Checkout repository" uses: actions/checkout@v3 @@ -38,7 +58,7 @@ jobs: java-version: ${{ matrix.java-version }} github-token: ${{ secrets.GITHUB_TOKEN }} - name: "❓ Check and test the plugin" - run: ./gradlew :native-maven-plugin:check --no-daemon + run: ./gradlew :native-maven-plugin:functionalTest --no-daemon --fail-fast --tests ${{ matrix.test }} - name: "πŸ“œ Upload unit test results" if: always() uses: actions/upload-artifact@v2 @@ -66,7 +86,7 @@ jobs: run: ./gradlew :native-maven-plugin:functionalTest --no-daemon --fail-fast - name: "πŸ“œ Upload tests results" if: always() - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: windows-maven-functional-tests-results path: native-maven-plugin/build/reports/tests/ diff --git a/build-logic/common-plugins/build.gradle.kts b/build-logic/common-plugins/build.gradle.kts index e1fc239a9..424902864 100644 --- a/build-logic/common-plugins/build.gradle.kts +++ b/build-logic/common-plugins/build.gradle.kts @@ -41,6 +41,7 @@ plugins { `kotlin-dsl` + `groovy-gradle-plugin` } repositories { diff --git a/build-logic/common-plugins/src/main/groovy/org.graalvm.build.github-actions-helper.gradle b/build-logic/common-plugins/src/main/groovy/org.graalvm.build.github-actions-helper.gradle new file mode 100644 index 000000000..d2a6afd58 --- /dev/null +++ b/build-logic/common-plugins/src/main/groovy/org.graalvm.build.github-actions-helper.gradle @@ -0,0 +1,37 @@ +import groovy.json.JsonOutput + +import java.nio.file.Files + +def matrixDefault = [ + "gradle-version": ["current", "7.4"], + "gradle-config-cache-version": ["current", "8.0.1"], + // # Following versions are disabled temporarily in order to speed up PR testing "7.3.3", "7.2", "7.1", "6.8.3", + "java-version": [ "17" ], + "os": [ "ubuntu-20.04" ] +] + +sourceSets.configureEach { sourceSet -> + if (sourceSet.name == 'functionalTest') { + tasks.register("dumpFunctionalTestList") { + doLast { + def matrix = [ + test: [] + ] + matrix.putAll(matrixDefault) + sourceSet.allSource.each { + matrix.test << it.name.substring(0, it.name.lastIndexOf('.')) + } + + String githubOut = System.getenv("GITHUB_OUTPUT") + if (githubOut != null) { + new File(githubOut).withWriterAppend { + it.println "matrix=${JsonOutput.toJson(matrix)}" + } + } else { + println "Warning: GITHUB_OUTPUT environment variable not found" + } + println "Build Matrix: $matrix" + } + } + } +} diff --git a/native-gradle-plugin/build.gradle b/native-gradle-plugin/build.gradle index a7ad9b3b1..d5ce50d35 100644 --- a/native-gradle-plugin/build.gradle +++ b/native-gradle-plugin/build.gradle @@ -47,6 +47,7 @@ plugins { id 'org.graalvm.build.java' id 'org.graalvm.build.functional-testing' id 'org.graalvm.build.publishing' + id 'org.graalvm.build.github-actions-helper' } maven { diff --git a/native-maven-plugin/build.gradle.kts b/native-maven-plugin/build.gradle.kts index 83cc46db2..78032343d 100644 --- a/native-maven-plugin/build.gradle.kts +++ b/native-maven-plugin/build.gradle.kts @@ -51,6 +51,7 @@ plugins { id("org.graalvm.build.publishing") id("org.graalvm.build.maven-plugin") id("org.graalvm.build.maven-functional-testing") + id("org.graalvm.build.github-actions-helper") } maven {