From 40c3331cec648cb2772fb7918c285f387b6c2501 Mon Sep 17 00:00:00 2001 From: Lokesh Mandvekar Date: Fri, 15 Jul 2022 14:02:33 -0400 Subject: [PATCH] Cirrus: enable Fedora 36 aarch64 tasks on EC2 Signed-off-by: Lokesh Mandvekar --- .cirrus.yml | 136 ++++++++++++++++++++++++++++++--------- Makefile | 13 ---- contrib/cirrus/runner.sh | 31 ++++++++- contrib/cirrus/setup.sh | 15 ++++- 4 files changed, 146 insertions(+), 49 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 13d0d7329..a2a3d0999 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -21,28 +21,24 @@ env: FEDORA_NETAVARK_IMAGE: "fedora-netavark-${IMAGE_SUFFIX}" AARDVARK_DNS_BRANCH: "main" AARDVARK_DNS_URL: "https://api.cirrus-ci.com/v1/artifact/github/containers/aardvark-dns/success/binary.zip?branch=${AARDVARK_DNS_BRANCH}" + FEDORA_NETAVARK_AARCH64_AMI_ID: "ami-00d7ccde5eaacc50e" gcp_credentials: ENCRYPTED[d6efdb7d6d4c61e3831df2193ca6348bb02f26cd931695f69d41930b1965f7dab72a838ca0902f6ed8cde66c7deddae2] - -# Default VM to use unless set or modified by task -gce_instance: &standard_vm - image_project: "libpod-218412" - zone: "us-central1-c" - cpu: 2 - memory: "4Gb" - disk: 200 # GB, do not set <200 per gcloud warning re: I/O performance - image_name: "${FEDORA_NETAVARK_IMAGE}" +aws_credentials: ENCRYPTED[949b114326ca5686a3aa2990536a479cf8e5a931611b443e50579ea787faa21eb172f6fc0ebc79d7e817e4bebf417940] build_task: alias: "build" # Compiling is very CPU intensive, make it chooch quicker for this task only - gce_instance: - <<: *standard_vm - cpu: 8 - memory: "8Gb" + gce_instance: &standard_build_gce_x86_64 + image_project: "libpod-218412" + zone: "us-central1-c" + disk: 200 # GB, do not set <200 per gcloud warning re: I/O performance + cpu: 8 + memory: "8Gb" + image_name: "${FEDORA_NETAVARK_IMAGE}" cargo_cache: &cargo_cache # Populating this cache depends on execution of setup.sh, and runner.sh # to builds of all release, debug, plus unit-tests. @@ -76,30 +72,39 @@ build_task: upload_caches: [ "cargo", "targets", "bin" ] -build_cross_task: - alias: "build_cross" - cargo_cache: - <<: *cargo_cache - # Don't confuse cache architectures, bad things will happen. - fingerprint_key: "cargo_v2_${DEST_BRANCH}_arm64" - targets_cache: - <<: *targets_cache - fingerprint_key: "targets_v2_${CIRRUS_TAG}${DEST_BRANCH}${CIRRUS_PR}_arm64" # Cache only within same tag, branch, or PR (branch will be 'pull/#') - bin_cache: - <<: *bin_cache - fingerprint_key: "bin_v2_${CIRRUS_TAG}${DEST_BRANCH}${CIRRUS_PR}_arm64" # Cache only within same tag, branch, or PR (branch will be 'pull/#') +build_aarch64_task: + alias: "build_aarch64" + ec2_instance: &standard_build_ec2_aarch64 + image: "${FEDORA_NETAVARK_AARCH64_AMI_ID}" + type: t4g.xlarge + region: us-east-1 + architecture: arm64 # CAUTION: This has to be "arm64", not "aarch64" + cargo_cache: &cargo_cache_aarch64 + folder: "$CARGO_HOME" + fingerprint_key: "cargo_v2_${DEST_BRANCH}_aarch64" + reupload_on_changes: true + targets_cache: &targets_cache_aarch64 + folder: "$CARGO_TARGET_DIR" + fingerprint_key: "targets_v2_${CIRRUS_TAG}${DEST_BRANCH}${CIRRUS_PR}_aarch64" # Cache only within same tag, branch, or PR (branch will be 'pull/#') + reupload_on_changes: true + bin_cache: &bin_cache_aarch64 + # This simply prevents rebuilding bin/netavark for every subsequent task. + folder: "$CIRRUS_WORKING_DIR/bin" + fingerprint_key: "bin_v2_${CIRRUS_TAG}${DEST_BRANCH}${CIRRUS_PR}_aarch64" # Cache only within same tag, branch, or PR (branch will be 'pull/#') + reupload_on_changes: true setup_script: *setup main_script: *main - # Upload cross-compiled binary for collection by success task - # https://cirrus-ci.org/guide/writing-tasks/#artifacts-instruction - binary_artifacts: - path: ./bin/netavark* + upload_caches: [ "cargo", "targets", "bin" ] validate_task: alias: "validate" depends_on: - "build" + gce_instance: &standard_gce_x86_64 + <<: *standard_build_gce_x86_64 + cpu: 2 + memory: "4Gb" # From this point forward, all cache's become read-only - meaning # any changes made in this task aren't re-uploaded to the cache. # This avoids some flapping between tasks, along with the upload time. @@ -115,30 +120,78 @@ validate_task: setup_script: *setup main_script: *main + +validate_aarch64_task: + alias: "validate_aarch64" + depends_on: + - "build_aarch64" + ec2_instance: *standard_build_ec2_aarch64 + cargo_cache: &ro_cargo_cache_aarch64 + <<: *cargo_cache_aarch64 + reupload_on_changes: false + targets_cache: &ro_targets_cache_aarch64 + <<: *targets_cache_aarch64 + reupload_on_changes: false + bin_cache: &ro_bin_cache_aarch64 + <<: *bin_cache_aarch64 + reupload_on_changes: false + setup_script: *setup + main_script: *main + + verify_vendor_task: alias: "verify_vendor" depends_on: - "build" + gce_instance: *standard_gce_x86_64 cargo_cache: *ro_cargo_cache targets_cache: *ro_targets_cache bin_cache: *ro_bin_cache setup_script: *setup main_script: *main + +verify_vendor_aarch64_task: + alias: "verify_vendor_aarch64" + depends_on: + - "build_aarch64" + ec2_instance: *standard_build_ec2_aarch64 + cargo_cache: *ro_cargo_cache_aarch64 + targets_cache: *ro_targets_cache_aarch64 + bin_cache: *ro_bin_cache_aarch64 + setup_script: *setup + main_script: *main + + unit_task: alias: "unit" depends_on: - "build" + gce_instance: *standard_gce_x86_64 cargo_cache: *ro_cargo_cache targets_cache: *ro_targets_cache bin_cache: *ro_bin_cache setup_script: *setup main_script: *main + +unit_aarch64_task: + alias: "unit_aarch64" + depends_on: + - "build_aarch64" + ec2_instance: *standard_build_ec2_aarch64 + cargo_cache: *ro_cargo_cache_aarch64 + targets_cache: *ro_targets_cache_aarch64 + bin_cache: *ro_bin_cache_aarch64 + setup_script: *setup + main_script: *main + + integration_task: alias: "integration" depends_on: - "unit" + gce_instance: *standard_gce_x86_64 cargo_cache: *ro_cargo_cache targets_cache: *ro_targets_cache bin_cache: *ro_bin_cache @@ -146,6 +199,18 @@ integration_task: main_script: *main +integration_aarch64_task: + alias: "integration_aarch64" + depends_on: + - "unit_aarch64" + ec2_instance: *standard_build_ec2_aarch64 + cargo_cache: *ro_cargo_cache_aarch64 + targets_cache: *ro_targets_cache_aarch64 + bin_cache: *ro_bin_cache_aarch64 + setup_script: *setup + main_script: *main + + # This task is critical. It updates the "last-used by" timestamp stored # in metadata for all VM images. This mechanism functions in tandem with # an out-of-band pruning operation to remove disused VM images. @@ -171,6 +236,7 @@ ubuntu20_build_task: alias: ubuntu20_build depends_on: - "build" + gce_instance: *standard_gce_x86_64 container: cpu: 2 memory: 2 @@ -183,6 +249,7 @@ centos9_build_task: alias: centos9_build depends_on: - "build" + gce_instance: *standard_gce_x86_64 container: cpu: 2 memory: 2 @@ -196,22 +263,27 @@ success_task: alias: success depends_on: - "build" - - "build_cross" + - "build_aarch64" - "validate" + - "validate_aarch64" - "verify_vendor" + - "verify_vendor_aarch64" - "unit" + - "unit_aarch64" - "integration" + - "integration_aarch64" - "meta" - "ubuntu20_build" - "centos9_build" + gce_instance: *standard_gce_x86_64 env: CIRRUS_SHELL: "/bin/sh" clone_script: *noop - bin_cache: *ro_bin_cache + bin_cache: *ro_bin_cache_aarch64 # The paths used for uploaded artifacts are relative here and in Cirrus script: # Cross-compiled binary artifact is required by other CI systems - - curl --fail --location -O --url https://api.cirrus-ci.com/v1/artifact/build/${CIRRUS_BUILD_ID}/build_cross/binary.zip + - curl --fail --location -O --url https://api.cirrus-ci.com/v1/artifact/build/${CIRRUS_BUILD_ID}/build_aarch64/binary.zip - unzip binary.zip - rm -f binary.zip - mv bin/* ./ diff --git a/Makefile b/Makefile index 9bc268340..06467a3cf 100644 --- a/Makefile +++ b/Makefile @@ -75,19 +75,6 @@ test: unit integration build_unit: $(CARGO_TARGET_DIR) cargo test --no-run -# Test build cross-architecture -# Ref: https://github.com/cross-rs/cross -.PHONY: build_cross -build_cross: build_cross.aarch64-unknown-linux-gnu build_cross.arm-unknown-linux-gnueabi - -.PHONY: build_cross.% -build_cross.%: bin $(CARGO_TARGET_DIR) - cargo install cross - rustup target add $* - cross build --target $* $(release) - cp $(CARGO_TARGET_DIR)/$*/$(profile)/netavark \ - bin/netavark.$(*)$(if $(debug),.debug,) - .PHONY: unit unit: $(CARGO_TARGET_DIR) cargo test diff --git a/contrib/cirrus/runner.sh b/contrib/cirrus/runner.sh index b5e245d17..b1f1d32c3 100755 --- a/contrib/cirrus/runner.sh +++ b/contrib/cirrus/runner.sh @@ -34,12 +34,18 @@ task: https://cirrus-ci.com/task/$CIRRUS_TASK_ID EOF } +_run_build_aarch64() { + _run_build +} + _run_validate() { - rustup install stable - rustup default stable make validate } +_run_validate_aarch64() { + _run_validate +} + _run_build_cross() { make build_cross debug=1 make build_cross @@ -52,19 +58,40 @@ _run_verify_vendor() { fi } +_run_verify_vendor_aarch64() { + _run_verify_vendor +} + _run_unit() { make unit } +_run_unit_aarch64() { + _run_unit +} + _run_integration() { make integration } +_run_integration_aarch64() { + _run_integration +} + show_env_vars msg "************************************************************" msg "Toolchain details" msg "************************************************************" + +# FIXME (@lsm5): rustup commands should be moved to c/automation_images repo +# https://github.com/containers/automation_images/issues/150 +rustup install stable +rustup default stable +if [[ $(uname -m) == "aarch64" ]]; then + rustup target add aarch64-unknown-linux-gnu +fi + rustc --version cargo --version diff --git a/contrib/cirrus/setup.sh b/contrib/cirrus/setup.sh index ac13cd4f0..00ab309a8 100755 --- a/contrib/cirrus/setup.sh +++ b/contrib/cirrus/setup.sh @@ -19,8 +19,6 @@ msg "************************************************************" msg "Setting up runtime environment" msg "************************************************************" -dnf -y install make automake gcc gcc-c++ kernel-devel - show_env_vars if [[ "$CIRRUS_TASK_NAME" == "build_cross" ]]; then @@ -41,3 +39,16 @@ else unzip -o /tmp/aardvark-dns.zip chmod a+x /usr/libexec/podman/aardvark-dns fi + +req_env_vars AARDVARK_DNS_URL + +set -x # show what's happening +curl --fail --location -o /tmp/aardvark-dns.zip "$AARDVARK_DNS_URL" +mkdir -p /usr/libexec/podman +cd /usr/libexec/podman +rm -f aardvark-dns* +unzip -o /tmp/aardvark-dns.zip +if [[ $(uname -m) != "x86_64" ]]; then + mv aardvark-dns.$(uname -m)-unknown-linux-gnu aardvark-dns +fi +chmod a+x /usr/libexec/podman/aardvark-dns