Skip to content

Commit

Permalink
Optimize direct push workflows in GitHub Actions (apache#22542)
Browse files Browse the repository at this point in the history
When the build is run via direct push to apache airflow repo
we do not need to run two separate workflows. The "push" workflow
is never a "pull request from fork" so it should have
the capability to build and push images to registry.

This allows the committers to make direct push requests to run PRs
that are actually running the build without having to merge
build-image.yml first.

This is cool because committers can simply push a branch to apache
and test if it works with some build image changes that otherwise
would require to push to `main` of an apache-airflow fork.

Another advantage is that merge and schedule builds do not run two
separate workflows - both building the image and running tests is done
in the same workflow (and the build-image workflow is not started)
This saves some build time on "wait for CI images" and
"wait for PROD images" jobs - because in merge builds and
schedule builds they only start after the images are actually
built.
  • Loading branch information
potiuk authored Mar 26, 2022
1 parent f482ae5 commit bf0a11c
Show file tree
Hide file tree
Showing 6 changed files with 414 additions and 214 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@
---
name: "Build Images"
on: # yamllint disable-line rule:truthy
schedule:
- cron: '28 0 * * *'
pull_request_target:
push:
branches: ['main', 'v[0-9]+-[0-9]+-test']
permissions:
# all other permissions are set to none
contents: read
Expand Down Expand Up @@ -168,7 +164,9 @@ jobs:
matrix:
python-version: ${{ fromJson(needs.build-info.outputs.allPythonVersions) }}
fail-fast: true
if: needs.build-info.outputs.image-build == 'true'
if: |
needs.build-info.outputs.image-build == 'true' &&
github.event.pull_request.repo.head.full_name != 'apache/airflow'
env:
RUNS_ON: ${{ fromJson(needs.build-info.outputs.runsOn)[0] }}
BACKEND: sqlite
Expand Down Expand Up @@ -254,7 +252,9 @@ jobs:
matrix:
python-version: ${{ fromJson(needs.build-info.outputs.allPythonVersions) }}
fail-fast: true
if: needs.build-info.outputs.image-build == 'true'
if: |
needs.build-info.outputs.image-build == 'true' &&
github.event.pull_request.repo.head.full_name != 'apache/airflow'
env:
RUNS_ON: ${{ fromJson(needs.build-info.outputs.runsOn)[0] }}
BACKEND: sqlite
Expand Down
Loading

0 comments on commit bf0a11c

Please sign in to comment.