From 1e567f3c6601cf70e577971de6b0cec5a18f28d4 Mon Sep 17 00:00:00 2001 From: Serhii Prodan <22973227+serpro69@users.noreply.github.com> Date: Sun, 10 Mar 2024 13:23:03 +0100 Subject: [PATCH] Fix gh workflows Use temurin distribution in actions/setup-java as recommended by the action docs. Split build.yml jobs into two since native image requires a custom java setup step. Update actions versions --- .github/workflows/build.yml | 67 ++++++++++++++++++++++---- .github/workflows/docs.yml | 6 +-- .github/workflows/publish_snapshot.yml | 30 ++++++++++-- Makefile | 6 ++- cli-bot/build.gradle.kts | 2 +- 5 files changed, 91 insertions(+), 20 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a23360555..ce9d8416d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,8 @@ name: Build +env: + GRAALCE_JDK_VERSION: "17.0.9" + on: push: branches: @@ -7,30 +10,74 @@ on: pull_request: jobs: - build: + libs: + name: test and build libs runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Set up JDK 8 - uses: actions/setup-java@v2 + + - name: Set up JDK 8 and 17 # we need both because graal plugin in cli-bot requires jdk version >= 11 + uses: actions/setup-java@v4 with: - java-version: '8' - distribution: 'adopt' + java-version: | + 8 + 17 + distribution: 'temurin' + - name: Gradle Wrapper Validation uses: gradle/wrapper-validation-action@v1.0.4 + - name: Grant execute permission for gradlew run: chmod +x gradlew + - name: Build with Gradle - run: ./gradlew clean test integrationTest build nativeCompile + run: ./gradlew clean test integrationTest build shadowJar + + cli: + name: build and test native image + runs-on: ubuntu-latest + needs: libs + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + # loosely based on https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#installing-java-from-local-file + - name: Fetch latest graalce JDK + id: fetch_latest_jdk + run: | + jdk_version=${{ env.GRAALCE_JDK_VERSION }} + cd $RUNNER_TEMP + latest_jdk_download_url="https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-${jdk_version}/graalvm-community-jdk-${jdk_version}_linux-x64_bin.tar.gz" + echo "$latest_jdk_download_url" + curl -Ls "$latest_jdk_download_url" -o java_package.tar.gz + echo "java_version=$jdk_version" >> "$GITHUB_OUTPUT" + + - name: Set up GraalCE JDK + uses: actions/setup-java@v4 + with: + distribution: 'jdkfile' + jdkFile: ${{ runner.temp }}/java_package.tar.gz + java-version: ${{ steps.fetch_latest_jdk.outputs.java_version }} + architecture: x64 + + - name: Gradle Wrapper Validation + uses: gradle/wrapper-validation-action@v1.0.4 + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Compile native image + run: ./gradlew nativeCompile - name: Test native image run: | # run several iterations to test various pathways when generating data for i in {0..10}; do - ./cli-bot/build/native/nativeCompile/faker-bot list --verbose >/dev/null || false - ./cli-bot/build/native/nativeCompile/faker-bot lookup a --verbose >/dev/null || false + ./cli-bot/build/native/nativeCompile/faker-bot list --verbose >/dev/null || false + ./cli-bot/build/native/nativeCompile/faker-bot lookup a --verbose >/dev/null || false done - diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 0e3a1470f..147f9ba1b 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -40,14 +40,14 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up JDK 8 - uses: actions/setup-java@v2 + uses: actions/setup-java@v4 with: java-version: '8' - distribution: 'adopt' + distribution: 'temurin' - name: Deploy Docs run: make deploy-docs env: diff --git a/.github/workflows/publish_snapshot.yml b/.github/workflows/publish_snapshot.yml index a1ac3a141..65797b94f 100644 --- a/.github/workflows/publish_snapshot.yml +++ b/.github/workflows/publish_snapshot.yml @@ -1,5 +1,8 @@ name: Publish Snapshot +env: + GRAALCE_JDK_VERSION: 17.0.9 + on: push: branches: @@ -28,14 +31,33 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 0 + # loosely based on https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#installing-java-from-local-file + - name: Fetch latest graalce JDK + id: fetch_latest_jdk + run: | + jdk_version=${{ env.GRAALCE_JDK_VERSION }} + cd $RUNNER_TEMP + latest_jdk_download_url="https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-${jdk_version}/graalvm-community-jdk-${jdk_version}_linux-x64_bin.tar.gz" + echo "$latest_jdk_download_url" + curl -Ls "$latest_jdk_download_url" -o java_package.tar.gz + echo "java_version=$jdk_version" >> "$GITHUB_OUTPUT" + - name: Set up GraalCE JDK + uses: actions/setup-java@v4 + with: + distribution: 'jdkfile' + jdkFile: ${{ runner.temp }}/java_package.tar.gz + java-version: ${{ steps.fetch_latest_jdk.outputs.java_version }} + architecture: x64 - name: Set up JDK 8 - uses: actions/setup-java@v2 + uses: actions/setup-java@v4 with: - java-version: '8' - distribution: 'adopt' + java-version: | + 8 + 17 + distribution: 'temurin' - name: Gradle Wrapper Validation uses: gradle/wrapper-validation-action@v1.0.4 - name: Grant execute permission to scripts diff --git a/Makefile b/Makefile index 46f1bfe8f..c7ee85853 100644 --- a/Makefile +++ b/Makefile @@ -16,12 +16,14 @@ __check_defined = \ $(if $(value $1),, \ $(error Undefined $1$(if $2, ($2)))) -__java_version_ok := $(shell java -version 2>&1|grep 1.8.0 >/dev/null; printf $$?) +# use java 17 to build because 'org.graalvm.buildtools.native' in cli-bot requires java version >= 11 +# both the libs and the cli app use java toolchains and will be built with java compatibility of version 8 +__java_version_ok := $(shell java -version 2>&1|grep '17.0' >/dev/null; printf $$?) .PHONY: check_java check_java: ## check current java version (mostly used in other targets) ifneq ($(__java_version_ok),$(shell echo 0)) - $(error "Expected java 1.8") + $(error "Expected java 17") endif .PHONY: deploy-docs diff --git a/cli-bot/build.gradle.kts b/cli-bot/build.gradle.kts index 8304a33f0..c3c22e465 100644 --- a/cli-bot/build.gradle.kts +++ b/cli-bot/build.gradle.kts @@ -1,5 +1,5 @@ -import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import com.adarshr.gradle.testlogger.theme.ThemeType +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar plugins { application