From ca212310dfa2241d5ae5f0d102244d40ff3e44fc Mon Sep 17 00:00:00 2001 From: John Murret Date: Mon, 8 Jul 2024 15:56:19 -0600 Subject: [PATCH 1/3] configure PR comments using backport assistant --- .github/workflows/backport-commenter.yml | 86 ++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 .github/workflows/backport-commenter.yml diff --git a/.github/workflows/backport-commenter.yml b/.github/workflows/backport-commenter.yml new file mode 100644 index 000000000000..ae940b88f9ad --- /dev/null +++ b/.github/workflows/backport-commenter.yml @@ -0,0 +1,86 @@ +# This workflow is responsible for validating backports and commenting on backport PRs tagging PR authors to merge in their backport PRs. +# It is scheduled to run at 9:00 AM every day and will also run when manually triggered. + +name: Backport Commenter +run-name: Validate backports and notify PRs owners +on: + # TODO(jmurret): Re-enable before we merge this PR. + # schedule: + # - cron: "0 9 * * *" + workflow_dispatch: + inputs: + versions: + description: "A comma seperated string of the x.y versions representing the backport labels to check. Example: 1.13,1.14,1.15" + required: true + type: string + begin-date: + description: Begin Date to check for PRs being merged. In the format of YYYY-MM-DD. + required: true + type: string + # TODO(jmurret): Remove this before we merge this PR. + push: + branches: + - jm/** + +env: + # This needs to be updated to the date of the last release. + BPA_COMMENTER_BEGIN_DATE: "2024-06-12" + # This needs to be updated to the versions that are currently being backported. + BPA_COMMENTER_VERSIONS: "1.15,1.16,1.17,1.18,1.19" + +jobs: + + validate-backports-oss: + container: hashicorpdev/backport-assistant:0.4.4 + runs-on: [ 'self-hosted, linux' ] + steps: + - name: Fetch Secrets + id: secrets + uses: hashicorp/vault-action@v3 + with: + url: ${{ vars.CI_VAULT_URL }} + method: ${{ vars.CI_VAULT_METHOD }} + path: ${{ vars.CI_VAULT_PATH }} + jwtGithubAudience: ${{ vars.CI_VAULT_AUD }} + secrets: + kv/data/github/${{ github.repository }} github_token ; + + - name: backport commenter + env: + OWNER: hashicorp + REPO: consul + SYNC_REPO: consul-enterprise + GITHUB_TOKEN: ${{ steps.secrets.outputs.github_token }} + run: | + backport-assistant validate \ + --owner ${OWNER} --repo ${REPO} --sync-repo ${SYNC_REPO} --versions "${BPA_COMMENTER_VERSIONS}" \ + --begin-date "${BPA_COMMENTER_BEGIN_DATE}" --add-comment + + validate-backports-enterprise: + container: hashicorpdev/backport-assistant:0.4.4 + runs-on: [ 'self-hosted, linux' ] + # needs to run serially because github search api limits to 30 req/minute. + # running in parallel will push it over the limit. + needs: + - validate-backports-oss + steps: + - name: Fetch Secrets + id: secrets + uses: hashicorp/vault-action@v3 + with: + url: ${{ vars.CI_VAULT_URL }} + method: ${{ vars.CI_VAULT_METHOD }} + path: ${{ vars.CI_VAULT_PATH }} + jwtGithubAudience: ${{ vars.CI_VAULT_AUD }} + secrets: + kv/data/github/${{ github.repository }} github_token ; + + - name: backport commenter + env: + OWNER: hashicorp + REPO: consul-enterprise + GITHUB_TOKEN: ${{ steps.secrets.outputs.github_token }} + run: | + backport-assistant validate \ + --owner "${OWNER}" --repo ${REPO} --versions ${BPA_COMMENTER_VERSIONS} \ + --begin-date ${BPA_COMMENTER_BEGIN_DATE} --add-comment \ No newline at end of file From f33db64f4108a30c89678c1f77e2a2582cda7f53 Mon Sep 17 00:00:00 2001 From: John Murret Date: Mon, 8 Jul 2024 16:03:13 -0600 Subject: [PATCH 2/3] updating image used. --- .github/workflows/backport-commenter.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/backport-commenter.yml b/.github/workflows/backport-commenter.yml index ae940b88f9ad..df19101cfa54 100644 --- a/.github/workflows/backport-commenter.yml +++ b/.github/workflows/backport-commenter.yml @@ -32,7 +32,7 @@ jobs: validate-backports-oss: container: hashicorpdev/backport-assistant:0.4.4 - runs-on: [ 'self-hosted, linux' ] + runs-on: [ 'ubuntu-latest' ] steps: - name: Fetch Secrets id: secrets @@ -58,7 +58,7 @@ jobs: validate-backports-enterprise: container: hashicorpdev/backport-assistant:0.4.4 - runs-on: [ 'self-hosted, linux' ] + runs-on: [ 'ubuntu-latest' ] # needs to run serially because github search api limits to 30 req/minute. # running in parallel will push it over the limit. needs: From 92d79dfa60fe90840e6995d17829f73344ad5c6d Mon Sep 17 00:00:00 2001 From: John Murret Date: Mon, 8 Jul 2024 16:13:45 -0600 Subject: [PATCH 3/3] using set up job to abstract GH runners from self-hosted runners. --- .github/workflows/backport-commenter.yml | 32 ++++++++++++++++++++---- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/.github/workflows/backport-commenter.yml b/.github/workflows/backport-commenter.yml index df19101cfa54..595df7bd1d82 100644 --- a/.github/workflows/backport-commenter.yml +++ b/.github/workflows/backport-commenter.yml @@ -1,12 +1,15 @@ # This workflow is responsible for validating backports and commenting on backport PRs tagging PR authors to merge in their backport PRs. # It is scheduled to run at 9:00 AM every day and will also run when manually triggered. +## IMPORTANT +# This workflow only has jobs that are enabled to run on consul and are disabled on consul-enterprise. +# Please do not modify this file in consul-enterprise. + name: Backport Commenter run-name: Validate backports and notify PRs owners on: - # TODO(jmurret): Re-enable before we merge this PR. - # schedule: - # - cron: "0 9 * * *" + schedule: + - cron: "0 9 * * *" workflow_dispatch: inputs: versions: @@ -29,10 +32,27 @@ env: BPA_COMMENTER_VERSIONS: "1.15,1.16,1.17,1.18,1.19" jobs: + setup: + name: Setup + if: ${{ !endsWith(github.repository, '-enterprise') }} + runs-on: ubuntu-latest + outputs: + compute-small: ${{ steps.setup-outputs.outputs.compute-small }} + compute-medium: ${{ steps.setup-outputs.outputs.compute-medium }} + compute-large: ${{ steps.setup-outputs.outputs.compute-large }} + compute-xl: ${{ steps.setup-outputs.outputs.compute-xl }} + steps: + - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + - id: setup-outputs + name: Setup outputs + run: ./.github/scripts/get_runner_classes.sh validate-backports-oss: + if: ${{ !endsWith(github.repository, '-enterprise') }} container: hashicorpdev/backport-assistant:0.4.4 - runs-on: [ 'ubuntu-latest' ] + runs-on: ${{ needs.setup.outputs.compute-small }} + needs: + - setup steps: - name: Fetch Secrets id: secrets @@ -57,11 +77,13 @@ jobs: --begin-date "${BPA_COMMENTER_BEGIN_DATE}" --add-comment validate-backports-enterprise: + if: ${{ !endsWith(github.repository, '-enterprise') }} container: hashicorpdev/backport-assistant:0.4.4 - runs-on: [ 'ubuntu-latest' ] + runs-on: ${{ needs.setup.outputs.compute-small }} # needs to run serially because github search api limits to 30 req/minute. # running in parallel will push it over the limit. needs: + - setup - validate-backports-oss steps: - name: Fetch Secrets