Skip to content

Commit

Permalink
Cirrus: enable Fedora 36 aarch64 tasks on EC2
Browse files Browse the repository at this point in the history
Signed-off-by: Lokesh Mandvekar <[email protected]>
  • Loading branch information
lsm5 committed Jul 15, 2022
1 parent f95b798 commit 130f402
Show file tree
Hide file tree
Showing 4 changed files with 156 additions and 51 deletions.
148 changes: 114 additions & 34 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -76,30 +72,47 @@ 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" ]
# Downstream CI needs the aarch64 binaries from this CI system.
# However, we don't want to confuse architectures.
art_prep_script:
- cd bin
- ln netavark netavark.$(uname -m)-unknown-linux-gnu
- ln netavark.debug netavark.debug.$(uname -m)-unknown-linux-gnu
armbinary_artifacts: # See success_task
path: ./bin/netavark*-unknown-linux-gnu


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.
Expand All @@ -115,37 +128,97 @@ 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
setup_script: *setup
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.
Expand All @@ -171,6 +244,7 @@ ubuntu20_build_task:
alias: ubuntu20_build
depends_on:
- "build"
gce_instance: *standard_gce_x86_64
container:
cpu: 2
memory: 2
Expand All @@ -183,6 +257,7 @@ centos9_build_task:
alias: centos9_build
depends_on:
- "build"
gce_instance: *standard_gce_x86_64
container:
cpu: 2
memory: 2
Expand All @@ -196,24 +271,29 @@ 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
- unzip binary.zip
- rm -f binary.zip
- curl --fail --location -O --url https://api.cirrus-ci.com/v1/artifact/build/${CIRRUS_BUILD_ID}/build_aarch64/armbinary.zip
- unzip armbinary.zip
- rm -f armbinary.zip
- mv bin/* ./
- rm -rf bin
# Upload tested binary for consumption downstream
Expand Down
13 changes: 0 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 29 additions & 2 deletions contrib/cirrus/runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
15 changes: 13 additions & 2 deletions contrib/cirrus/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 130f402

Please sign in to comment.