blob: 26822f20b02e43e88be3f1d7094a7d1eff482dc1 [file] [log] [blame]
Earl Lee2e463fb2025-04-17 11:22:22 -07001# Simplified Commit Queue
2#
3# (Force) push to "queue-main-$USER" a potential change, and
4# this job will push it main if it passes pre-commit and tests,
5# which will run in parallel. The push may fail if the commit
6# cannot be pushed cleanly because it needs to be rebased, which
7# will happen especially if another developer pushes a change at
8# roughly the same time.
Josh Bleecher Snyderefda3962025-04-30 13:09:42 -07009#
10# Please keep this file in sync with queue-dev.yml.
Earl Lee2e463fb2025-04-17 11:22:22 -070011
12name: Main Branch Commit Queue
13on:
14 push:
15 branches:
Josh Bleecher Snyderbd6c1682025-04-25 12:04:07 -070016 - "queue-main-*"
Earl Lee2e463fb2025-04-17 11:22:22 -070017
18permissions: read-all
19
20jobs:
Josh Bleecher Snyderbd6c1682025-04-25 12:04:07 -070021 formatting:
22 uses: ./.github/workflows/formatting.yml
Josh Bleecher Snyderae772262025-04-25 20:02:22 +000023 permissions:
24 contents: write
Josh Bleecher Snyderbd6c1682025-04-25 12:04:07 -070025 with:
26 auto_fix: true
27
Philip Zeyliger4de80d22025-04-23 12:33:31 -070028 go-test:
Josh Bleecher Snyderbd6c1682025-04-25 12:04:07 -070029 needs: [formatting]
Earl Lee2e463fb2025-04-17 11:22:22 -070030 uses: ./.github/workflows/go_test.yml
31 permissions: read-all
Josh Bleecher Snyder936ba622025-04-30 20:53:21 +000032 with:
33 ref: ${{ needs.formatting.outputs.commit_sha }}
Earl Lee2e463fb2025-04-17 11:22:22 -070034
Philip Zeyliger4de80d22025-04-23 12:33:31 -070035 ui-test:
Josh Bleecher Snyderbd6c1682025-04-25 12:04:07 -070036 needs: [formatting]
Philip Zeyliger4de80d22025-04-23 12:33:31 -070037 uses: ./.github/workflows/webui_test.yml
38 permissions: read-all
Josh Bleecher Snyder936ba622025-04-30 20:53:21 +000039 with:
40 ref: ${{ needs.formatting.outputs.commit_sha }}
Philip Zeyliger4de80d22025-04-23 12:33:31 -070041
Earl Lee2e463fb2025-04-17 11:22:22 -070042 push-to-main:
43 runs-on: ubuntu-latest
Josh Bleecher Snyderc3391a92025-04-25 21:03:33 +000044 needs: [go-test, ui-test, formatting]
Earl Lee2e463fb2025-04-17 11:22:22 -070045 permissions:
46 contents: write
47 steps:
48 - uses: actions/checkout@v4
49 with:
50 fetch-depth: 0
51
52 - name: Push to main
Josh Bleecher Snyder6e463602025-05-28 18:10:59 +000053 id: push
Earl Lee2e463fb2025-04-17 11:22:22 -070054 run: |
Josh Bleecher Snydereda2a8c2025-04-25 21:24:11 +000055 COMMIT_TO_PUSH="HEAD"
Josh Bleecher Snyderc3391a92025-04-25 21:03:33 +000056 if [[ "${{ needs.formatting.outputs.commit_sha }}" != "" ]]; then
57 echo "Using formatted commit: ${{ needs.formatting.outputs.commit_sha }}"
Josh Bleecher Snydereda2a8c2025-04-25 21:24:11 +000058 COMMIT_TO_PUSH="${{ needs.formatting.outputs.commit_sha }}"
Josh Bleecher Snyderc3391a92025-04-25 21:03:33 +000059 fi
Josh Bleecher Snyder10489732025-04-30 12:49:10 -070060
Josh Bleecher Snyder6e463602025-05-28 18:10:59 +000061 # Get the actual commit SHA that we're pushing
62 COMMIT_SHA=$(git rev-parse "${COMMIT_TO_PUSH}")
63 echo "commit_sha=${COMMIT_SHA}" >> $GITHUB_OUTPUT
64
Josh Bleecher Snyder837699b2025-05-28 18:58:17 +000065 # Get the list of commits that will be pushed (in chronological order)
66 COMMITS_TO_NOTIFY=$(git log origin/main.."${COMMIT_TO_PUSH}" --reverse --format="%H" | tr '\n' ' ')
67 echo "commits_to_notify=${COMMITS_TO_NOTIFY}" >> $GITHUB_OUTPUT
68 echo "Commits to be pushed and notified: ${COMMITS_TO_NOTIFY}"
69
Josh Bleecher Snyderb74b5262025-04-30 12:53:46 -070070 git push https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git "${COMMIT_TO_PUSH}":main
Josh Bleecher Snyderddc81422025-04-25 19:47:05 +000071 env:
72 GITHUB_TOKEN: ${{ github.token }}
Josh Bleecher Snyder6e463602025-05-28 18:10:59 +000073
Josh Bleecher Snyder837699b2025-05-28 18:58:17 +000074 - name: Send Discord notifications for all pushed commits
Josh Bleecher Snyder6e463602025-05-28 18:10:59 +000075 if: success()
76 env:
77 DISCORD_WEBHOOK_FOR_COMMITS: ${{ secrets.DISCORD_WEBHOOK_FOR_COMMITS }}
Josh Bleecher Snyder837699b2025-05-28 18:58:17 +000078 run: |
79 COMMITS="${{ steps.push.outputs.commits_to_notify }}"
80 if [[ -z "$COMMITS" ]]; then
81 echo "No commits to notify about"
82 exit 0
83 fi
84
85 echo "Sending Discord notifications for commits: $COMMITS"
86 for commit_sha in $COMMITS; do
87 echo "Sending notification for commit: $commit_sha"
88 git checkout "$commit_sha"
89 GITHUB_SHA="$commit_sha" python3 .github/scripts/discord_notify.py
90 done