From d5c45b83f6f7b795b1ff9fe6b8820d2289e2704f Mon Sep 17 00:00:00 2001 From: Tomo Suzuki Date: Tue, 29 Mar 2022 15:09:27 -0400 Subject: [PATCH] test: verifying test, lint, clirr, and graalvm in checks (#456) * test: verifying test, lint, and clirr in checks * test: trying graalvm job-type with GraalVM 22.0.0.2 * ci: adding the new builds as required checks The following simple Python script can generate the list: for j in [8, 11]: for r in ["java-trace", "java-bigquery"]: for t in ["test", "lint", "clirr"]: print(' - "build (%s, %s, %s)"' % (j, r, t)) --- .github/sync-repo-settings.yaml | 13 ++++ ...ream.yaml => downstream-dependencies.yaml} | 10 ++- .../workflows/downstream-maven-plugins.yaml | 67 +++++++++++++++++++ .kokoro/client-library-check.sh | 23 +++++-- 4 files changed, 103 insertions(+), 10 deletions(-) rename .github/workflows/{downstream.yaml => downstream-dependencies.yaml} (70%) create mode 100644 .github/workflows/downstream-maven-plugins.yaml diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index c2d7ab05..c3a74079 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -46,6 +46,19 @@ branchProtectionRules: - "dependencies (11, java-spanner)" - "dependencies (11, java-storage)" - "dependencies (11, java-pubsub)" + - "build (8, java-trace, test)" + - "build (8, java-trace, lint)" + - "build (8, java-trace, clirr)" + - "build (8, java-bigquery, test)" + - "build (8, java-bigquery, lint)" + - "build (8, java-bigquery, clirr)" + - "build (11, java-trace, test)" + - "build (11, java-trace, lint)" + - "build (11, java-trace, clirr)" + - "build (11, java-bigquery, test)" + - "build (11, java-bigquery, lint)" + - "build (11, java-bigquery, clirr)" + - "graalvm (11, java-orgpolicy)" - "cla/google" - pattern: java7 # Can admins overwrite branch protection. diff --git a/.github/workflows/downstream.yaml b/.github/workflows/downstream-dependencies.yaml similarity index 70% rename from .github/workflows/downstream.yaml rename to .github/workflows/downstream-dependencies.yaml index 8992a599..58c60f9d 100644 --- a/.github/workflows/downstream.yaml +++ b/.github/workflows/downstream-dependencies.yaml @@ -18,14 +18,12 @@ jobs: - java-storage - java-pubsub steps: - - uses: actions/checkout@v2 - - uses: stCarolas/setup-maven@v4 - with: - maven-version: 3.8.1 - - uses: actions/setup-java@v1 + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 with: + distribution: zulu java-version: ${{matrix.java}} - run: java -version - run: sudo apt-get update -y - run: sudo apt-get install libxml2-utils - - run: .kokoro/client-library-check.sh ${{matrix.repo}} + - run: .kokoro/client-library-check.sh ${{matrix.repo}} dependencies diff --git a/.github/workflows/downstream-maven-plugins.yaml b/.github/workflows/downstream-maven-plugins.yaml new file mode 100644 index 00000000..e1544540 --- /dev/null +++ b/.github/workflows/downstream-maven-plugins.yaml @@ -0,0 +1,67 @@ +on: + push: + branches: + - main + pull_request: + +# Keeping this file separate as the dependencies check would use more +# repositories than needed this downstream check for GraalVM native image and +# other Maven plugins. +name: downstream +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + java: [8, 11] + repo: + # GAPIC library + - java-trace + # Handwritten library + - java-bigquery + job-type: + - test # maven-surefire-plugin + - lint # fmt-maven-plugin and google-java-format + - clirr # clirr-maven-plugin + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 + with: + distribution: zulu + java-version: ${{matrix.java}} + - run: java -version + - run: sudo apt-get update -y + - run: sudo apt-get install libxml2-utils + - run: .kokoro/client-library-check.sh ${{matrix.repo}} ${{matrix.job-type}} + + # GraalVM job ensures the compatibility of GraaVM version above and the + # native-maven-plugin version. + graalvm: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + java: [11] + repo: + # GAPIC library that doesn't use a real GCP project in integration tests + - java-orgpolicy + steps: + - uses: actions/checkout@v2 + - uses: stCarolas/setup-maven@v4 + with: + maven-version: 3.8.1 + - uses: ayltai/setup-graalvm@v1 + with: + java-version: ${{matrix.java}} + # When a new version of native-maven-plugin fails to run in a downstream + # library, it's likely to be an incompatibility with the GraalVM version. + # In that case, you need to upgrade the Docker container used in the + # tests in the downstream repositories (not just this value below). + # Example: https://github.com/googleapis/testing-infra-docker/pull/195 + graalvm-version: 22.0.0.2 + native-image: true + - run: java -version + - run: sudo apt-get update -y + - run: sudo apt-get install libxml2-utils + - run: .kokoro/client-library-check.sh ${{matrix.repo}} graalvm diff --git a/.kokoro/client-library-check.sh b/.kokoro/client-library-check.sh index 03cee53b..3cddeb10 100755 --- a/.kokoro/client-library-check.sh +++ b/.kokoro/client-library-check.sh @@ -21,12 +21,15 @@ set -eo pipefail # Display commands being run. set -x -if [[ $# -lt 1 ]]; +if [[ $# -ne 2 ]]; then - echo "Usage: $0 " + echo "Usage: $0 " + echo "where repo-name is java-XXX and check-type is dependencies, lint, or clirr" exit 1 fi REPO=$1 +# build.sh uses this environment variable +export JOB_TYPE=$2 ## Get the directory of the build script scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}")) @@ -61,5 +64,17 @@ set ${VERSION} save pom.xml EOF -# run dependencies script -.kokoro/dependencies.sh +case ${JOB_TYPE} in +dependencies) + .kokoro/dependencies.sh + RETURN_CODE=$? + ;; +*) + # This reads the JOB_TYPE environmental variable + .kokoro/build.sh + RETURN_CODE=$? + ;; +esac + +echo "exiting with ${RETURN_CODE}" +exit ${RETURN_CODE}