From 896c57273bf8ac1c44169478135cf5d2d2feba44 Mon Sep 17 00:00:00 2001 From: Holly Cummins Date: Mon, 12 Sep 2022 13:59:40 +0100 Subject: [PATCH] Add Mac M1 to workflow configuration Preprocess the matrix to avoid running M1 jobs on forks --- .github/filter-jvm-tests-json.sh | 20 +++++++++ .github/matrix-jvm-tests.json | 36 +++++++++++++++ .github/workflows/ci-actions-incremental.yml | 46 ++++++-------------- 3 files changed, 69 insertions(+), 33 deletions(-) create mode 100755 .github/filter-jvm-tests-json.sh create mode 100644 .github/matrix-jvm-tests.json diff --git a/.github/filter-jvm-tests-json.sh b/.github/filter-jvm-tests-json.sh new file mode 100755 index 0000000000000..9ba5707a29639 --- /dev/null +++ b/.github/filter-jvm-tests-json.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +BASEDIR=$(dirname "$0") + +# Filter out mac os from a matrix of build configurations. +# The reason we do this is that running mac on a fork won't work; the fork won't have a self-hosted runner + +# See https://stackoverflow.com/questions/65384420/how-to-make-a-github-action-matrix-element-conditional + +repoName=${GITHUB_REPOSITORY} + +if [[ $repoName == "quarkusio/quarkus" ]] +then + matrix=$(cat $BASEDIR/matrix-jvm-tests.json) +else + # Use jq to read in a json file that represents the matrix configuration. + matrix=$(jq 'map(. | select(.["os-name"]!="macos-arm64-latest"))' $BASEDIR/matrix-jvm-tests.json) +fi + +echo \{java: ${matrix}\} \ No newline at end of file diff --git a/.github/matrix-jvm-tests.json b/.github/matrix-jvm-tests.json new file mode 100644 index 0000000000000..146e3d8559c0c --- /dev/null +++ b/.github/matrix-jvm-tests.json @@ -0,0 +1,36 @@ +[ { + "name": "11", + "java-version": 11, + "maven_args": "$JVM_TEST_MAVEN_ARGS", + "maven_opts": "-Xmx2g -XX:MaxMetaspaceSize=1g", + "os-name": "ubuntu-latest" +} +, { + "name": "17", + "java-version": 17, + "maven_args": "$JVM_TEST_MAVEN_ARGS", + "maven_opts": "-Xmx2g -XX:MaxMetaspaceSize=1g", + "os-name": "ubuntu-latest" +} +, { + "name": "18", + "java-version": 18, + "maven_args": "$JVM_TEST_MAVEN_ARGS", + "maven_opts": "-Xmx2g -XX:MaxMetaspaceSize=1g", + "os-name": "ubuntu-latest" +} +, { + "name": "11 Windows", + "java-version": 11, + "maven_args": "-DskipDocs -Dformat.skip", + "maven_opts": "-Xmx2g -XX:MaxMetaspaceSize=1g -Xlog:gc*=debug:file=windows-java-11.txt", + "os-name": "windows-latest" +} +, { + "name": "17 MacOS M1", + "java-version": 17, + "maven_args": "-DskipDocs -Dformat.skip", + "maven_opts": "-Xmx2g -XX:MaxMetaspaceSize=1g", + "architecture": "aarch64", + "os-name": "macos-arm64-latest" +}] diff --git a/.github/workflows/ci-actions-incremental.yml b/.github/workflows/ci-actions-incremental.yml index f8f1b5253b0f2..eb5f7157ff8be 100644 --- a/.github/workflows/ci-actions-incremental.yml +++ b/.github/workflows/ci-actions-incremental.yml @@ -222,6 +222,7 @@ jobs: GIB_IMPACTED_MODULES: ${{ needs.build-jdk11.outputs.gib_impacted }} outputs: native_matrix: ${{ steps.calc-native-matrix.outputs.matrix }} + jvm_matrix: ${{ steps.calc-jvm-matrix.outputs.matrix }} run_jvm: ${{ steps.calc-run-flags.outputs.run_jvm }} run_devtools: ${{ steps.calc-run-flags.outputs.run_devtools }} run_gradle: ${{ steps.calc-run-flags.outputs.run_gradle }} @@ -236,6 +237,12 @@ jobs: json=$(.github/filter-native-tests-json.sh "${GIB_IMPACTED_MODULES}" | tr -d '\n') echo "${json}" echo "::set-output name=matrix::${json}" + - name: Calculate matrix from matrix-jvm-tests.json + id: calc-jvm-matrix + run: | + json=$(.github/filter-jvm-tests-json.sh) + echo "${json}" + echo "::set-output name=matrix::${json}" - name: Calculate run flags id: calc-run-flags run: | @@ -267,40 +274,12 @@ jobs: MAVEN_OPTS: ${{ matrix.java.maven_opts }} strategy: fail-fast: false - matrix: - java: - - { - name: "11", - java-version: 11, - maven_args: "$JVM_TEST_MAVEN_ARGS", - maven_opts: "-Xmx2g -XX:MaxMetaspaceSize=1g", - os-name: "ubuntu-latest" - } - - { - name: "17", - java-version: 17, - maven_args: "$JVM_TEST_MAVEN_ARGS", - maven_opts: "-Xmx2g -XX:MaxMetaspaceSize=1g", - os-name: "ubuntu-latest" - } - - { - name: "18", - java-version: 18, - maven_args: "$JVM_TEST_MAVEN_ARGS", - maven_opts: "-Xmx2g -XX:MaxMetaspaceSize=1g", - os-name: "ubuntu-latest" - } - - { - name: "11 Windows", - java-version: 11, - maven_args: "-DskipDocs -Dformat.skip", - maven_opts: "-Xmx2g -XX:MaxMetaspaceSize=1g -Xlog:gc*=debug:file=windows-java-11.txt", - os-name: "windows-latest" - } + matrix: ${{ fromJson(needs.calculate-test-jobs.outputs.jvm_matrix) }} + steps: - name: Stop mysql - if: "!startsWith(matrix.java.os-name, 'windows')" + if: "!startsWith(matrix.java.os-name, 'windows') && !startsWith(matrix.java.os-name, 'macos')" shell: bash run: | ss -ln @@ -316,12 +295,12 @@ jobs: run: git remote add quarkusio https://github.com/quarkusio/quarkus.git - name: apt clean - if: "!startsWith(matrix.java.os-name, 'windows')" + if: "!startsWith(matrix.java.os-name, 'windows') && !startsWith(matrix.java.os-name, 'macos')" shell: bash run: sudo apt-get clean - name: Reclaim Disk Space - if: "!startsWith(matrix.java.os-name, 'windows')" + if: "!startsWith(matrix.java.os-name, 'windows') && !startsWith(matrix.java.os-name, 'macos')" run: .github/ci-prerequisites.sh - name: Set up JDK ${{ matrix.java.java-version }} @@ -329,6 +308,7 @@ jobs: with: distribution: temurin java-version: ${{ matrix.java.java-version }} + architecture: ${{ matrix.java.architecture || 'x64' }} - name: Download Maven Repo uses: actions/download-artifact@v3