From 900b4a6feae4888e1c82bb1cdba7ee51640b194a Mon Sep 17 00:00:00 2001 From: Lauri Tulmin Date: Tue, 9 Jul 2024 03:22:17 +0300 Subject: [PATCH] Build image for testing early jdk8 (#11594) --- .../pr-smoke-test-early-jdk8-images.yml | 35 ++++++++++++ .../publish-smoke-test-early-jdk8-images.yml | 53 +++++++++++++++++++ settings.gradle.kts | 1 + smoke-tests/images/early-jdk8/Dockerfile | 16 ++++++ .../images/early-jdk8/build.gradle.kts | 35 ++++++++++++ 5 files changed, 140 insertions(+) create mode 100644 .github/workflows/pr-smoke-test-early-jdk8-images.yml create mode 100644 .github/workflows/publish-smoke-test-early-jdk8-images.yml create mode 100644 smoke-tests/images/early-jdk8/Dockerfile create mode 100644 smoke-tests/images/early-jdk8/build.gradle.kts diff --git a/.github/workflows/pr-smoke-test-early-jdk8-images.yml b/.github/workflows/pr-smoke-test-early-jdk8-images.yml new file mode 100644 index 000000000000..2f5749cac24e --- /dev/null +++ b/.github/workflows/pr-smoke-test-early-jdk8-images.yml @@ -0,0 +1,35 @@ +name: PR build early jdk8 images for smoke tests + +on: + pull_request: + paths: + - "smoke-tests/images/early-jdk8/**" + - ".github/workflows/pr-smoke-test-early-jdk8-images.yml" + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: Free disk space + run: .github/scripts/gha-free-disk-space.sh + + - name: Set up JDK for running Gradle + uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 + with: + distribution: temurin + java-version-file: .java-version + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@d9336dac04dea2507a617466bc058a3def92b18b # v3.4.0 + with: + cache-read-only: true + # gradle enterprise is used for the build cache + gradle-home-cache-excludes: caches/build-cache-1 + + - name: Build Docker image + run: ./gradlew :smoke-tests:images:early-jdk8:imageBuild diff --git a/.github/workflows/publish-smoke-test-early-jdk8-images.yml b/.github/workflows/publish-smoke-test-early-jdk8-images.yml new file mode 100644 index 000000000000..dcaa3085e541 --- /dev/null +++ b/.github/workflows/publish-smoke-test-early-jdk8-images.yml @@ -0,0 +1,53 @@ +name: Publish early jdk8 images for smoke tests + +on: + push: + paths: + - "smoke-tests/images/early-jdk8/**" + - ".github/workflows/pr-smoke-test-early-jdk8-images.yml" + branches: + - main + workflow_dispatch: + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Free disk space + run: .github/scripts/gha-free-disk-space.sh + + - name: Set up JDK for running Gradle + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version-file: .java-version + + - name: Login to GitHub package registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set tag + run: echo "TAG=$(date '+%Y%m%d').$GITHUB_RUN_ID" >> $GITHUB_ENV + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@d9336dac04dea2507a617466bc058a3def92b18b # v3.4.0 + + - name: Build Docker image + run: ./gradlew :smoke-tests:images:early-jdk8:dockerPush -PextraTag=${{ env.TAG }} + + workflow-notification: + needs: + - publish + if: always() + uses: ./.github/workflows/reusable-workflow-notification.yml + with: + success: >- + ${{ + needs.publishLinux.result == 'success' && + needs.publishWindows.result == 'success' + }} diff --git a/settings.gradle.kts b/settings.gradle.kts index 828170472690..21bb245dc7df 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -145,6 +145,7 @@ include(":testing-common:library-for-integration-tests") // smoke tests include(":smoke-tests") +include(":smoke-tests:images:early-jdk8") include(":smoke-tests:images:fake-backend") include(":smoke-tests:images:grpc") include(":smoke-tests:images:play") diff --git a/smoke-tests/images/early-jdk8/Dockerfile b/smoke-tests/images/early-jdk8/Dockerfile new file mode 100644 index 000000000000..02c04ee4ac7e --- /dev/null +++ b/smoke-tests/images/early-jdk8/Dockerfile @@ -0,0 +1,16 @@ +# https://github.com/zulu-openjdk/zulu-openjdk/blob/master/ubuntu/8u412-8.78/Dockerfile +FROM ubuntu:jammy + +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' + +RUN apt-get -qq update && \ + apt-get -qq -y --no-install-recommends install software-properties-common locales curl tzdata unzip && \ + echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen && \ + locale-gen en_US.UTF-8 && \ + curl -sLO https://cdn.azul.com/zulu/bin/zulu1.8.0_31-8.5.0.1-x86lx64.zip && \ + unzip zulu1.8.0_31-8.5.0.1-x86lx64.zip -d /opt && \ + apt-get -qq -y purge --auto-remove software-properties-common curl unzip && \ + rm zulu1.8.0_31-8.5.0.1-x86lx64.zip + +ENV JAVA_HOME=/opt/zulu1.8.0_31-8.5.0.1-x86lx64 +ENV PATH="${PATH}:/opt/zulu1.8.0_31-8.5.0.1-x86lx64/bin" diff --git a/smoke-tests/images/early-jdk8/build.gradle.kts b/smoke-tests/images/early-jdk8/build.gradle.kts new file mode 100644 index 000000000000..d583cd6f53fd --- /dev/null +++ b/smoke-tests/images/early-jdk8/build.gradle.kts @@ -0,0 +1,35 @@ +import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage +import com.bmuschko.gradle.docker.tasks.image.DockerPushImage +import java.time.LocalDateTime +import java.time.format.DateTimeFormatter + +plugins { + id("com.bmuschko.docker-remote-api") +} + +val extraTag = findProperty("extraTag") + ?: DateTimeFormatter.ofPattern("yyyyMMdd.HHmmSS").format(LocalDateTime.now()) + +tasks { + val dockerWorkingDir = layout.buildDirectory.dir("docker") + + val imagePrepare by registering(Copy::class) { + into(dockerWorkingDir) + from("Dockerfile") + } + + val imageBuild by registering(DockerBuildImage::class) { + dependsOn(imagePrepare) + inputDir.set(dockerWorkingDir) + + images.add("ghcr.io/open-telemetry/opentelemetry-java-instrumentation/smoke-test-zulu-openjdk-8u31:$extraTag") + dockerFile.set(dockerWorkingDir.get().file("Dockerfile")) + } + + val dockerPush by registering(DockerPushImage::class) { + group = "publishing" + description = "Push all Docker images" + dependsOn(imageBuild) + images.add("ghcr.io/open-telemetry/opentelemetry-java-instrumentation/smoke-test-zulu-openjdk-8u31:$extraTag") + } +}