Skip to content
This repository was archived by the owner on Jun 12, 2023. It is now read-only.

Cirrus: Groom rust cache before updating #54

Merged
merged 1 commit into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ build_task:
image_name: "${FEDORA_NETAVARK_IMAGE}"
cargo_cache: &cargo_cache
folder: "$CARGO_HOME"
fingerprint_key: "cargo_v1_${DEST_BRANCH}" # Cache for branch + PRs
fingerprint_script: echo -e "cargo_v3_${DEST_BRANCH}_amd64\n---\n$(<Cargo.lock)\n---\n$(<Cargo.toml)"
reupload_on_changes: true
targets_cache: &targets_cache
folder: "$CARGO_TARGET_DIR"
fingerprint_key: "targets_v1_${CIRRUS_BUILD_ID}" # Cache only within same build
fingerprint_script: echo -e "targets_v3_${CIRRUS_TAG}${DEST_BRANCH}${CIRRUS_PR}_amd64\n---\n$(<Cargo.lock)\n---\n$(<Cargo.toml)"
reupload_on_changes: true
bin_cache: &bin_cache
# This simply prevents rebuilding bin/aardvark-dns* or every subsequent task.
Expand All @@ -50,6 +50,8 @@ build_task:
reupload_on_changes: true
setup_script: &setup "$SCRIPT_BASE/setup.sh $CIRRUS_TASK_NAME"
main_script: &main "$SCRIPT_BASE/runner.sh $CIRRUS_TASK_NAME"
# N/B: This script comes from `main` on the netavark repo
cache_grooming_script: &groom bash "$SCRIPT_BASE/netavark_cache_groom.sh"
upload_caches: [ "cargo", "targets", "bin" ]


Expand All @@ -63,15 +65,16 @@ build_task:
# architecture: arm64 # CAUTION: This has to be "arm64", not aarch64.
# cargo_cache: &cargo_cache_aarch64
# <<: *cargo_cache
# fingerprint_key: "cargo_v1_${DEST_BRANCH}_aarch64"
# fingerprint_script: echo -e "cargo_v3_${DEST_BRANCH}_aarch64\n---\n$(<Cargo.lock)\n---\n$(<Cargo.toml)"
# targets_cache: &targets_cache_aarch64
# <<: *targets_cache
# fingerprint_key: "cargo_v1_${DEST_BRANCH}_aarch64"
# fingerprint_script: echo -e "targets_v3_${CIRRUS_TAG}${DEST_BRANCH}${CIRRUS_PR}_aarch64\n---\n$(<Cargo.lock)\n---\n$(<Cargo.toml)"
# bin_cache: &bin_cache_aarch64
# <<: *bin_cache
# fingerprint_key: "cargo_v1_${DEST_BRANCH}_aarch64"
# setup_script: *setup
# main_script: *main
# cache_grooming_script: *groom
# upload_caches: [ "cargo", "targets", "bin" ]


Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/target
Cargo.lock
.idea/
proto-build/netavark_proxy.rs
/bin
Empty file added Cargo.lock
Empty file.
23 changes: 23 additions & 0 deletions contrib/cirrus/netavark_cache_groom.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
#
# This script is intended to be run from Cirrus-CI to prepare the
# rust targets cache for re-use during subsequent runs. This mainly
# involves removing files and directories which change frequently
# but are cheap/quick to regenerate - i.e. prevent "cache-flapping".
# Any other use of this script is not supported and may cause harm.

set -eo pipefail

SCRIPT_DIRPATH=$(dirname ${BASH_SOURCE[0]})
source $SCRIPT_DIRPATH/lib.sh

if [[ "$CIRRUS_CI" != true ]] || [[ -z "$DEST_BRANCH" ]]; then
die "Script is not intended for use outside of Cirrus-CI"
fi

SCRIPT_DEST=$SCRIPT_DIRPATH/cache_groom.sh
showrun curl --location --silent --show-error -o $SCRIPT_DEST \
https://raw.githubusercontent.com/containers/netavark/$DEST_BRANCH/contrib/cirrus/cache_groom.sh

# Certain common automation library calls assume execution from this file
exec bash $SCRIPT_DEST