-
Notifications
You must be signed in to change notification settings - Fork 14.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Streamline Build Images workflow using new GitHub Actions features #15944
Streamline Build Images workflow using new GitHub Actions features #15944
Conversation
Use `pull_request_target` event for building images, and `concurrency` to automatically cancel old jobs for PRs. This means that: - GitHub will automatically cancel old jobs for us, so we don't have to handle that ourselves (removes most of the use of the cancel-workflow-action) - GitHub displays these checks directly on the PR, but it is still run in the context of our repo, meaning it has access write to our repo/access to secrets etc. - Since it shows up directly on the PR checks, we don't need to create the check in the "CI" workflow to show the status of the Image Build. - We also don't need to post the comment saying _why_ it failed, as the Build Image status will show up directly there - Since `pull_request_target` has information about the PR in the `github.event` context, we don't need the complex mechanism to find the "other" PR, we can do a fairly simple API request and filter by the commit SHA to find and cancel to CI workflow job. (This removes the final use of the cancel-workflow-action) One change I had to make here what tag we use for Docker images we build and push up. Previously we used the "source run ID" (i.e. the id of the CI run) but with pull_request_target we don't have that anymore. We could use the same API mechanism we do to cancel to find the target job, but the only requirement here is for an ID that both jobs know -- the SHA of the PR branch fills that need Extra side benefits of this: - The sidebar of commits in main branch aren't "polluted" with Build Images for PRs like they were previously.
I've been testing this out on my fork here ashb#9 -- that is a PR opened from a different user. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
COOL. ❤️ It. The concurrency
removes major pain out with the cancelling and having it all in one PR makes it cool.
I love to retire the total madness of the complexity of cancelling because of lack of support from GitHub Actions so far :)
Good stuff @ashb !
Ths might be not needed. We just need to print SHA in output of tests in instructions and we can use SHA directly. No need to use build ID, maybe just rename the parameter |
notifyPRCancel: true | ||
jobNameRegexps: > | ||
["^Pylint$", "^Static checks", "^Build docs$", "^Spell check docs$", | ||
"^Provider packages", "^Checks: Helm tests$", "^Test OpenAPI*"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, this step is still probably needed, meaning we can't remove the cancel-workflow_runs action entirely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's an optimisation only, and I am not sure if thats' so much needed after we sped up most of the builds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Selective checks already take care about most savings we have.
Happy to merge this one even without the "fast-fail" for the names of the jobs. I have already put the "deprecation notice" in my action : https://github.com/potiuk/cancel-workflow-runs#readme after the One less thing to maintain :) |
@potiuk Cool, can you give this a ✅ then please? And then once merged lets see if we need every open PR to rebase to pick it up or not :/ |
The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest master at your convenience, or amend the last commit of the PR, and push it with --force-with-lease. |
I think no rebase is neeed. It should just work . The name of images did not change, and this is the only interface between the workflows. |
🤞🏻 |
I think this was added as a DEBUG step which was forgotten to remove in apache#15944
I think this was added as a DEBUG step which was forgotten to remove in #15944
…pache#15944) Use `pull_request_target` event for building images, and `concurrency` to automatically cancel old jobs for PRs. This means that: - GitHub will automatically cancel old jobs for us, so we don't have to handle that ourselves (removes most of the use of the cancel-workflow-action) - GitHub displays these checks directly on the PR, but it is still run in the context of our repo, meaning it has access write to our repo/access to secrets etc. - Since it shows up directly on the PR checks, we don't need to create the check in the "CI" workflow to show the status of the Image Build. - We also don't need to post the comment saying _why_ it failed, as the Build Image status will show up directly there - Since `pull_request_target` has information about the PR in the `github.event` context, we don't need the complex mechanism to find the "other" PR, we can do a fairly simple API request and filter by the commit SHA to find and cancel to CI workflow job. (This removes the final use of the cancel-workflow-action) One change I had to make here what tag we use for Docker images we build and push up. Previously we used the "source run ID" (i.e. the id of the CI run) but with pull_request_target we don't have that anymore. We could use the same API mechanism we do to cancel to find the target job, but the only requirement here is for an ID that both jobs know -- the SHA of the PR branch fills that need Extra side benefits of this: - The sidebar of commits in main branch aren't "polluted" with Build Images for PRs like they were previously. (cherry picked from commit 9c98a60)
I think this was added as a DEBUG step which was forgotten to remove in apache#15944 (cherry picked from commit 19a9fc5)
I think this was added as a DEBUG step which was forgotten to remove in apache/airflow#15944 (cherry picked from commit 19a9fc5273337ca2bb68eb669055487f81fb21d6) GitOrigin-RevId: 53805f4c027c090b02391e071ea8640e64ef6901
I think this was added as a DEBUG step which was forgotten to remove in apache/airflow#15944 (cherry picked from commit 19a9fc5273337ca2bb68eb669055487f81fb21d6) GitOrigin-RevId: 53805f4c027c090b02391e071ea8640e64ef6901
I think this was added as a DEBUG step which was forgotten to remove in apache/airflow#15944 (cherry picked from commit 19a9fc5273337ca2bb68eb669055487f81fb21d6) GitOrigin-RevId: 53805f4c027c090b02391e071ea8640e64ef6901
When image build fails, the pull request that triggered it should be cancelled. The apache#15944 introduced rewrite of the GitHub actions code but by mistake it also introduced a failure in cancelling the PR workflow by missing pipeline to jq. In most cases it did not matter, but it cause "wait for images" in PRs to run far longer than they should be. This PR restores cancelling feature.
When image build fails, the pull request that triggered it should be cancelled. The #15944 introduced rewrite of the GitHub actions code but by mistake it also introduced a failure in cancelling the PR workflow by missing pipeline to jq. In most cases it did not matter, but it cause "wait for images" in PRs to run far longer than they should be. This PR restores cancelling feature.
I think this was added as a DEBUG step which was forgotten to remove in apache/airflow#15944 GitOrigin-RevId: 19a9fc5273337ca2bb68eb669055487f81fb21d6
I think this was added as a DEBUG step which was forgotten to remove in apache/airflow#15944 GitOrigin-RevId: 19a9fc5273337ca2bb68eb669055487f81fb21d6
I think this was added as a DEBUG step which was forgotten to remove in apache/airflow#15944 GitOrigin-RevId: 19a9fc5273337ca2bb68eb669055487f81fb21d6
I think this was added as a DEBUG step which was forgotten to remove in apache/airflow#15944 GitOrigin-RevId: 19a9fc5273337ca2bb68eb669055487f81fb21d6
I think this was added as a DEBUG step which was forgotten to remove in apache/airflow#15944 GitOrigin-RevId: 19a9fc5273337ca2bb68eb669055487f81fb21d6
I think this was added as a DEBUG step which was forgotten to remove in apache/airflow#15944 GitOrigin-RevId: 19a9fc5273337ca2bb68eb669055487f81fb21d6
Currently, we have to manually cancel duplicate jobs when we push more commits to existing PRs. We use GitHub action's "[concurrency](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency)" feature in Airflow too for this: apache/airflow#15944 closes #1021
Currently, we have to manually cancel duplicate jobs when we push more commits to existing PRs. We use GitHub action's "[concurrency](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency)" feature in Airflow too for this: apache/airflow#15944 closes #1021
I think this was added as a DEBUG step which was forgotten to remove in apache/airflow#15944 GitOrigin-RevId: 19a9fc5273337ca2bb68eb669055487f81fb21d6
I think this was added as a DEBUG step which was forgotten to remove in apache/airflow#15944 GitOrigin-RevId: 19a9fc5273337ca2bb68eb669055487f81fb21d6
I think this was added as a DEBUG step which was forgotten to remove in apache/airflow#15944 GitOrigin-RevId: 19a9fc5273337ca2bb68eb669055487f81fb21d6
I think this was added as a DEBUG step which was forgotten to remove in apache/airflow#15944 GitOrigin-RevId: 19a9fc5273337ca2bb68eb669055487f81fb21d6
I think this was added as a DEBUG step which was forgotten to remove in apache/airflow#15944 GitOrigin-RevId: 19a9fc5273337ca2bb68eb669055487f81fb21d6
I think this was added as a DEBUG step which was forgotten to remove in apache/airflow#15944 GitOrigin-RevId: 19a9fc5273337ca2bb68eb669055487f81fb21d6
Use
pull_request_target
event for building images, andconcurrency
toautomatically cancel old jobs for PRs.
This means that:
GitHub will automatically cancel old jobs for us, so we don't have to
handle that ourselves (removes most of the use of the
cancel-workflow-action)
New pushes show this for a little while
And then the old job shows this as the reason
GitHub displays these checks directly on the PR, but it is still run
in the context of our repo, meaning it has access write to our
repo/access to secrets etc.
Since it shows up directly on the PR checks, we don't need to create the
check in the "CI" workflow to show the status of the Image Build.
We also don't need to post the comment saying why it failed, as the
Build Image status will show up directly there
Since
pull_request_target
has information about the PR in thegithub.event
context, we don't need the complex mechanism to findthe "other" PR, we can do a fairly simple API request and filter by
the commit SHA to find and cancel to CI workflow job. (This removes
the final use of the cancel-workflow-action)
One change I had to make here what tag we use for Docker images we build
and push up. Previously we used the "source run ID" (i.e. the id of the
CI run) but with pull_request_target we don't have that anymore. We
could use the same API mechanism we do to cancel to find the target job,
but the only requirement here is for an ID that both jobs know -- the
SHA of the PR branch fills that need
Extra side benefits of this:
Images for PRs like they were previously.
Still do do:
Update breeze to pull the new image tag format when given a numeric id (use API to look up sha that a build is for)Update docs to remove references to RUN_ID