| Earl Lee | 2e463fb | 2025-04-17 11:22:22 -0700 | [diff] [blame] | 1 | # 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 Snyder | efda396 | 2025-04-30 13:09:42 -0700 | [diff] [blame] | 9 | # |
| 10 | # Please keep this file in sync with queue-dev.yml. |
| Earl Lee | 2e463fb | 2025-04-17 11:22:22 -0700 | [diff] [blame] | 11 | |
| 12 | name: Main Branch Commit Queue |
| 13 | on: |
| 14 | push: |
| 15 | branches: |
| Josh Bleecher Snyder | bd6c168 | 2025-04-25 12:04:07 -0700 | [diff] [blame] | 16 | - "queue-main-*" |
| Earl Lee | 2e463fb | 2025-04-17 11:22:22 -0700 | [diff] [blame] | 17 | |
| 18 | permissions: read-all |
| 19 | |
| 20 | jobs: |
| Josh Bleecher Snyder | bd6c168 | 2025-04-25 12:04:07 -0700 | [diff] [blame] | 21 | formatting: |
| 22 | uses: ./.github/workflows/formatting.yml |
| Josh Bleecher Snyder | ae77226 | 2025-04-25 20:02:22 +0000 | [diff] [blame] | 23 | permissions: |
| 24 | contents: write |
| Josh Bleecher Snyder | bd6c168 | 2025-04-25 12:04:07 -0700 | [diff] [blame] | 25 | with: |
| 26 | auto_fix: true |
| 27 | |
| Philip Zeyliger | 4de80d2 | 2025-04-23 12:33:31 -0700 | [diff] [blame] | 28 | go-test: |
| Josh Bleecher Snyder | bd6c168 | 2025-04-25 12:04:07 -0700 | [diff] [blame] | 29 | needs: [formatting] |
| Earl Lee | 2e463fb | 2025-04-17 11:22:22 -0700 | [diff] [blame] | 30 | uses: ./.github/workflows/go_test.yml |
| 31 | permissions: read-all |
| Josh Bleecher Snyder | 936ba62 | 2025-04-30 20:53:21 +0000 | [diff] [blame] | 32 | with: |
| 33 | ref: ${{ needs.formatting.outputs.commit_sha }} |
| Philip Zeyliger | c314f0c | 2025-07-16 16:48:46 -0700 | [diff] [blame] | 34 | include-slow-tests: false |
| Earl Lee | 2e463fb | 2025-04-17 11:22:22 -0700 | [diff] [blame] | 35 | |
| Philip Zeyliger | 4de80d2 | 2025-04-23 12:33:31 -0700 | [diff] [blame] | 36 | ui-test: |
| Josh Bleecher Snyder | bd6c168 | 2025-04-25 12:04:07 -0700 | [diff] [blame] | 37 | needs: [formatting] |
| Philip Zeyliger | 4de80d2 | 2025-04-23 12:33:31 -0700 | [diff] [blame] | 38 | uses: ./.github/workflows/webui_test.yml |
| 39 | permissions: read-all |
| Josh Bleecher Snyder | 936ba62 | 2025-04-30 20:53:21 +0000 | [diff] [blame] | 40 | with: |
| 41 | ref: ${{ needs.formatting.outputs.commit_sha }} |
| Philip Zeyliger | 4de80d2 | 2025-04-23 12:33:31 -0700 | [diff] [blame] | 42 | |
| Earl Lee | 2e463fb | 2025-04-17 11:22:22 -0700 | [diff] [blame] | 43 | push-to-main: |
| 44 | runs-on: ubuntu-latest |
| Josh Bleecher Snyder | c3391a9 | 2025-04-25 21:03:33 +0000 | [diff] [blame] | 45 | needs: [go-test, ui-test, formatting] |
| Earl Lee | 2e463fb | 2025-04-17 11:22:22 -0700 | [diff] [blame] | 46 | permissions: |
| 47 | contents: write |
| 48 | steps: |
| 49 | - uses: actions/checkout@v4 |
| 50 | with: |
| 51 | fetch-depth: 0 |
| 52 | |
| 53 | - name: Push to main |
| Josh Bleecher Snyder | 6e46360 | 2025-05-28 18:10:59 +0000 | [diff] [blame] | 54 | id: push |
| Earl Lee | 2e463fb | 2025-04-17 11:22:22 -0700 | [diff] [blame] | 55 | run: | |
| Josh Bleecher Snyder | eda2a8c | 2025-04-25 21:24:11 +0000 | [diff] [blame] | 56 | COMMIT_TO_PUSH="HEAD" |
| Josh Bleecher Snyder | c3391a9 | 2025-04-25 21:03:33 +0000 | [diff] [blame] | 57 | if [[ "${{ needs.formatting.outputs.commit_sha }}" != "" ]]; then |
| 58 | echo "Using formatted commit: ${{ needs.formatting.outputs.commit_sha }}" |
| Josh Bleecher Snyder | eda2a8c | 2025-04-25 21:24:11 +0000 | [diff] [blame] | 59 | COMMIT_TO_PUSH="${{ needs.formatting.outputs.commit_sha }}" |
| Josh Bleecher Snyder | c3391a9 | 2025-04-25 21:03:33 +0000 | [diff] [blame] | 60 | fi |
| Josh Bleecher Snyder | 1048973 | 2025-04-30 12:49:10 -0700 | [diff] [blame] | 61 | |
| Josh Bleecher Snyder | 6e46360 | 2025-05-28 18:10:59 +0000 | [diff] [blame] | 62 | # Get the actual commit SHA that we're pushing |
| 63 | COMMIT_SHA=$(git rev-parse "${COMMIT_TO_PUSH}") |
| 64 | echo "commit_sha=${COMMIT_SHA}" >> $GITHUB_OUTPUT |
| 65 | |
| Philip Zeyliger | fb56a5c | 2025-07-16 22:38:38 +0000 | [diff] [blame] | 66 | # Ensure we have the latest main branch reference |
| 67 | git fetch origin main |
| 68 | |
| Josh Bleecher Snyder | 837699b | 2025-05-28 18:58:17 +0000 | [diff] [blame] | 69 | # Get the list of commits that will be pushed (in chronological order) |
| Philip Zeyliger | fb56a5c | 2025-07-16 22:38:38 +0000 | [diff] [blame] | 70 | # Use FETCH_HEAD as the base to avoid rewriting local main reference |
| 71 | COMMITS_TO_NOTIFY=$(git log FETCH_HEAD.."${COMMIT_TO_PUSH}" --reverse --format="%H" | tr '\n' ' ') |
| Josh Bleecher Snyder | 837699b | 2025-05-28 18:58:17 +0000 | [diff] [blame] | 72 | echo "commits_to_notify=${COMMITS_TO_NOTIFY}" >> $GITHUB_OUTPUT |
| 73 | echo "Commits to be pushed and notified: ${COMMITS_TO_NOTIFY}" |
| 74 | |
| Josh Bleecher Snyder | b74b526 | 2025-04-30 12:53:46 -0700 | [diff] [blame] | 75 | git push https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git "${COMMIT_TO_PUSH}":main |
| Josh Bleecher Snyder | ddc8142 | 2025-04-25 19:47:05 +0000 | [diff] [blame] | 76 | env: |
| 77 | GITHUB_TOKEN: ${{ github.token }} |
| Josh Bleecher Snyder | 6e46360 | 2025-05-28 18:10:59 +0000 | [diff] [blame] | 78 | |
| Josh Bleecher Snyder | 837699b | 2025-05-28 18:58:17 +0000 | [diff] [blame] | 79 | - name: Send Discord notifications for all pushed commits |
| Josh Bleecher Snyder | 6e46360 | 2025-05-28 18:10:59 +0000 | [diff] [blame] | 80 | if: success() |
| 81 | env: |
| 82 | DISCORD_WEBHOOK_FOR_COMMITS: ${{ secrets.DISCORD_WEBHOOK_FOR_COMMITS }} |
| Josh Bleecher Snyder | 837699b | 2025-05-28 18:58:17 +0000 | [diff] [blame] | 83 | run: | |
| 84 | COMMITS="${{ steps.push.outputs.commits_to_notify }}" |
| 85 | if [[ -z "$COMMITS" ]]; then |
| 86 | echo "No commits to notify about" |
| 87 | exit 0 |
| 88 | fi |
| 89 | |
| 90 | echo "Sending Discord notifications for commits: $COMMITS" |
| 91 | for commit_sha in $COMMITS; do |
| 92 | echo "Sending notification for commit: $commit_sha" |
| 93 | git checkout "$commit_sha" |
| 94 | GITHUB_SHA="$commit_sha" python3 .github/scripts/discord_notify.py |
| 95 | done |