From ad9b7b4e9decbab43c660e908ddd248fe2f331f6 Mon Sep 17 00:00:00 2001 From: Albert Callarisa Date: Tue, 10 Mar 2026 14:19:47 +0100 Subject: [PATCH 1/2] Make use of shared workflows Signed-off-by: Albert Callarisa --- .github/scripts/automerge.py | 73 ------------------- .github/workflows/backport.yaml | 19 +---- .github/workflows/dapr-bot-schedule.yml | 62 ++++------------ .github/workflows/validate_examples.yaml | 93 +----------------------- 4 files changed, 22 insertions(+), 225 deletions(-) delete mode 100644 .github/scripts/automerge.py diff --git a/.github/scripts/automerge.py b/.github/scripts/automerge.py deleted file mode 100644 index 176962f93..000000000 --- a/.github/scripts/automerge.py +++ /dev/null @@ -1,73 +0,0 @@ -# -# Copyright 2021 The Dapr Authors -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# http://www.apache.org/licenses/LICENSE-2.0 -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# This script automerges PRs in Dapr. - -import os - -from github import Github - - -g = Github(os.getenv("GITHUB_TOKEN")) -repo = g.get_repo(os.getenv("GITHUB_REPOSITORY")) -maintainers = [m.strip() for m in os.getenv("MAINTAINERS").split(',')] - - -def fetch_pulls(mergeable_state, labels={'automerge'}): - return [pr for pr in repo.get_pulls(state='open', sort='created') - if (not pr.draft and pr.mergeable_state == mergeable_state - and (not labels or len(labels.intersection({label.name for label in pr.labels})) > 0))] - - -def is_approved(pr): - approvers = [r.user.login for r in pr.get_reviews() - if r.state == 'APPROVED' and r.user.login in maintainers] - return len([a for a in approvers if - repo.get_collaborator_permission(a) in ['admin', 'write']]) > 0 - - -# First, find a PR that can be merged -pulls = fetch_pulls('clean') -print(f"Detected {len(pulls)} open pull requests in {repo.name} to be automerged.") -merged = False -for pr in pulls: - if is_approved(pr): - # Merge only one PR per run. - print(f"Merging PR {pr.html_url}") - try: - pr.merge(merge_method='squash') - merged = True - break - except Exception: - print(f"Failed to merge PR {pr.html_url}") - -if len(pulls) > 0 and not merged: - print("No PR was automerged.") - -# Now, update all PRs that are behind, regardless of automerge label. -pulls = fetch_pulls('behind', {'automerge', 'autoupdate'}) -print(f"Detected {len(pulls)} open pull requests in {repo.name} to be updated.") -for pr in pulls: - print(f"Updating PR {pr.html_url}") - try: - pr.update_branch() - except Exception: - print(f"Failed to update PR {pr.html_url}") - -pulls = fetch_pulls('dirty') -print(f"Detected {len(pulls)} open pull requests in {repo.name}" - "to be automerged but are in dirty state.") -for pr in pulls: - print(f"PR is in dirty state: {pr.html_url}") - -print("Done.") diff --git a/.github/workflows/backport.yaml b/.github/workflows/backport.yaml index 71b9716cb..dc8f52664 100644 --- a/.github/workflows/backport.yaml +++ b/.github/workflows/backport.yaml @@ -12,6 +12,7 @@ # name: Backport + on: pull_request_target: types: @@ -20,18 +21,6 @@ on: jobs: backport: - name: Backport - runs-on: ubuntu-latest - if: > - github.event.pull_request.merged - && ( - github.event.action == 'closed' - || ( - github.event.action == 'labeled' - && contains(github.event.label.name, 'backport') - ) - ) - steps: - - uses: tibdex/backport@9565281eda0731b1d20c4025c43339fb0a23812e - with: - github_token: ${{ secrets.DAPR_BOT_TOKEN }} + uses: dapr/.github/.github/workflows/backport.yaml@main + secrets: + dapr_bot_token: ${{ secrets.DAPR_BOT_TOKEN }} diff --git a/.github/workflows/dapr-bot-schedule.yml b/.github/workflows/dapr-bot-schedule.yml index 918c163ec..08e6a399d 100644 --- a/.github/workflows/dapr-bot-schedule.yml +++ b/.github/workflows/dapr-bot-schedule.yml @@ -17,53 +17,21 @@ on: schedule: - cron: '*/10 * * * *' workflow_dispatch: + jobs: automerge: - if: github.repository_owner == 'dapr' - name: Automerge and update PRs. - runs-on: ubuntu-latest - steps: - - name: Checkout repo - uses: actions/checkout@v6 - - name: Install dependencies - run: pip install PyGithub - - name: Automerge and update - env: - MAINTAINERS: berndverst,wcs1only - GITHUB_TOKEN: ${{ secrets.DAPR_BOT_TOKEN }} - run: python ./.github/scripts/automerge.py + uses: dapr/.github/.github/workflows/automerge.yaml@main + with: + maintainer-teams: python-sdk-maintainers + secrets: + dapr_bot_token: ${{ secrets.DAPR_BOT_TOKEN }} + prune_stale: - name: Prune Stale - runs-on: ubuntu-latest - steps: - - name: Prune Stale - uses: actions/stale@v5 - with: - repo-token: ${{ secrets.DAPR_BOT_TOKEN }} - # Different amounts of days for issues/PRs are not currently supported but there is a PR - # open for it: https://github.com/actions/stale/issues/214 - days-before-stale: 60 - days-before-close: 7 - stale-issue-message: > - This issue has been automatically marked as stale because it has not had activity in the - last 60 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue, help wanted or triaged/resolved) or other activity - occurs. Thank you for your contributions. - close-issue-message: > - This issue has been automatically closed because it has not had activity in the - last 67 days. If this issue is still valid, please ping a maintainer and ask them to label it as pinned, good first issue, help wanted or triaged/resolved. - Thank you for your contributions. - stale-pr-message: > - This pull request has been automatically marked as stale because it has not had - activity in the last 60 days. It will be closed in 7 days if no further activity occurs. Please - feel free to give a status update now, ping for review, or re-open when it's ready. - Thank you for your contributions! - close-pr-message: > - This pull request has been automatically closed because it has not had - activity in the last 67 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. - Thank you for your contributions! - stale-issue-label: 'stale' - exempt-issue-labels: 'pinned,good first issue,help wanted,triaged/resolved' - stale-pr-label: 'stale' - exempt-pr-labels: 'pinned' - operations-per-run: 500 - ascending: true + uses: dapr/.github/.github/workflows/prune-stale.yaml@main + with: + days-before-issue-stale: 60 + days-before-pr-stale: 60 + days-before-issue-close: 7 + days-before-pr-close: 7 + secrets: + dapr_bot_token: ${{ secrets.DAPR_BOT_TOKEN }} diff --git a/.github/workflows/validate_examples.yaml b/.github/workflows/validate_examples.yaml index f99010d22..bd833ec26 100644 --- a/.github/workflows/validate_examples.yaml +++ b/.github/workflows/validate_examples.yaml @@ -19,15 +19,6 @@ on: - release-* - feature/* workflow_dispatch: - inputs: - daprdapr_commit: - description: 'Dapr/Dapr commit to build custom daprd from' - required: false - default: '' - daprcli_commit: - description: 'Dapr/CLI commit to build custom dapr CLI from' - required: false - default: '' repository_dispatch: types: [validate-examples] merge_group: @@ -35,13 +26,6 @@ jobs: validate: runs-on: ubuntu-latest env: - GOVER: 1.21 - GOOS: linux - GOARCH: amd64 - GOPROXY: https://proxy.golang.org - DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/master/install/install.sh - DAPR_CLI_REF: ${{ github.event.inputs.daprcli_commit }} - DAPR_REF: ${{ github.event.inputs.daprdapr_commit }} CHECKOUT_REPO: ${{ github.repository }} CHECKOUT_REF: ${{ github.ref }} @@ -56,7 +40,6 @@ jobs: if [ ${{ github.event.client_payload.command }} = "ok-to-test" ]; then echo "CHECKOUT_REPO=${{ github.event.client_payload.pull_head_repo }}" >> $GITHUB_ENV echo "CHECKOUT_REF=${{ github.event.client_payload.pull_head_ref }}" >> $GITHUB_ENV - echo "DAPR_REF=master" >> $GITHUB_ENV fi - name: Check out code onto GOPATH @@ -65,30 +48,6 @@ jobs: repository: ${{ env.CHECKOUT_REPO }} ref: ${{ env.CHECKOUT_REF }} - uses: azure/setup-helm@v4 - - name: Determine latest Dapr Runtime version (including prerelease) - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - RUNTIME_VERSION=$(curl -fsS -H "Authorization: Bearer $GITHUB_TOKEN" \ - "https://api.github.com/repos/dapr/dapr/releases?per_page=10" | \ - jq -r 'sort_by(.created_at) | reverse | .[0].tag_name | ltrimstr("v")') - if [ -z "$RUNTIME_VERSION" ] || [ "$RUNTIME_VERSION" = "null" ]; then - echo "Failed to resolve Dapr Runtime version" && exit 1 - fi - echo "DAPR_RUNTIME_VER=$RUNTIME_VERSION" >> $GITHUB_ENV - echo "Found $RUNTIME_VERSION" - - name: Determine latest Dapr CLI version (including prerelease) - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - CLI_VERSION=$(curl -fsS -H "Authorization: Bearer $GITHUB_TOKEN" \ - "https://api.github.com/repos/dapr/cli/releases?per_page=10" | \ - jq -r 'sort_by(.created_at) | reverse | .[0].tag_name | ltrimstr("v")') - if [ -z "$CLI_VERSION" ] || [ "$CLI_VERSION" = "null" ]; then - echo "Failed to resolve Dapr CLI version" && exit 1 - fi - echo "DAPR_CLI_VER=$CLI_VERSION" >> $GITHUB_ENV - echo "Found $CLI_VERSION" - name: Set up Python ${{ matrix.python_ver }} uses: actions/setup-python@v6 with: @@ -98,61 +57,15 @@ jobs: python -m pip install --upgrade pip pip install setuptools wheel twine tox - name: Set up Dapr CLI - run: | - wget -q "https://github.com/dapr/cli/releases/download/v${{ env.DAPR_CLI_VER }}/dapr_${{ env.GOOS }}_${{ env.GOARCH }}.tar.gz" -O /tmp/dapr.tar.gz - sudo tar xzf /tmp/dapr.tar.gz -C /usr/local/bin dapr - dapr --version - - name: Set up Go ${{ env.GOVER }} - if: env.DAPR_REF != '' || env.DAPR_CLI_REF != '' - uses: actions/setup-go@v5 - with: - go-version: ${{ env.GOVER }} + uses: dapr/.github/.github/actions/setup-dapr-cli@main + - name: Set up Dapr runtime + uses: dapr/.github/.github/actions/setup-dapr-runtime@main - name: Set up Llama run: | curl -fsSL https://ollama.com/install.sh | sh nohup ollama serve & sleep 10 ollama pull llama3.2:latest - - name: Checkout Dapr CLI repo to override dapr command. - uses: actions/checkout@v6 - if: env.DAPR_CLI_REF != '' - with: - repository: dapr/cli - ref: ${{ env.DAPR_CLI_REF }} - path: cli - - name: Checkout Dapr repo to override daprd. - uses: actions/checkout@v6 - if: env.DAPR_REF != '' - with: - repository: dapr/dapr - ref: ${{ env.DAPR_REF }} - path: dapr_runtime - - name: Build and override dapr cli with referenced commit. - if: env.DAPR_CLI_REF != '' - run: | - cd cli - make - sudo cp dist/linux_amd64/release/dapr /usr/local/bin/dapr - cd .. - - name: Initialize Dapr runtime ${{ env.DAPR_RUNTIME_VER }} - run: | - dapr uninstall --all - dapr init --runtime-version ${{ env.DAPR_RUNTIME_VER }} - - name: Build and override daprd with referenced commit. - if: env.DAPR_REF != '' - run: | - cd dapr_runtime - make - mkdir -p $HOME/.dapr/bin/ - cp dist/linux_amd64/release/daprd $HOME/.dapr/bin/daprd - cd .. - - name: Override placement service. - if: env.DAPR_REF != '' - run: | - docker stop dapr_placement - cd dapr_runtime - ./dist/linux_amd64/release/placement --healthz-port 9091 & - cd .. - name: Check Examples run: | tox -e examples From c943265c4e09f5f0ff4b3f3634915f023217652c Mon Sep 17 00:00:00 2001 From: Albert Callarisa Date: Mon, 16 Mar 2026 17:37:46 +0100 Subject: [PATCH 2/2] Keep inputs for the commit SHA in the CLI and runtime Signed-off-by: Albert Callarisa --- .github/workflows/validate_examples.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/validate_examples.yaml b/.github/workflows/validate_examples.yaml index bd833ec26..03ab9b43e 100644 --- a/.github/workflows/validate_examples.yaml +++ b/.github/workflows/validate_examples.yaml @@ -19,6 +19,15 @@ on: - release-* - feature/* workflow_dispatch: + inputs: + daprdapr_commit: + description: 'Dapr/Dapr commit to build custom daprd from' + required: false + default: '' + daprcli_commit: + description: 'Dapr/CLI commit to build custom dapr CLI from' + required: false + default: '' repository_dispatch: types: [validate-examples] merge_group: @@ -58,8 +67,14 @@ jobs: pip install setuptools wheel twine tox - name: Set up Dapr CLI uses: dapr/.github/.github/actions/setup-dapr-cli@main + with: + commit: ${{ github.event.inputs.daprcli_commit }} + github-token: ${{ secrets.GITHUB_TOKEN }} - name: Set up Dapr runtime uses: dapr/.github/.github/actions/setup-dapr-runtime@main + with: + commit: ${{ github.event.inputs.daprdapr_commit }} + github-token: ${{ secrets.GITHUB_TOKEN }} - name: Set up Llama run: | curl -fsSL https://ollama.com/install.sh | sh