From 6ae5ab9add9dafe2c522786275c3aa7b62bdd5d2 Mon Sep 17 00:00:00 2001 From: Tripti Tripathi Date: Tue, 19 Jul 2022 16:43:54 +0530 Subject: [PATCH 1/3] Github action for release having docker Image with Tag as version number --- .github/workflows/docker-tests.yml | 7 +++ .github/workflows/pr-build.yml | 2 + .github/workflows/release.yml | 47 +++++++++++++++++++ hypertrace-ingester/build.gradle.kts | 2 +- .../build.gradle.kts | 2 +- .../build.gradle.kts | 2 +- .../build.gradle.kts | 2 +- .../build.gradle.kts | 2 +- .../build.gradle.kts | 2 +- .../raw-spans-grouper/build.gradle.kts | 2 +- .../span-normalizer/build.gradle.kts | 2 +- 11 files changed, 64 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/docker-tests.yml b/.github/workflows/docker-tests.yml index 267cf5fb2..4f930b06c 100644 --- a/.github/workflows/docker-tests.yml +++ b/.github/workflows/docker-tests.yml @@ -36,10 +36,15 @@ jobs: gradle-packages-${{ runner.os }}-${{ github.job }} gradle-packages-${{ runner.os }} + - name: Show Github ENV variables + run: env | grep ^GITHUB + - name: Build with Gradle uses: hypertrace/github-actions/gradle@main with: args: dockerBuildImages + env: + IMAGE_TAG: ${GITHUB_SHA} - name: Verify hypertrace image working-directory: ./.github/workflows/hypertrace-ingester @@ -86,6 +91,8 @@ jobs: uses: hypertrace/github-actions/gradle@main with: args: dockerBuildImages + env: + IMAGE_TAG: ${GITHUB_SHA} - name: Verify hypertrace image working-directory: ./.github/workflows/hypertrace-ingester diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index f7e0a6787..871341411 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -83,6 +83,8 @@ jobs: uses: hypertrace/github-actions/gradle@main with: args: build dockerBuildImages + env: + IMAGE_TAG: ${GITHUB_SHA} - name: push docker image uses: hypertrace/github-actions/gradle@main diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..6d5157eb9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,47 @@ +name: Release artifacts +on: +# Will run when a comment is added in PR e.g. /release v0.6.40-0.1.0-beta.1 + issue_comment: + types: [ created ] + workflow_dispatch: + +jobs: + publish-artifacts: + if: contains(github.event.comment.html_url, '/pull') && startsWith(github.event.comment.body, '/release v') + runs-on: ubuntu-20.04 + steps: + # Set fetch-depth: 0 to fetch commit history and tags for use in version calculation + - name: Check out code + uses: actions/checkout@v2.3.4 + with: + fetch-depth: 0 + + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.PUBLIC_DOCKER_USERNAME }} + password: ${{ secrets.PUBLIC_DOCKER_PASSWORD }} + + - name: Set ENV variable + env: + RELEASE_VERSION_COMMENT: ${{ github.event.comment.body }} + run: | + echo "VERSION=${RELEASE_VERSION_COMMENT##/release\ v}" >> $GITHUB_ENV + echo "Setting tag version: ${VERSION}" + + - name: Build with Gradle + uses: hypertrace/github-actions/gradle@main + with: + args: build dockerBuildImages + env: + DOCKER_USERNAME: ${{ secrets.PUBLIC_DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.PUBLIC_DOCKER_PASSWORD }} + IMAGE_TAG: ${{ env.VERSION }} + + - name: push docker image + uses: hypertrace/github-actions/gradle@main + with: + args: dockerPushImages + env: + DOCKER_USERNAME: ${{ secrets.PUBLIC_DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.PUBLIC_DOCKER_PASSWORD }} \ No newline at end of file diff --git a/hypertrace-ingester/build.gradle.kts b/hypertrace-ingester/build.gradle.kts index e2071cc04..5d7f21e74 100644 --- a/hypertrace-ingester/build.gradle.kts +++ b/hypertrace-ingester/build.gradle.kts @@ -24,7 +24,7 @@ hypertraceDocker { } namespace.set("razorpay") } - tag("${project.name}" + "_" + getCommitHash()) + tag("${project.name}" + "_" + System.getenv("IMAGE_TAG")) } dependencies { diff --git a/hypertrace-metrics-exporter/hypertrace-metrics-exporter/build.gradle.kts b/hypertrace-metrics-exporter/hypertrace-metrics-exporter/build.gradle.kts index e647c60db..8d48ee28d 100644 --- a/hypertrace-metrics-exporter/hypertrace-metrics-exporter/build.gradle.kts +++ b/hypertrace-metrics-exporter/hypertrace-metrics-exporter/build.gradle.kts @@ -20,7 +20,7 @@ hypertraceDocker { } namespace.set("razorpay") } - tag("${project.name}" + "_" + getCommitHash()) + tag("${project.name}" + "_" + System.getenv("IMAGE_TAG")) } fun getCommitHash(): String { diff --git a/hypertrace-metrics-generator/hypertrace-metrics-generator/build.gradle.kts b/hypertrace-metrics-generator/hypertrace-metrics-generator/build.gradle.kts index 815dcead2..44a103bda 100644 --- a/hypertrace-metrics-generator/hypertrace-metrics-generator/build.gradle.kts +++ b/hypertrace-metrics-generator/hypertrace-metrics-generator/build.gradle.kts @@ -20,7 +20,7 @@ hypertraceDocker { } namespace.set("razorpay") } - tag("${project.name}" + "_" + getCommitHash()) + tag("${project.name}" + "_" + System.getenv("IMAGE_TAG")) } fun getCommitHash(): String { diff --git a/hypertrace-metrics-processor/hypertrace-metrics-processor/build.gradle.kts b/hypertrace-metrics-processor/hypertrace-metrics-processor/build.gradle.kts index 5bab16278..515c0d46b 100644 --- a/hypertrace-metrics-processor/hypertrace-metrics-processor/build.gradle.kts +++ b/hypertrace-metrics-processor/hypertrace-metrics-processor/build.gradle.kts @@ -20,7 +20,7 @@ hypertraceDocker { } namespace.set("razorpay") } - tag("${project.name}" + "_" + getCommitHash()) + tag("${project.name}" + "_" + System.getenv("IMAGE_TAG")) } fun getCommitHash(): String { diff --git a/hypertrace-trace-enricher/hypertrace-trace-enricher/build.gradle.kts b/hypertrace-trace-enricher/hypertrace-trace-enricher/build.gradle.kts index a4e49e953..e3ab99d26 100644 --- a/hypertrace-trace-enricher/hypertrace-trace-enricher/build.gradle.kts +++ b/hypertrace-trace-enricher/hypertrace-trace-enricher/build.gradle.kts @@ -19,7 +19,7 @@ hypertraceDocker { } namespace.set("razorpay") } - tag("${project.name}" + "_" + getCommitHash()) + tag("${project.name}" + "_" + System.getenv("IMAGE_TAG")) } // Config for gw run to be able to run this locally. Just execute gw run here on Intellij or on the console. diff --git a/hypertrace-view-generator/hypertrace-view-generator/build.gradle.kts b/hypertrace-view-generator/hypertrace-view-generator/build.gradle.kts index 844ec8d58..b0f83ba55 100644 --- a/hypertrace-view-generator/hypertrace-view-generator/build.gradle.kts +++ b/hypertrace-view-generator/hypertrace-view-generator/build.gradle.kts @@ -20,7 +20,7 @@ hypertraceDocker { } namespace.set("razorpay") } - tag("${project.name}" + "_" + getCommitHash()) + tag("${project.name}" + "_" + System.getenv("IMAGE_TAG")) } tasks.test { diff --git a/raw-spans-grouper/raw-spans-grouper/build.gradle.kts b/raw-spans-grouper/raw-spans-grouper/build.gradle.kts index c85a778ab..c1ccb2a60 100644 --- a/raw-spans-grouper/raw-spans-grouper/build.gradle.kts +++ b/raw-spans-grouper/raw-spans-grouper/build.gradle.kts @@ -19,7 +19,7 @@ hypertraceDocker { } namespace.set("razorpay") } - tag("${project.name}" + "_" + getCommitHash()) + tag("${project.name}" + "_" + System.getenv("IMAGE_TAG")) } // Config for gw run to be able to run this locally. Just execute gw run here on Intellij or on the console. diff --git a/span-normalizer/span-normalizer/build.gradle.kts b/span-normalizer/span-normalizer/build.gradle.kts index f7b2515c4..da12aaa8c 100644 --- a/span-normalizer/span-normalizer/build.gradle.kts +++ b/span-normalizer/span-normalizer/build.gradle.kts @@ -20,7 +20,7 @@ hypertraceDocker { } namespace.set("razorpay") } - tag("${project.name}" + "_" + getCommitHash()) + tag("${project.name}" + "_" + System.getenv("IMAGE_TAG")) } // Config for gw run to be able to run this locally. Just execute gw run here on Intellij or on the console. From df6e02b56fb26af03be9ea2b6ca281c179d36943 Mon Sep 17 00:00:00 2001 From: Tripti Tripathi Date: Thu, 21 Jul 2022 15:37:13 +0530 Subject: [PATCH 2/3] getCommitHash() method removed --- hypertrace-ingester/build.gradle.kts | 9 +-------- .../hypertrace-metrics-exporter/build.gradle.kts | 9 +-------- .../hypertrace-metrics-generator/build.gradle.kts | 9 +-------- .../hypertrace-metrics-processor/build.gradle.kts | 9 +-------- .../hypertrace-trace-enricher/build.gradle.kts | 9 +-------- .../hypertrace-view-generator/build.gradle.kts | 9 +-------- raw-spans-grouper/raw-spans-grouper/build.gradle.kts | 9 --------- span-normalizer/span-normalizer/build.gradle.kts | 9 +-------- 8 files changed, 7 insertions(+), 65 deletions(-) diff --git a/hypertrace-ingester/build.gradle.kts b/hypertrace-ingester/build.gradle.kts index 5d7f21e74..cb2700e0a 100644 --- a/hypertrace-ingester/build.gradle.kts +++ b/hypertrace-ingester/build.gradle.kts @@ -168,11 +168,4 @@ tasks.register("createCopySpecForSubJobTest") { ).into("./build/resources/test/configs/") } -fun getCommitHash(): String { - val os = com.bmuschko.gradle.docker.shaded.org.apache.commons.io.output.ByteArrayOutputStream() - project.exec { - commandLine = "git rev-parse --verify HEAD".split(" ") - standardOutput = os - } - return String(os.toByteArray()).trim() -} + diff --git a/hypertrace-metrics-exporter/hypertrace-metrics-exporter/build.gradle.kts b/hypertrace-metrics-exporter/hypertrace-metrics-exporter/build.gradle.kts index 8d48ee28d..eff079c07 100644 --- a/hypertrace-metrics-exporter/hypertrace-metrics-exporter/build.gradle.kts +++ b/hypertrace-metrics-exporter/hypertrace-metrics-exporter/build.gradle.kts @@ -23,14 +23,7 @@ hypertraceDocker { tag("${project.name}" + "_" + System.getenv("IMAGE_TAG")) } -fun getCommitHash(): String { - val os = com.bmuschko.gradle.docker.shaded.org.apache.commons.io.output.ByteArrayOutputStream() - project.exec { - commandLine = "git rev-parse --verify HEAD".split(" ") - standardOutput = os - } - return String(os.toByteArray()).trim() -} + tasks.test { useJUnitPlatform() diff --git a/hypertrace-metrics-generator/hypertrace-metrics-generator/build.gradle.kts b/hypertrace-metrics-generator/hypertrace-metrics-generator/build.gradle.kts index 44a103bda..bfdbb7b57 100644 --- a/hypertrace-metrics-generator/hypertrace-metrics-generator/build.gradle.kts +++ b/hypertrace-metrics-generator/hypertrace-metrics-generator/build.gradle.kts @@ -23,14 +23,7 @@ hypertraceDocker { tag("${project.name}" + "_" + System.getenv("IMAGE_TAG")) } -fun getCommitHash(): String { - val os = com.bmuschko.gradle.docker.shaded.org.apache.commons.io.output.ByteArrayOutputStream() - project.exec { - commandLine = "git rev-parse --verify HEAD".split(" ") - standardOutput = os - } - return String(os.toByteArray()).trim() -} + tasks.test { useJUnitPlatform() diff --git a/hypertrace-metrics-processor/hypertrace-metrics-processor/build.gradle.kts b/hypertrace-metrics-processor/hypertrace-metrics-processor/build.gradle.kts index 515c0d46b..9ca72476d 100644 --- a/hypertrace-metrics-processor/hypertrace-metrics-processor/build.gradle.kts +++ b/hypertrace-metrics-processor/hypertrace-metrics-processor/build.gradle.kts @@ -23,14 +23,7 @@ hypertraceDocker { tag("${project.name}" + "_" + System.getenv("IMAGE_TAG")) } -fun getCommitHash(): String { - val os = com.bmuschko.gradle.docker.shaded.org.apache.commons.io.output.ByteArrayOutputStream() - project.exec { - commandLine = "git rev-parse --verify HEAD".split(" ") - standardOutput = os - } - return String(os.toByteArray()).trim() -} + tasks.test { useJUnitPlatform() diff --git a/hypertrace-trace-enricher/hypertrace-trace-enricher/build.gradle.kts b/hypertrace-trace-enricher/hypertrace-trace-enricher/build.gradle.kts index e3ab99d26..812ba03ae 100644 --- a/hypertrace-trace-enricher/hypertrace-trace-enricher/build.gradle.kts +++ b/hypertrace-trace-enricher/hypertrace-trace-enricher/build.gradle.kts @@ -67,11 +67,4 @@ dependencies { testImplementation("org.apache.kafka:kafka-streams-test-utils:6.0.1-ccs") } -fun getCommitHash(): String { - val os = com.bmuschko.gradle.docker.shaded.org.apache.commons.io.output.ByteArrayOutputStream() - project.exec { - commandLine = "git rev-parse --verify HEAD".split(" ") - standardOutput = os - } - return String(os.toByteArray()).trim() -} + diff --git a/hypertrace-view-generator/hypertrace-view-generator/build.gradle.kts b/hypertrace-view-generator/hypertrace-view-generator/build.gradle.kts index b0f83ba55..3f20c2495 100644 --- a/hypertrace-view-generator/hypertrace-view-generator/build.gradle.kts +++ b/hypertrace-view-generator/hypertrace-view-generator/build.gradle.kts @@ -50,11 +50,4 @@ dependencies { testImplementation("com.google.code.gson:gson:2.8.9") } -fun getCommitHash(): String { - val os = com.bmuschko.gradle.docker.shaded.org.apache.commons.io.output.ByteArrayOutputStream() - project.exec { - commandLine = "git rev-parse --verify HEAD".split(" ") - standardOutput = os - } - return String(os.toByteArray()).trim() -} + diff --git a/raw-spans-grouper/raw-spans-grouper/build.gradle.kts b/raw-spans-grouper/raw-spans-grouper/build.gradle.kts index c1ccb2a60..3cfa0d820 100644 --- a/raw-spans-grouper/raw-spans-grouper/build.gradle.kts +++ b/raw-spans-grouper/raw-spans-grouper/build.gradle.kts @@ -63,12 +63,3 @@ dependencies { testImplementation("org.junit-pioneer:junit-pioneer:1.3.8") testImplementation("org.apache.kafka:kafka-streams-test-utils:6.0.1-ccs") } - -fun getCommitHash(): String { - val os = com.bmuschko.gradle.docker.shaded.org.apache.commons.io.output.ByteArrayOutputStream() - project.exec { - commandLine = "git rev-parse --verify HEAD".split(" ") - standardOutput = os - } - return String(os.toByteArray()).trim() -} diff --git a/span-normalizer/span-normalizer/build.gradle.kts b/span-normalizer/span-normalizer/build.gradle.kts index da12aaa8c..5d3ed1e72 100644 --- a/span-normalizer/span-normalizer/build.gradle.kts +++ b/span-normalizer/span-normalizer/build.gradle.kts @@ -75,11 +75,4 @@ dependencies { testImplementation("org.apache.kafka:kafka-streams-test-utils:6.0.1-ccs") } -fun getCommitHash(): String { - val os = com.bmuschko.gradle.docker.shaded.org.apache.commons.io.output.ByteArrayOutputStream() - project.exec { - commandLine = "git rev-parse --verify HEAD".split(" ") - standardOutput = os - } - return String(os.toByteArray()).trim() -} + From 18316ecf5aefb2ec3d0578659f4b9c5cb80e4fd6 Mon Sep 17 00:00:00 2001 From: Tripti Tripathi Date: Fri, 22 Jul 2022 16:05:24 +0530 Subject: [PATCH 3/3] Fixes github action syntax issues --- .github/workflows/docker-tests.yml | 7 ++----- .github/workflows/pr-build.yml | 3 ++- hypertrace-ingester/build.gradle.kts | 2 -- .../hypertrace-metrics-exporter/build.gradle.kts | 2 -- .../hypertrace-metrics-generator/build.gradle.kts | 2 -- .../hypertrace-metrics-processor/build.gradle.kts | 2 -- .../hypertrace-trace-enricher/build.gradle.kts | 2 -- .../hypertrace-view-generator/build.gradle.kts | 2 -- span-normalizer/span-normalizer/build.gradle.kts | 2 -- 9 files changed, 4 insertions(+), 20 deletions(-) diff --git a/.github/workflows/docker-tests.yml b/.github/workflows/docker-tests.yml index 4f930b06c..c638f45c6 100644 --- a/.github/workflows/docker-tests.yml +++ b/.github/workflows/docker-tests.yml @@ -36,15 +36,12 @@ jobs: gradle-packages-${{ runner.os }}-${{ github.job }} gradle-packages-${{ runner.os }} - - name: Show Github ENV variables - run: env | grep ^GITHUB - - name: Build with Gradle uses: hypertrace/github-actions/gradle@main with: args: dockerBuildImages env: - IMAGE_TAG: ${GITHUB_SHA} + IMAGE_TAG: ${{ github.sha }} - name: Verify hypertrace image working-directory: ./.github/workflows/hypertrace-ingester @@ -92,7 +89,7 @@ jobs: with: args: dockerBuildImages env: - IMAGE_TAG: ${GITHUB_SHA} + IMAGE_TAG: ${{ github.sha }} - name: Verify hypertrace image working-directory: ./.github/workflows/hypertrace-ingester diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index 871341411..a96827381 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -84,7 +84,7 @@ jobs: with: args: build dockerBuildImages env: - IMAGE_TAG: ${GITHUB_SHA} + IMAGE_TAG: ${{ github.sha }} - name: push docker image uses: hypertrace/github-actions/gradle@main @@ -93,6 +93,7 @@ jobs: env: DOCKER_USERNAME: ${{ secrets.PUBLIC_DOCKER_USERNAME }} DOCKER_PASSWORD: ${{ secrets.PUBLIC_DOCKER_PASSWORD }} + IMAGE_TAG: ${{ github.sha }} # snyk-scan: # runs-on: ubuntu-20.04 diff --git a/hypertrace-ingester/build.gradle.kts b/hypertrace-ingester/build.gradle.kts index cb2700e0a..f7b46582c 100644 --- a/hypertrace-ingester/build.gradle.kts +++ b/hypertrace-ingester/build.gradle.kts @@ -167,5 +167,3 @@ tasks.register("createCopySpecForSubJobTest") { createCopySpecForSubJob("hypertrace-view-generator", "hypertrace-view-generator", "test") ).into("./build/resources/test/configs/") } - - diff --git a/hypertrace-metrics-exporter/hypertrace-metrics-exporter/build.gradle.kts b/hypertrace-metrics-exporter/hypertrace-metrics-exporter/build.gradle.kts index eff079c07..d99f1ecf1 100644 --- a/hypertrace-metrics-exporter/hypertrace-metrics-exporter/build.gradle.kts +++ b/hypertrace-metrics-exporter/hypertrace-metrics-exporter/build.gradle.kts @@ -23,8 +23,6 @@ hypertraceDocker { tag("${project.name}" + "_" + System.getenv("IMAGE_TAG")) } - - tasks.test { useJUnitPlatform() } diff --git a/hypertrace-metrics-generator/hypertrace-metrics-generator/build.gradle.kts b/hypertrace-metrics-generator/hypertrace-metrics-generator/build.gradle.kts index bfdbb7b57..f628d219d 100644 --- a/hypertrace-metrics-generator/hypertrace-metrics-generator/build.gradle.kts +++ b/hypertrace-metrics-generator/hypertrace-metrics-generator/build.gradle.kts @@ -23,8 +23,6 @@ hypertraceDocker { tag("${project.name}" + "_" + System.getenv("IMAGE_TAG")) } - - tasks.test { useJUnitPlatform() } diff --git a/hypertrace-metrics-processor/hypertrace-metrics-processor/build.gradle.kts b/hypertrace-metrics-processor/hypertrace-metrics-processor/build.gradle.kts index 9ca72476d..638323e82 100644 --- a/hypertrace-metrics-processor/hypertrace-metrics-processor/build.gradle.kts +++ b/hypertrace-metrics-processor/hypertrace-metrics-processor/build.gradle.kts @@ -23,8 +23,6 @@ hypertraceDocker { tag("${project.name}" + "_" + System.getenv("IMAGE_TAG")) } - - tasks.test { useJUnitPlatform() } diff --git a/hypertrace-trace-enricher/hypertrace-trace-enricher/build.gradle.kts b/hypertrace-trace-enricher/hypertrace-trace-enricher/build.gradle.kts index 812ba03ae..77f31e91b 100644 --- a/hypertrace-trace-enricher/hypertrace-trace-enricher/build.gradle.kts +++ b/hypertrace-trace-enricher/hypertrace-trace-enricher/build.gradle.kts @@ -66,5 +66,3 @@ dependencies { testImplementation("org.junit-pioneer:junit-pioneer:1.3.8") testImplementation("org.apache.kafka:kafka-streams-test-utils:6.0.1-ccs") } - - diff --git a/hypertrace-view-generator/hypertrace-view-generator/build.gradle.kts b/hypertrace-view-generator/hypertrace-view-generator/build.gradle.kts index 3f20c2495..757a5ffec 100644 --- a/hypertrace-view-generator/hypertrace-view-generator/build.gradle.kts +++ b/hypertrace-view-generator/hypertrace-view-generator/build.gradle.kts @@ -49,5 +49,3 @@ dependencies { testImplementation("org.mockito:mockito-core:3.8.0") testImplementation("com.google.code.gson:gson:2.8.9") } - - diff --git a/span-normalizer/span-normalizer/build.gradle.kts b/span-normalizer/span-normalizer/build.gradle.kts index 5d3ed1e72..b9ec9f13a 100644 --- a/span-normalizer/span-normalizer/build.gradle.kts +++ b/span-normalizer/span-normalizer/build.gradle.kts @@ -74,5 +74,3 @@ dependencies { testImplementation("org.mockito:mockito-core:3.8.0") testImplementation("org.apache.kafka:kafka-streams-test-utils:6.0.1-ccs") } - -