From ca09cbf5241aa0a465ce15dbf0c33e003bc7d0d2 Mon Sep 17 00:00:00 2001 From: Jacob Baungard Hansen Date: Wed, 18 Sep 2024 11:06:06 +0200 Subject: [PATCH 1/3] Add ACM Grafana config Allows us to use syncbot with ACM Grafana. Signed-off-by: Jacob Baungard Hansen --- .github/workflows/merge-acm-grafana.yaml | 65 ++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/workflows/merge-acm-grafana.yaml diff --git a/.github/workflows/merge-acm-grafana.yaml b/.github/workflows/merge-acm-grafana.yaml new file mode 100644 index 0000000..b1e7ab0 --- /dev/null +++ b/.github/workflows/merge-acm-grafana.yaml @@ -0,0 +1,65 @@ +name: ACM Grafana merger + +on: + workflow_dispatch: + schedule: + - cron: '0 0 * * 1' #@weekly + pull_request: + paths: + - '.github/workflows/merge-acm-flow.yaml' + - '.github/workflows/merge-acm-grafana.yaml' + push: + paths: + - '.github/workflows/merge-acm-flow.yaml' + - '.github/workflows/merge-acm-grafana.yaml' +jobs: + grafana-merge: + uses: ./.github/workflows/merge-acm-flow.yaml + with: + upstream: grafana/grafana + downstream: stolostron/grafana + sandbox: rhobs/acm-grafana + go-version: "1.22" + node-version: "20" + restore-downstream: >- + OWNERS + restore-upstream: >- + .drone.yml + CHANGELOG.md + docs + go.mod + go.sum + go.work + go.work.sum + pkg + lerna.json + package.json + packages + public/app/ + yarn.lock + assets-cmd: | + # get rid of old assets as new filenames are generated + rm -rf ./public/build/ + + # generate nodejs files, using docker since it appears to be problematic doing + # it directly in the github action runner. + docker build --target js-builder -t grafana-js-build . + docker create --name grafana-jsbuild grafana-js-build:latest + docker cp grafana-jsbuild:/tmp/grafana/public/build ./public/ + docker rm grafana-jsbuild + + # Generate go files with wire + go mod download + go run ./pkg/build/wire/cmd/wire/main.go gen -tags oss ./pkg/server + + # Commit assets + git add pkg/server/wire_gen.go ./public/build ./public/app/plugins/datasource/*/dist/* + git diff --cached --exit-code || git commit -s -m "[bot] assets: generate" + downstream-version-expression: | + sed -n -E 's/^.*\"version\": *\"([0-9]+\.[0-9]+\.[0-9]+)\".*$/v\1/p' https://raw.githubusercontent.com/stolostron/grafana/release-2.12/package.json + secrets: + pr-app-id: ${{ secrets.ACM_APP_ID }} + pr-app-private-key: ${{ secrets.ACM_APP_PRIVATE_KEY }} + cloner-app-id: ${{ secrets.ACM_CLONER_APP_ID }} + cloner-app-private-key: ${{ secrets.ACM_CLONER_APP_PRIVATE_KEY }} + slack-webhook-url: ${{ secrets.ACM_SLACK_WEBHOOK_URL }} From af29ffc1e6cef65f4521bbf7c25df85c0f560a28 Mon Sep 17 00:00:00 2001 From: Jacob Baungard Hansen Date: Thu, 19 Sep 2024 11:25:10 +0200 Subject: [PATCH 2/3] Grafana: don't run go mod tidy Signed-off-by: Jacob Baungard Hansen --- .github/workflows/merge-acm-flow.yaml | 6 ++++++ .github/workflows/merge-acm-grafana.yaml | 1 + 2 files changed, 7 insertions(+) diff --git a/.github/workflows/merge-acm-flow.yaml b/.github/workflows/merge-acm-flow.yaml index 9d26dd8..7fae690 100644 --- a/.github/workflows/merge-acm-flow.yaml +++ b/.github/workflows/merge-acm-flow.yaml @@ -48,6 +48,11 @@ on: required: false default: '' type: string + go-mod-tidy: + description: Run `go mod tidy` after a merge + required: false + default: true + type: boolean secrets: cloner-app-id: description: Github ID of cloner app @@ -186,6 +191,7 @@ jobs: with: node-version: ${{ inputs.node-version }} - name: go mod tidy + vendor + if: ${{ inputs.go-mod-tidy }} run: | go mod tidy git add go.mod go.sum diff --git a/.github/workflows/merge-acm-grafana.yaml b/.github/workflows/merge-acm-grafana.yaml index b1e7ab0..08c9c72 100644 --- a/.github/workflows/merge-acm-grafana.yaml +++ b/.github/workflows/merge-acm-grafana.yaml @@ -21,6 +21,7 @@ jobs: sandbox: rhobs/acm-grafana go-version: "1.22" node-version: "20" + go-mod-tidy: false restore-downstream: >- OWNERS restore-upstream: >- From cac04e234d047f2da7d7000f6a485500afaad89c Mon Sep 17 00:00:00 2001 From: Jacob Baungard Hansen Date: Thu, 19 Sep 2024 16:41:36 +0200 Subject: [PATCH 3/3] Fix linter issue in merge-acm-flow Signed-off-by: Jacob Baungard Hansen --- .github/workflows/merge-acm-flow.yaml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/merge-acm-flow.yaml b/.github/workflows/merge-acm-flow.yaml index 7fae690..66c5429 100644 --- a/.github/workflows/merge-acm-flow.yaml +++ b/.github/workflows/merge-acm-flow.yaml @@ -87,9 +87,11 @@ jobs: - name: Find github org name from repo name id: org run: | - echo "upstream=$(dirname ${{ inputs.upstream }})" >> $GITHUB_OUTPUT - echo "downstream=$(dirname ${{ inputs.downstream }})" >> $GITHUB_OUTPUT - echo "sandbox=$(dirname ${{ inputs.sandbox }})" >> $GITHUB_OUTPUT + { + echo "upstream=$(dirname ${{ inputs.upstream }})" + echo "downstream=$(dirname ${{ inputs.downstream }})" + echo "sandbox=$(dirname ${{ inputs.sandbox }})" + } >> "$GITHUB_OUTPUT" DOWNSTREAM_VERSION=$(curl -sL "https://raw.githubusercontent.com/${{ inputs.downstream }}/${{ inputs.downstream-branch }}/VERSION") if [[ "${DOWNSTREAM_VERSION}" =~ ^$|"404: Not Found" ]]; then # Strip the trailing URL from the expression. @@ -106,7 +108,7 @@ jobs: exit 1 fi fi - echo "downstream-version=${DOWNSTREAM_VERSION}" >> $GITHUB_OUTPUT + echo "downstream-version=${DOWNSTREAM_VERSION}" >> "$GITHUB_OUTPUT" - uses: madhead/semver-utils@latest id: version with: @@ -119,14 +121,14 @@ jobs: SEMVER_RESULT="${{ steps.version.outputs.comparison-result }}" echo "${{ inputs.downstream }}@${{ steps.org.outputs.downstream-version }} ${SEMVER_RESULT} ${{ inputs.upstream }}@${{ steps.upstream.outputs.release }}" if [ "${SEMVER_RESULT}" == "<" ]; then - echo "status=outdated" >> $GITHUB_OUTPUT + echo "status=outdated" >> "$GITHUB_OUTPUT" echo "::notice::downstream outdated" elif [ "${SEMVER_RESULT}" == "=" ]; then - echo "status=uptodate" >> $GITHUB_OUTPUT + echo "status=uptodate" >> "$GITHUB_OUTPUT" echo "::notice::downstream up-to-date" exit 0 else - echo "status=ahead" >> $GITHUB_OUTPUT + echo "status=ahead" >> "$GITHUB_OUTPUT" echo "::notice::downstream ahead" exit 0 fi @@ -144,7 +146,7 @@ jobs: - name: Merge with upstream ${{ steps.upstream.outputs.release }} tag id: merge run: | - git merge -X theirs refs/tags/${{ steps.upstream.outputs.release }} --no-edit || echo 'MERGE_CONFLICT=true' >> $GITHUB_OUTPUT + git merge -X theirs refs/tags/${{ steps.upstream.outputs.release }} --no-edit || echo 'MERGE_CONFLICT=true' >> "$GITHUB_OUTPUT" - name: Resolve conflict using upstream contents if: ${{ steps.merge.outputs.MERGE_CONFLICT == 'true' && inputs.restore-upstream != ''}} run: |