Context

Apache Airflow started to experience a lot of problems with TravisCI that was used so far and looked for another solution.

The problems are documented in https://lists.apache.org/thread.html/8bfee0f0a52b7b8b9ec63724c48f76a7002aeacf7c86c5a23b48f172@%3Cdev.airflow.apache.org%3E . and in https://lists.apache.org/list.html?dev@airflow.apache.org but summarizing it:

  • Travis CI has little incentive to support OSS projects
  • Their service deteriorates continuously
  • We have little to no influence on fixing problems even Apache Infrastructure team is involved
  • GitHub released fully-featured CI/CD solution - GitHub Actions and it is very well

Considerations


  • We considered cost of running the builds
  • The system had to be easy to integrate with GitHub including passing status of the build back to GitHub
  • The system should be self-maintainable - with as little special Development/Ops maintenance needed.
  • We should be able to move gradually out of old Travis CI builds working (being able to run builds from own Travis CI forks as needed).

The Architecture

Apache Airflow chose GitHub Actions and build the whole CI solution on it. It turned out to be robust and seamless to run.

The architecture of the proposed solutions is shown below. It describes Apache Airflow Architecture, but it should be applicable to other projects:


UPDATE: Apache Airflow has changed the process since - there is no more automated push to DockerHub - all the CI images are only automatically published in GHCR.IO for the purpose of development and CI.  Apache Airflow switched to manual process of publishing RC and RELASE images by the release manage (using semi-automation of course). Similarly as preparing the releases, building and pushing the images is now executed on the release manager-controlled hardware. Once the image is locally built it is pushed to DockerHub using personal authentication of the release manager.




The following components are part of the CI infrastructure

  • Apache Airflow Code Repository - the code repository at https://github.com/apache/airflow
  • Apache Airflow Forks - forks of the Apache Airflow Code Repository from which contributors make Pull Requests
  • GitHub Actions -  (GA) UI + execution engine for our jobs
  • GA CRON trigger - GitHub Actions CRON triggering our jobs
  • GA Workers - virtual machines running our jobs at GitHub Actions (max 20 in parallel)
  • GitHub Private Image Registry  - image registry used as build cache for CI  jobs. It is at https://docker.pkg.github.com/apache/airflow/airflow
  • DockerHub Public Image Registry - publicly available image registry at DockerHub. It is at https://hub.docker.com/repository/docker/apache/airflow
  • DockerHub Build Workers - virtual machines running build jibs at DockerHub
  • Official Images (future) - these are official images that are prominently visible in DockerHub. We aim our images to become official images so that you will be able to pull them with `docker pull apache-airflow`

CI run categories

The following CI Job runs are currently run for Apache Airflow, and each of the runs have different purpose and context.

- Pull Request Run - Those runs are results of PR from the forks made by contributors. Most builds for Apache Airflow fall into this category. They are executed in the context of the "Fork", not main Airflow Code Repository which means that they have only "read" permission to all the GitHub resources (container registry, code repository). This is necessary as the code in those PRs (including CI job definition) might be modified by people who are not committers for the Apache Airflow Code Repository. The main purpose of those jobs is to check if PR builds cleanly, if the test run properly and if the PR is ready to review and merge. The runs are using cached images from the Private GitHub registry - CI, Production Images as well as base Python images that are also cached in the Private GitHub registry.


- Direct Push/Merge Run - Those runs are results of direct pushes done by the committers or as result of merge of a Pull Request by the committers. Those runs execute in the context of the Apache Airflow Code Repository and have also write permission for GitHub resources  (container registry, code repository). The main purpose for the run is to check if the code after merge still holds all the assertions - like whether it still builds, all tests are green. This is needed because some of the conflicting changes from multiple PRs might cause build and test failures after merge even if they do not fail in isolation. Also those runs are already reviewed and confirmed by the committers so they can be used to do some housekeeping - for now they are pushing most recent image build in the PR to the Github Private Registry - which is our image cache for all the builds. Another purpose of those runs is to refresh latest Python base images. Python base images are refreshed with varying frequency (once every few months usually but sometimes several times per week) with the latest security and bug fixes. Those patch level images releases can occasionally break Airflow builds (specifically Docker image builds based on those images) therefore in PRs we always use latest "good" python image that we store in the private GitHub cache. The direct push/master builds are not using registry cache to pull the python images - they are directly pulling the images from DockerHub, therefore they will try the latest images after they are released and in case they are fine, CI Docker image is build and tests are passing - those jobs will push the base images to the private GitHub Registry so that they be used by subsequent PR runs.

- Scheduled Run - those runs are results of (nightly) triggered job - only for master branch. The main purpose of the job is to check if there was no impact of external dependency changes on the Apache Airflow code (for example transitive dependencies released that fail the build). It also checks if the Docker images can be build from the scratch (again - to see if some dependencies have not changed - for example downloaded package releases etc. Another reason for the nightly build is that the builds tags most recent master with nightly-master tag so that DockerHub build can pick up the moved tag and prepare a nightly public master build in the DockerHub registry. The v1-10-test branch images are build in DockerHub when pushing v1-10-stable manually

All runs consist of the same jobs, but the jobs behave slightly differently or they are skipped in different runs. Here is a summary of the run types with regards of the jobs they are running. Those jobs often have matrix run strategy which runs several different variations of the jobs (with different Backend type /Python version, type of the tests to run for example)

Job

Description 

Pull Request Run

Direct Push/Merge Run

Scheduled Run

* Builds all images from scratch

Static checks 1Performs first set of static checksYesYesYes *
Static checks 2Performs second set of static checksYesYesYes *
DocsBuilds documentationYesYesYes *
Build Prod ImageBuilds production imageYesYesYes *
Prepare Backport packagesPrepares Backport Packages for 1.10.*YesYesYes *
Pyfiles

Counts how many python files changed in the  change.

Used to determine if tests should be run

YesYes (but it is not used)Yes (but it is not used)
TestsRun all the combinations of Pytest tests for Python codeYes (if pyfiles count >0)YesYes*
Quarantined testsThose are tests that are flaky and we need to fix themYes (if pyfiles count >0)YesYes *
Requirements

Checks if requirement constraints in the code are up-to-date

Yes (fails if missing requirement)

Yes

Fails if missing requirement

Yes *

Eager dependency upgrade

Does not fail for changed requirements

Pull Python from cachePulls Python base images from Github Private Image registry to keep the last good python image used in PRsYesNo-
Push Python from cachePushes Python base images to Github Private Image registry - checks if latest image is fine and pushes if so-Yes-
Push Prod image 

Pushes production images to GitHub Private Image Registry

This is to cache the build images for following runs.

-Yes-
Push CI image

Pushes CI images to GitHub Private Image Registry

This is to cache the build images for following runs.

-Yes-
Tag Repo nightly

Tags the repository with nightly tag

It is a lightweight tag that moves nightly

--

Yes.

Triggers DockerHub build for public registry