From 1753285e2e7504efc040e282f596dfb31cf99d38 Mon Sep 17 00:00:00 2001 From: Jade Carino Date: Thu, 25 Jul 2024 14:56:32 +0100 Subject: [PATCH 1/4] Use new GHCR image Signed-off-by: Jade Carino --- .github/workflows/build.yaml | 2 +- .github/workflows/pr-build.yaml | 2 +- dockerfiles/dockerfile.framework | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index c452b8773..6ca7d32db 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -80,7 +80,7 @@ jobs: tags: ${{ steps.metadata.outputs.tags }} labels: ${{ steps.metadata.outputs.labels }} build-args: | - dockerRepository=harbor.galasa.dev + dockerRepository=ghcr.io tag=${{ env.IMAGE_TAG }} - name: Recycle application in ArgoCD diff --git a/.github/workflows/pr-build.yaml b/.github/workflows/pr-build.yaml index daaebcf21..ecca21426 100644 --- a/.github/workflows/pr-build.yaml +++ b/.github/workflows/pr-build.yaml @@ -56,7 +56,7 @@ jobs: load: true tags: framework:test build-args: | - dockerRepository=harbor.galasa.dev + dockerRepository=ghcr.io tag=main build-rest-api-documentation: diff --git a/dockerfiles/dockerfile.framework b/dockerfiles/dockerfile.framework index 0117c43ff..4077eacab 100644 --- a/dockerfiles/dockerfile.framework +++ b/dockerfiles/dockerfile.framework @@ -1,6 +1,6 @@ ARG dockerRepository ARG tag -FROM ${dockerRepository}/galasadev/galasa-maven:${tag} +FROM ${dockerRepository}/galasa-dev/maven-maven-artefacts:${tag} COPY repo/ /usr/local/apache2/htdocs/ COPY framework.githash /usr/local/apache2/htdocs/framework.githash From 72f7f291ad74b0dd9e5f825775b71626248193c1 Mon Sep 17 00:00:00 2001 From: Jade Carino Date: Wed, 14 Aug 2024 14:10:28 +0100 Subject: [PATCH 2/4] Parameterise main build workflow to support any branch/tag Signed-off-by: Jade Carino --- .github/workflows/build.yaml | 70 +++++++++++++++++++++++++++++++----- 1 file changed, 61 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index a67ccec19..cfb723696 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -2,15 +2,41 @@ name: Main build on: workflow_dispatch: + inputs: + jacocoEnabled: + description: 'Enable Jacoco code coverage (set to "false" for release builds)' + required: true + default: 'true' + type: choice + options: + - 'true' + - 'false' + isMainOrRelease: + description: 'This build is for the main branch or a release (set to "false" for development branch builds)' + required: true + default: 'true' + type: choice + options: + - 'true' + - 'false' push: branches: [main] env: REGISTRY: ghcr.io NAMESPACE: galasa-dev - IMAGE_TAG: main + BRANCH: ${{ github.ref_name }} + ARGO_APP_BRANCH: gh # TODO: remove this parameter and just use env.BRANCH once we update development.galasa.dev/main with these workflows. jobs: + log-github-ref: + name: Log the GitHub ref this workflow is running on (Branch or tag that received dispatch) + runs-on: ubuntu-latest + steps: + - name: Log GitHub ref of workflow + run: | + echo "This workflow is running on GitHub ref ${{ env.BRANCH }}" + build-framework: name: Build Framework using openapi2beans and gradle runs-on: ubuntu-latest @@ -36,13 +62,14 @@ jobs: - name: Build servlet beans with openapi2beans run: | - docker run --rm -v ${{ github.workspace }}:/var/workspace ghcr.io/${{env.NAMESPACE}}/openapi2beans:main generate --yaml var/workspace/${{ env.YAML_LOCATION }} --output var/workspace/${{ env.OUTPUT_LOCATION }} --package ${{ env.PACKAGE }} + docker run --rm -v ${{ github.workspace }}:/var/workspace ghcr.io/galasa-dev/openapi2beans:main generate --yaml var/workspace/${{ env.YAML_LOCATION }} --output var/workspace/${{ env.OUTPUT_LOCATION }} --package ${{ env.PACKAGE }} env: YAML_LOCATION: "galasa-parent/dev.galasa.framework.api.openapi/src/main/resources/openapi.yaml" OUTPUT_LOCATION: "galasa-parent/dev.galasa.framework.api.beans/src/main/java" PACKAGE: "dev.galasa.framework.api.beans.generated" - name: Build Framework source code + if: github.event_name == 'push' env: GITHUB_ACTOR: ${{ github.actor }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -52,11 +79,28 @@ jobs: run: | gradle -b galasa-parent/build.gradle check publish \ -Dorg.gradle.jvmargs=-Xmx5120M \ - -PsourceMaven=https://development.galasa.dev/gh/maven-repo/maven/ \ + -PsourceMaven=https://development.galasa.dev/${{ env.ARGO_APP_BRANCH }}/maven-repo/maven/ \ -PcentralMaven=https://repo.maven.apache.org/maven2/ \ -PtargetMaven=${{ github.workspace }}/repo \ -PjacocoEnabled=true \ -PisMainOrRelease=true + + - name: Build Framework source code + if: github.event_name == 'workflow_dispatch' # Use the input values provided by the workflow dispatch. + env: + GITHUB_ACTOR: ${{ github.actor }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.GPG_KEYID }} + ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_KEY }} + ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_PASSPHRASE }} + run: | + gradle -b galasa-parent/build.gradle check publish \ + -Dorg.gradle.jvmargs=-Xmx5120M \ + -PsourceMaven=https://development.galasa.dev/${{ env.ARGO_APP_BRANCH }}/maven-repo/maven/ \ + -PcentralMaven=https://repo.maven.apache.org/maven2/ \ + -PtargetMaven=${{ github.workspace }}/repo \ + -PjacocoEnabled=${{ inputs.jacocoEnabled }} \ + -PisMainOrRelease=${{ inputs.isMainOrRelease }} - name: Login to Github Container Registry uses: docker/login-action@v3 @@ -82,19 +126,19 @@ jobs: labels: ${{ steps.metadata.outputs.labels }} build-args: | dockerRepository=ghcr.io - tag=${{ env.IMAGE_TAG }} + tag=${{ env.BRANCH }} - name: Recycle application in ArgoCD env: ARGOCD_AUTH_TOKEN: ${{ secrets.ARGOCD_TOKEN }} run: | - docker run --env ARGOCD_AUTH_TOKEN=${{ env.ARGOCD_AUTH_TOKEN }} --rm -v ${{ github.workspace }}:/var/workspace ghcr.io/galasa-dev/argocdcli:main app actions run gh-maven-repos restart --kind Deployment --resource-name framework-gh --server argocd.galasa.dev + docker run --env ARGOCD_AUTH_TOKEN=${{ env.ARGOCD_AUTH_TOKEN }} --rm -v ${{ github.workspace }}:/var/workspace ghcr.io/galasa-dev/argocdcli:main app actions run ${{ env.ARGO_APP_BRANCH }}-maven-repos restart --kind Deployment --resource-name framework-${{ env.ARGO_APP_BRANCH }} --server argocd.galasa.dev - name: Wait for app health in ArgoCD env: ARGOCD_AUTH_TOKEN: ${{ secrets.ARGOCD_TOKEN }} run: | - docker run --env ARGOCD_AUTH_TOKEN=${{ env.ARGOCD_AUTH_TOKEN }} --rm -v ${{ github.workspace }}:/var/workspace ghcr.io/galasa-dev/argocdcli:main app wait gh-maven-repos --resource apps:Deployment:framework-gh --health --server argocd.galasa.dev + docker run --env ARGOCD_AUTH_TOKEN=${{ env.ARGOCD_AUTH_TOKEN }} --rm -v ${{ github.workspace }}:/var/workspace ghcr.io/galasa-dev/argocdcli:main app wait ${{ env.ARGO_APP_BRANCH }}-maven-repos --resource apps:Deployment:framework-${{ env.ARGO_APP_BRANCH }} --health --server argocd.galasa.dev build-rest-api-documentation: @@ -145,13 +189,13 @@ jobs: env: ARGOCD_AUTH_TOKEN: ${{ secrets.ARGOCD_TOKEN }} run: | - docker run --env ARGOCD_AUTH_TOKEN=${{ env.ARGOCD_AUTH_TOKEN }} --rm -v ${{ github.workspace }}:/var/workspace ghcr.io/galasa-dev/argocdcli:main app actions run gh-maven-repos restart --kind Deployment --resource-name restapidocsite-gh --server argocd.galasa.dev + docker run --env ARGOCD_AUTH_TOKEN=${{ env.ARGOCD_AUTH_TOKEN }} --rm -v ${{ github.workspace }}:/var/workspace ghcr.io/galasa-dev/argocdcli:main app actions run ${{ env.ARGO_APP_BRANCH }}-maven-repos restart --kind Deployment --resource-name restapidocsite-${{ env.ARGO_APP_BRANCH }} --server argocd.galasa.dev - name: Wait for app health in ArgoCD env: ARGOCD_AUTH_TOKEN: ${{ secrets.ARGOCD_TOKEN }} run: | - docker run --env ARGOCD_AUTH_TOKEN=${{ env.ARGOCD_AUTH_TOKEN }} --rm -v ${{ github.workspace }}:/var/workspace ghcr.io/galasa-dev/argocdcli:main app wait gh-maven-repos --resource apps:Deployment:restapidocsite-gh --health --server argocd.galasa.dev + docker run --env ARGOCD_AUTH_TOKEN=${{ env.ARGOCD_AUTH_TOKEN }} --rm -v ${{ github.workspace }}:/var/workspace ghcr.io/galasa-dev/argocdcli:main app wait ${{ env.ARGO_APP_BRANCH }}-maven-repos --resource apps:Deployment:restapidocsite-${{ env.ARGO_APP_BRANCH }} --health --server argocd.galasa.dev trigger-extensions-workflow: name: Trigger Extensions workflow @@ -160,7 +204,15 @@ jobs: steps: - name: Trigger Extensions workflow dispatch event with GitHub CLI + if: github.event_name == 'push' + env: + GH_TOKEN: ${{ secrets.GALASA_TEAM_GITHUB_TOKEN }} + run: | + gh workflow run build.yaml --repo https://github.com/galasa-dev/extensions + + - name: Trigger Extensions workflow dispatch event with GitHub CLI + if: github.event_name == 'workflow_dispatch' env: GH_TOKEN: ${{ secrets.GALASA_TEAM_GITHUB_TOKEN }} run: | - gh workflow run build.yaml --repo https://github.com/galasa-dev/extensions \ No newline at end of file + gh workflow run build.yaml --repo https://github.com/galasa-dev/extensions --ref ${{ env.BRANCH }} -f jacocoEnabled=${{ inputs.jacocoEnabled }} -f isMainOrRelease=${{ inputs.isMainOrRelease }} \ No newline at end of file From 685f476f007697481041586b8a5bb7edb1fd97dd Mon Sep 17 00:00:00 2001 From: Jade Carino Date: Tue, 10 Sep 2024 11:10:51 +0100 Subject: [PATCH 3/4] Disabling gradle cache to avoid build problems Signed-off-by: Jade Carino --- .github/workflows/build.yaml | 1 + .github/workflows/pr-build.yaml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 845794b00..22b68ce3d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -63,6 +63,7 @@ jobs: uses: gradle/actions/setup-gradle@v3 with: gradle-version: 8.9 + cache-disabled: true - name: Build servlet beans with openapi2beans run: | diff --git a/.github/workflows/pr-build.yaml b/.github/workflows/pr-build.yaml index cee0b45f3..559e6cb24 100644 --- a/.github/workflows/pr-build.yaml +++ b/.github/workflows/pr-build.yaml @@ -36,6 +36,7 @@ jobs: uses: gradle/actions/setup-gradle@v3 with: gradle-version: 8.9 + cache-disabled: true - name: Build servlet beans with openapi2beans run: | From 444abbe180994b1e775ad4a56bb0e1313ba31a3e Mon Sep 17 00:00:00 2001 From: Jade Carino Date: Fri, 27 Sep 2024 16:24:33 +0100 Subject: [PATCH 4/4] add report failed build job Signed-off-by: Jade Carino --- .github/workflows/build.yaml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 22b68ce3d..b75803098 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -231,4 +231,17 @@ jobs: env: GH_TOKEN: ${{ secrets.GALASA_TEAM_GITHUB_TOKEN }} run: | - gh workflow run build.yaml --repo https://github.com/galasa-dev/extensions --ref ${{ env.BRANCH }} -f jacocoEnabled=${{ inputs.jacocoEnabled }} -f isMainOrRelease=${{ inputs.isMainOrRelease }} \ No newline at end of file + gh workflow run build.yaml --repo https://github.com/galasa-dev/extensions --ref ${{ env.BRANCH }} -f jacocoEnabled=${{ inputs.jacocoEnabled }} -f isMainOrRelease=${{ inputs.isMainOrRelease }} + + report-failure: + name: Report failure in workflow + runs-on: ubuntu-latest + needs: [log-github-ref, build-framework, build-rest-api-documentation, trigger-extensions-workflow] + if: failure() + + steps: + - name: Report failure in workflow to Slack + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + run : | + docker run --rm -v ${{ github.workspace }}:/var/workspace ghcr.io/galasa-dev/galasabld-ibm:main slackpost workflows --repo "framework" --workflowName "${{ github.workflow }}" --workflowRunNum "${{ github.run_id }}" --ref "${{ env.BRANCH }}" --hook "${{ env.SLACK_WEBHOOK }}"