From 935803c48a67bda6b3ce44082a2cb8fd8691bb35 Mon Sep 17 00:00:00 2001 From: Paul Latzelsperger Date: Wed, 24 Jul 2024 12:59:54 +0200 Subject: [PATCH 1/6] feat(ci): add periodic build trigger --- .github/workflows/publish-new-snapshot.yaml | 37 +++++++++++++++++-- .github/workflows/publish-openapi-ui.yml | 11 ++++-- .github/workflows/run-all-tests.yml | 3 ++ .github/workflows/trigger-docker-publish.yaml | 3 ++ .github/workflows/trigger-maven-publish.yaml | 2 + 5 files changed, 49 insertions(+), 7 deletions(-) diff --git a/.github/workflows/publish-new-snapshot.yaml b/.github/workflows/publish-new-snapshot.yaml index ce5bb8619..faf9e6754 100644 --- a/.github/workflows/publish-new-snapshot.yaml +++ b/.github/workflows/publish-new-snapshot.yaml @@ -39,6 +39,8 @@ on: - published workflow_dispatch: + # periodic build triggers are defined in run-all-tests.yml, which triggers this workflow + concurrency: # cancel only running jobs on pull requests @@ -65,34 +67,63 @@ jobs: [ ! -z "${{ secrets.SWAGGERHUB_USER }}" ] && echo "HAS_SWAGGER=true" >> $GITHUB_OUTPUT exit 0 + determine-version: + runs-on: ubuntu-latest + outputs: + VERSION: ${{ steps.get-version.outputs.VERSION }} + steps: + - uses: actions/checkout@v4 + - name: "Get version" + id: get-version + run: | + if [[ ${{ github.event_name }} == "schedule" }} ]]; then + echo "VERSION=$(IFS=.- read -r RELEASE_VERSION_MAJOR RELEASE_VERSION_MINOR RELEASE_VERSION_PATCH SNAPSHOT<<<$(grep "version" gradle.properties | awk -F= '{print $2}') && echo $RELEASE_VERSION_MAJOR.$RELEASE_VERSION_MINOR.$RELEASE_VERSION_PATCH-$(date +"%Y%m%d")-SNAPSHOT)" >> "$GITHUB_OUTPUT" + fi + publish-docker-images: name: "Create Docker Images" - needs: [ secret-presence ] + needs: [ secret-presence, determine-version] if: | needs.secret-presence.outputs.DOCKER_HUB_TOKEN permissions: contents: write uses: ./.github/workflows/trigger-docker-publish.yaml secrets: inherit + with: + docker_tag: ${{ needs.determine-version.outputs.VERSION }} publish-maven-artifacts: name: "Publish artefacts to OSSRH Snapshots / MavenCentral" permissions: contents: read - needs: [ secret-presence ] + needs: [ secret-presence, determine-version ] # do not run on PR branches, do not run on releases if: | needs.secret-presence.outputs.HAS_OSSRH && github.event_name != 'pull_request' && github.ref != 'refs/heads/releases' uses: ./.github/workflows/trigger-maven-publish.yaml secrets: inherit + with: + version: ${{ needs.determine-version.outputs.VERSION }} publish-to-swaggerhub: name: "Publish OpenAPI spec to Swaggerhub" permissions: contents: read - needs: [ secret-presence ] + needs: [ secret-presence, determine-version ] if: needs.secret-presence.outputs.HAS_SWAGGER uses: ./.github/workflows/publish-swaggerhub.yaml secrets: inherit + with: + downstream_version: ${{ needs.determine-version.outputs.VERSION }} + + publish-openapi-to-ghpages: + name: "Publish OpenAPI UI spec GitHub Pages" + permissions: + contents: read + needs: [ secret-presence, determine-version ] + uses: ./.github/workflows/publish-openapi-ui.yaml + secrets: inherit + with: + version: ${{ needs.determine-version.outputs.VERSION }} diff --git a/.github/workflows/publish-openapi-ui.yml b/.github/workflows/publish-openapi-ui.yml index 5d6cf3808..62102ef6f 100644 --- a/.github/workflows/publish-openapi-ui.yml +++ b/.github/workflows/publish-openapi-ui.yml @@ -21,10 +21,6 @@ name: publish openapi ui on: - push: - branches: - - main - - release/* workflow_dispatch: inputs: @@ -33,6 +29,13 @@ on: description: "Version of the Tractus-X EDC API to be should be published" type: string + workflow_call: + inputs: + version: + required: false + description: "Version of the Tractus-X EDC API to be should be published" + type: string + jobs: generate-openapi-spec: runs-on: ubuntu-latest diff --git a/.github/workflows/run-all-tests.yml b/.github/workflows/run-all-tests.yml index 26eacc08a..777b4b615 100644 --- a/.github/workflows/run-all-tests.yml +++ b/.github/workflows/run-all-tests.yml @@ -37,6 +37,9 @@ on: pull_request: workflow_dispatch: + schedule: + - cron: 0 3 * * MON # run on 03:00 UTC every Monday -> weekly build + concurrency: # cancel older running jobs on the same branch group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/trigger-docker-publish.yaml b/.github/workflows/trigger-docker-publish.yaml index 67205c90c..460922977 100644 --- a/.github/workflows/trigger-docker-publish.yaml +++ b/.github/workflows/trigger-docker-publish.yaml @@ -62,6 +62,9 @@ jobs: contents: write steps: - uses: actions/checkout@v4 + - name: Log inputs + run: | + echo "Input Version: ${{ inputs.version }}, Input namespace: ${{ inputs.namespace}}" - uses: ./.github/actions/publish-docker-image name: Publish ${{ matrix.variant.img }} with: diff --git a/.github/workflows/trigger-maven-publish.yaml b/.github/workflows/trigger-maven-publish.yaml index ca7128030..94cd7594f 100644 --- a/.github/workflows/trigger-maven-publish.yaml +++ b/.github/workflows/trigger-maven-publish.yaml @@ -59,6 +59,8 @@ jobs: OSSRH_USER: ${{ secrets.ORG_OSSRH_USERNAME }} run: |- + echo "Input Version: ${{ inputs.version }}" + # check if version input was specified, else read from gradle.properties if [ ! -z ${{ inputs.version }} ]; From 5df570dff145fcf30175b75fb83c649c37b4a1f4 Mon Sep 17 00:00:00 2001 From: Paul Latzelsperger Date: Wed, 24 Jul 2024 13:24:58 +0200 Subject: [PATCH 2/6] filter for triggering workflow event --- .github/workflows/publish-new-snapshot.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-new-snapshot.yaml b/.github/workflows/publish-new-snapshot.yaml index faf9e6754..0c66a9584 100644 --- a/.github/workflows/publish-new-snapshot.yaml +++ b/.github/workflows/publish-new-snapshot.yaml @@ -76,7 +76,10 @@ jobs: - name: "Get version" id: get-version run: | - if [[ ${{ github.event_name }} == "schedule" }} ]]; then + + echo '${{ toJSON(context.payload.workflow_run) }}' | jq + + if [[ ${{ github.event_name }} == "workflow_run" }} ]]; then echo "VERSION=$(IFS=.- read -r RELEASE_VERSION_MAJOR RELEASE_VERSION_MINOR RELEASE_VERSION_PATCH SNAPSHOT<<<$(grep "version" gradle.properties | awk -F= '{print $2}') && echo $RELEASE_VERSION_MAJOR.$RELEASE_VERSION_MINOR.$RELEASE_VERSION_PATCH-$(date +"%Y%m%d")-SNAPSHOT)" >> "$GITHUB_OUTPUT" fi From f9c381a7b82f841c99b855b867461f4d1490c408 Mon Sep 17 00:00:00 2001 From: Paul Latzelsperger Date: Wed, 24 Jul 2024 13:35:58 +0200 Subject: [PATCH 3/6] fixed typo, update cron event filter --- .github/workflows/publish-new-snapshot.yaml | 17 ++++++++++++----- .github/workflows/run-all-tests.yml | 21 +++++++++++---------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/.github/workflows/publish-new-snapshot.yaml b/.github/workflows/publish-new-snapshot.yaml index 0c66a9584..eed55a58e 100644 --- a/.github/workflows/publish-new-snapshot.yaml +++ b/.github/workflows/publish-new-snapshot.yaml @@ -67,6 +67,13 @@ jobs: [ ! -z "${{ secrets.SWAGGERHUB_USER }}" ] && echo "HAS_SWAGGER=true" >> $GITHUB_OUTPUT exit 0 + print-calling-workflow-event: + runs-on: ubuntu-latest + steps: + - name: "log parent workflow event" + run: | + echo '${{ github.event.workflow_run.event }}' + determine-version: runs-on: ubuntu-latest outputs: @@ -77,9 +84,9 @@ jobs: id: get-version run: | - echo '${{ toJSON(context.payload.workflow_run) }}' | jq + # only create the version string if the run-all-tests workflow was triggered by a cron event - if [[ ${{ github.event_name }} == "workflow_run" }} ]]; then + if [[ ${{ github.event.workflow_run.event }} == "schedule" ]]; then echo "VERSION=$(IFS=.- read -r RELEASE_VERSION_MAJOR RELEASE_VERSION_MINOR RELEASE_VERSION_PATCH SNAPSHOT<<<$(grep "version" gradle.properties | awk -F= '{print $2}') && echo $RELEASE_VERSION_MAJOR.$RELEASE_VERSION_MINOR.$RELEASE_VERSION_PATCH-$(date +"%Y%m%d")-SNAPSHOT)" >> "$GITHUB_OUTPUT" fi @@ -119,14 +126,14 @@ jobs: uses: ./.github/workflows/publish-swaggerhub.yaml secrets: inherit with: - downstream_version: ${{ needs.determine-version.outputs.VERSION }} + downstream-version: ${{ needs.determine-version.outputs.VERSION }} - publish-openapi-to-ghpages: + publish-openapi-to-gh-pages: name: "Publish OpenAPI UI spec GitHub Pages" permissions: contents: read needs: [ secret-presence, determine-version ] - uses: ./.github/workflows/publish-openapi-ui.yaml + uses: ./.github/workflows/publish-openapi-ui.yml secrets: inherit with: version: ${{ needs.determine-version.outputs.VERSION }} diff --git a/.github/workflows/run-all-tests.yml b/.github/workflows/run-all-tests.yml index 777b4b615..edcd2e56c 100644 --- a/.github/workflows/run-all-tests.yml +++ b/.github/workflows/run-all-tests.yml @@ -38,7 +38,7 @@ on: workflow_dispatch: schedule: - - cron: 0 3 * * MON # run on 03:00 UTC every Monday -> weekly build + - cron: 0 3 * * * # run on 03:00 UTC every day concurrency: # cancel older running jobs on the same branch @@ -47,13 +47,13 @@ concurrency: # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - verify: - uses: ./.github/workflows/verify.yaml - secrets: inherit - - deployment-test: - uses: ./.github/workflows/deployment-test.yaml - secrets: inherit +# verify: +# uses: ./.github/workflows/verify.yaml +# secrets: inherit +# +# deployment-test: +# uses: ./.github/workflows/deployment-test.yaml +# secrets: inherit upgradeability-test: uses: ./.github/workflows/upgradeability-test.yaml @@ -63,8 +63,9 @@ jobs: # in future iterations, this could be used as a choke point to collect test data, etc. summary: needs: - - verify - - deployment-test +# - verify +# - deployment-test + - upgradeability-test runs-on: ubuntu-latest steps: - name: 'Master test job' From 820b2b71874af65d1c6e7272c028c15e2c6801f6 Mon Sep 17 00:00:00 2001 From: Paul Latzelsperger Date: Wed, 24 Jul 2024 15:14:01 +0200 Subject: [PATCH 4/6] add openapi-ui publish job to release wf --- .github/workflows/publish-new-release.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/publish-new-release.yml b/.github/workflows/publish-new-release.yml index 43028ae3d..e0f5ff931 100644 --- a/.github/workflows/publish-new-release.yml +++ b/.github/workflows/publish-new-release.yml @@ -209,3 +209,13 @@ jobs: with: downstream-version: ${{ needs.release-version.outputs.RELEASE_VERSION }} secrets: inherit + + publish-openapi-to-gh-pages: + name: "Publish OpenAPI UI spec GitHub Pages" + permissions: + contents: read + needs: [ release-version ] + uses: ./.github/workflows/publish-openapi-ui.yml + secrets: inherit + with: + version: ${{ needs.release-version.outputs.RELEASE_VERSION }} \ No newline at end of file From ca044e7290ed338f78b0f266668d9cfe0c62b716 Mon Sep 17 00:00:00 2001 From: Paul Latzelsperger Date: Wed, 24 Jul 2024 15:27:18 +0200 Subject: [PATCH 5/6] reduce cron frequency --- .github/workflows/run-all-tests.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/run-all-tests.yml b/.github/workflows/run-all-tests.yml index edcd2e56c..9b6843b86 100644 --- a/.github/workflows/run-all-tests.yml +++ b/.github/workflows/run-all-tests.yml @@ -38,7 +38,7 @@ on: workflow_dispatch: schedule: - - cron: 0 3 * * * # run on 03:00 UTC every day + - cron: 0 3 * * 1 # run on 03:00 UTC every Monday concurrency: # cancel older running jobs on the same branch @@ -47,13 +47,13 @@ concurrency: # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: -# verify: -# uses: ./.github/workflows/verify.yaml -# secrets: inherit -# -# deployment-test: -# uses: ./.github/workflows/deployment-test.yaml -# secrets: inherit + verify: + uses: ./.github/workflows/verify.yaml + secrets: inherit + + deployment-test: + uses: ./.github/workflows/deployment-test.yaml + secrets: inherit upgradeability-test: uses: ./.github/workflows/upgradeability-test.yaml @@ -63,8 +63,8 @@ jobs: # in future iterations, this could be used as a choke point to collect test data, etc. summary: needs: -# - verify -# - deployment-test + - verify + - deployment-test - upgradeability-test runs-on: ubuntu-latest steps: From 4d1225127e11785c13f694a5051bdf6501a083b5 Mon Sep 17 00:00:00 2001 From: Paul Latzelsperger Date: Wed, 24 Jul 2024 16:07:48 +0200 Subject: [PATCH 6/6] remove debug --- .github/workflows/publish-new-snapshot.yaml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/publish-new-snapshot.yaml b/.github/workflows/publish-new-snapshot.yaml index eed55a58e..8476cf2f2 100644 --- a/.github/workflows/publish-new-snapshot.yaml +++ b/.github/workflows/publish-new-snapshot.yaml @@ -67,13 +67,6 @@ jobs: [ ! -z "${{ secrets.SWAGGERHUB_USER }}" ] && echo "HAS_SWAGGER=true" >> $GITHUB_OUTPUT exit 0 - print-calling-workflow-event: - runs-on: ubuntu-latest - steps: - - name: "log parent workflow event" - run: | - echo '${{ github.event.workflow_run.event }}' - determine-version: runs-on: ubuntu-latest outputs: