flatcar-scripts/ci-automation
James Le Cuirot d1ba9b19fb
Switch from raw (.fd) EDK2 firmware images to QCOW2, plus 4MB on amd64
The new arm64 firmware supporting Secure Boot (see next commit) is in
QCOW2 format only, avoiding the extra space taken up by the 64MB
padding. Supporting both raw and QCOW2 images would be messy, so switch
entirely to QCOW2.

Only the 4MB images are in QCOW2 format on amd64, so also switch away
from the 2MB images. 4MB images are now the default for most
distributions as they are needed to apply certain Windows updates.

Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
2024-11-12 11:59:40 +00:00
..
python-bin python: install feedparser for Kernel CVEs fetching 2024-09-02 09:52:06 +02:00
util Apply suggestions of my favourite proofreader 2022-03-02 10:09:59 +01:00
vendor-testing ci-automation: Include --qemu-ovmf-vars in qemu_update test for arm64 2024-11-12 11:59:22 +00:00
base_sysexts.sh build_image,ci-automation: Add app-containers/docker-buildx to docker-flatcar sysext 2024-09-02 14:05:56 +02:00
ci_automation_common.sh torcx removal: address PR comments 2023-10-23 16:05:45 +02:00
ci-config.env Switch from raw (.fd) EDK2 firmware images to QCOW2, plus 4MB on amd64 2024-11-12 11:59:40 +00:00
garbage_collect_cloud.sh ci-automation: Drop azure auth flags 2024-07-02 17:05:15 +02:00
garbage_collect_github_ci_sdk.sh ci-automation/garbage_collect: add cached release artifacts 2024-01-30 14:59:00 +01:00
garbage_collect_releases.sh garbage_collect_releases.sh: more readable variables in AWK script 2024-02-14 18:30:12 +01:00
garbage_collect.sh Migrate release AMI gc to ci-automation 2024-04-24 16:52:11 +09:00
gpg_setup.sh ci-automation: use --batch when importing gpg key 2022-10-04 10:22:43 +02:00
image_changes.sh ci-automation/image-changes: Simplify a bit 2024-08-15 14:45:40 +02:00
image.sh ci: Build sysexts together with image 2024-03-11 11:57:45 +00:00
packages-tag.sh ci-automation/sdk_bootstrap: Put some names into variables 2023-09-28 17:22:09 +02:00
packages.sh ci-automation: remove torcx artifact handling and tests 2023-10-23 16:05:45 +02:00
push_pkgs.sh build_dev_binpkgs: Ensure adevcontainer binpkgs are built 2023-12-18 10:46:05 +01:00
README.md ci-automation: remove torcx artifact handling and tests 2023-10-23 16:05:45 +02:00
release.sh ci-automation: Drop azure auth flags 2024-07-02 17:05:15 +02:00
sdk_bootstrap.sh ci-automation: Update the SDK container extension in check 2023-10-10 12:52:44 +02:00
sdk_container.sh scripts, CI, workflows: remove submodule handling (main) 2023-04-13 12:26:36 +02:00
tapfile_helper_lib.sh tapfile_helper: fix foldable details output 2023-05-03 10:57:02 +02:00
test_update_reruns.sh tapfile_helper ff.: support TAP and Markdown output 2023-03-29 21:05:47 +02:00
test.sh ci-automation/test: Always pull mantle image when running tests 2024-03-15 14:44:08 +01:00
vendor_test.sh ci-automation: remove torcx artifact handling and tests 2023-10-23 16:05:45 +02:00
vms.sh oem: provide proxmox images 2024-11-12 12:51:36 +01:00

CI automation glue logic scripts

Scripts in this directory aim to ease automation of Flatcar builds in continuous integration systems.

Design goal of the automation scripts is to provide self-contained, context-aware automation with a low integration overhead. Each step takes its context from the repository (version to build etc.) and from the artifact of the previous build, with the aim of reducing the number of arguments to an absolute minimum.

Each script represents a distinct build step; each step ingests the container image of the previous step and produces a new container image for the next step. Notable exceptions are "SDK Bootstrap" (sdk.sh) which only creates an SDK tarball, and "VMs build" which does not output a container but only VM (vendor) images. The container images are self-contained and aim for ease of reproducibility. All steps make use of a "build cache" server for pulling (https) build inputs and for pushing (rsync) artifacts.

Test automation is provided alongside build automation, following the same design principles.

Please refer to the individual scripts for prerequisites, input parameters, and outputs.

Build steps

The build pipeline can be used to build everything from scratch, including the SDK (starting from 1. below) or to build a new OS image (starting from 3.). "From scratch" builds (i.e. builds which include a new SDK) are usually only done for the main branch (main can be considered alpha-next). Release / maintenance branches in the majority of cases do note build a new SDK but start with the OS image build. Release branches usually use the SDK introduced when the new major version was branched off main throughout the lifetime of the major version; i.e. release stable-MMMM.mm.pp would use SDK-MMMM.0.0.

To reproduce any given build step, follow this pattern:

./checkout <build-tag> # Build tag from either SDK bootstrap pr Packages step
source ci-automation/<step-script>.sh
<step_function> <parameters>

For example, to rebuild the AMD64 OS image of build main-3145.0.0-nightly-20220209-0139, do

./checkout main-3145.0.0-nightly-20220209-0139
source ci-automation/image.sh
image_build amd64

SDK bootstrap build

  1. SDK Bootstrap (sdk.sh): Use a seed SDK tarball and seed SDK container image to build a new SDK tarball. The resulting SDK tarball will ship packages and versions from the updated coreos-overlay and portage-stable ebuild directories. This step updates the versionfile, recording the SDK container version just built. It will generate and push a new version tag to the scripts repo.
  2. SDK container build (sdk_container.sh) : use SDK tarball to build an SDK container image. The resulting image will come in "amd64", "arm64", and "all" flavours, with support for respective OS target architectures. This step builds the Flatcar SDK container images published at ghcr.io/flatcar.
         .---------.                    .------------.          .--------.
         | scripts |                    |     CI     |          |  Build |
         |  repo   |                    | automation |          |  cache |
         `---------´                    `------------´          `--------´
              |                                |                     |
              |                      "alpha-3449.0.0-dev23"          |
              |                                |                     |
              |                         _______v_______              |
              +-------- clone -------> ( SDK bootstrap )             |
              |                         `-------------´              |
              |<- tag: alpha-3499.0.0-dev23 --´|`--- sdk tarball --->|
              |                                |                     |
              |                         _______v_______              |
              +-------- clone -------> ( SDK container )             |
              | alpha-3499.0.0-dev23    `-------------´              |
              |                                |`- sdk container --->|
              v                                v        image
                      continue to OS
                       image build
                            |
                            v 

OS image build

  1. Packages tag (packages-tag.sh): Creates git tag if needed with the SDK container version recorded in the versionfile and the OS version from the tag. Creates skip-build flag file if no changes since last nightly tag are seen. Pushes the new version tag to the scripts repo as free-standing tag, and for nightlies also to the branch.
  2. Packages build (packages.sh): Build OS image packages and generate a new container image (containing both SDK and packages).
  3. Packages are published and the generic OS image is built.
    1. Binary packages are published (push_pkgs.sh) to the build cache, making them available to developers who base their work on the main branch.
    2. Image build (image.sh): Using the container from 3., build an OS image, and generate a new container image with everything in it.
  4. VMs build (vms.sh). Using the packages+image container from 4., build vendor images. Results are vendor-specific OS images.
       .---------.                     .------------.             .--------.
       | scripts |                     |     CI     |             |  Build |
       |  repo   |                     | automation |             |  cache |
       `---------´                     `------------´             `--------´
            |                                 |                        |
            |                       "alpha-3449.0.0-dev23"             |
            |                                 |                        |
            |                           ______v_______                 |
            +---------- clone ------>  ( packages-tag )                |
            |                           `------------´                 |
            |<-- tag: alpha-3499.0.0-dev23 --´|                        |
            |                             ____v_____                   |
            +-----       clone      ---> ( packages )                  |
            |    alpha-3499.0.0-dev23     `--------´                   |
            |                                 |`- sdk + OS packages -->|
            |                                 |    container image     |
            |                                 |                        |
            |                           ______v_______                 |
            |                          ( publish pkgs )                |
            |                           `------------´                 |
            |                                 |`-- binary packages --->|
            |                              ___v__                      |
            +-----       clone      --->  ( image )                    |
            |    alpha-3499.0.0-dev23      `-----´                     |
            |                                 |`-- sdk + packages + -->|
            |                               __v__  OS image cnt img    |
            +-----       clone      --->   ( vms )                     |
                 alpha-3499.0.0-dev23       `---´                      |
                                              `- vendor OS images ---->|

Local Patches

For embargoed relases the build system looks for patch files ../scripts.patch, ../overlay.patch, ../portage.patch (i.e., in the folder that contains the scripts repo) and applies them locally before building.

Testing

Testing follows the same design principles build automation adheres to - it's self-contained and context-aware, reducing required parameters to a minimum. The test.sh script needs exactly two parameters: the architecture, and the image type to be tested. Optionally, patterns matching a group of tests can be supplied (or simply a list of tests); this defaults to "all tests" of a given vendor / image. test.sh also supports re-running failed tests automatically to reduce the need for human interaction on flaky tests.

Testing is implemented in two layers:

  1. ci-automation/test.sh is a generic test wrapper / stub to be called from CI.
  2. ci-automation/vendor-testing/ contains low-level vendor-specific test wrappers around kola, our test scenario orchestrator.

Testing relies on the SDK container and will use tools / test suites from the SDK. The low-level vendor / image specific script (layer 2. in the list above) runs inside the SDK. Testing will use the vendor image published by vms.sh from buildcache.

Additionally, a script library is provided (at ci-automation/tapfile_helper_lib.sh) to help handling .tap test result files produced by test runs. Library functions may be used to merge the result of multiple test runs (e.g. for multiple image types / vendors) into a single test result report. The test runs are considered successful only if all tests succeeded for all vendors / images at least once.

Usage

./checkout <version-to-test>
source ci-automation/test.sh
test_run <arch> <image-type>

E.g. for running qemu / amd64 tests on main-3145.0.0-nightly-20220209-0139:

./checkout main-3145.0.0-nightly-20220209-0139
source ci-automation/test.sh
test_run amd64 qemu

QEmu test

ci-automation/vendor-testing/qemu.sh implements a kola wrapper for testing the qemu image. The wrapper is a straightforward call to kola and does not have any additional requirements.

NOTE that the generic image (flatcar_production_image.bin) is used for the test instead of the QEmu vendor image.

NOTE on host firewalling The test automation uses bridged networking and will handle forwarding and NAT. However, we experienced test failures from lack of internet access with several firewall implementations. It is recommended to stop firewalling on the host the tests are run on (for example, use systemctl stop firewalld if the host used firewalld).

Settings

  • QEMU_IMAGE_NAME - file name of the QEmu image to fetch from bincache.
  • QEMU_PARALLEL - Number of parallel test cases to run. Note that test cases may involve launching mutliple QEmu VMs (network testing etc.). Tests are memory bound, not CPU bound; e.g. 20 is a sensible value for a 6 core / 12 threads systwem w/ 32 GB RAM.