From eaff5d009aa24250de40ca44eb798b5fd0190707 Mon Sep 17 00:00:00 2001 From: Clement Tsang <34804052+ClementTsang@users.noreply.github.com> Date: Thu, 1 Aug 2024 23:52:11 +0000 Subject: [PATCH] ci: clean up cirrus CI (#1530) * ci: try adding auto cancellation back to cirrus tasks * tweak timeout * some renaming * modernizing * Revert "modernizing" This reverts commit d66b3aa0e999140ced08e523214751f7572d4306. * hmmm * bleh back to false --- .cirrus.yml | 9 ++++++--- .github/workflows/build_releases.yml | 2 +- build.rs | 2 +- scripts/cirrus/{build.py => release.py} | 16 +++++++++------- 4 files changed, 17 insertions(+), 12 deletions(-) rename scripts/cirrus/{build.py => release.py} (93%) diff --git a/.cirrus.yml b/.cirrus.yml index 146a1049..e8be3976 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -42,12 +42,13 @@ env: test_task: auto_cancellation: "false" # We set this to false to prevent nightly builds from affecting this only_if: $CIRRUS_BUILD_SOURCE != "api" && ($CIRRUS_BRANCH == "main" || $CIRRUS_PR != "") - timeout_in: "20m" + timeout_in: "15m" skip: "!changesInclude('.cargo/**', '.cirrus.yml', 'sample_configs/**', 'src/**', 'tests/**', 'build.rs', 'Cargo.lock', 'Cargo.toml', 'clippy.toml', 'rustfmt.toml')" matrix: - name: "FreeBSD 14 Test" freebsd_instance: image_family: freebsd-14-0 + - name: "FreeBSD 13 Test" freebsd_instance: image_family: freebsd-13-3 @@ -67,9 +68,9 @@ test_task: - cargo clippy --all-targets --workspace --all-features -- -D warnings <<: *CLEANUP_TEMPLATE -build_task: +release_task: auto_cancellation: "false" - only_if: $CIRRUS_BUILD_SOURCE == "api" + only_if: $CIRRUS_BUILD_SOURCE == "api" && $BTM_BUILD_RELEASE_CALLER == "ci" timeout_in: "30m" env: BTM_GENERATE: "true" @@ -84,6 +85,7 @@ build_task: env: TARGET: "x86_64-unknown-freebsd" NAME: "x86_64-unknown-freebsd-14-0" + - name: "FreeBSD 13 Build" alias: "freebsd_13_3_build" freebsd_instance: @@ -91,6 +93,7 @@ build_task: env: TARGET: "x86_64-unknown-freebsd" NAME: "x86_64-unknown-freebsd-13-3" + - name: "Legacy Linux (2.17)" alias: "linux_2_17_build" container: diff --git a/.github/workflows/build_releases.yml b/.github/workflows/build_releases.yml index cf1c661d..fdc332ca 100644 --- a/.github/workflows/build_releases.yml +++ b/.github/workflows/build_releases.yml @@ -296,7 +296,7 @@ jobs: raw=$(git branch -r --contains '${{ github.ref_name }}'); BRANCH=${raw##*/}; fi - python ./scripts/cirrus/build.py "$BRANCH" "release/" "${{ inputs.caller }}" + python ./scripts/cirrus/release.py "$BRANCH" "release/" "${{ inputs.caller }}" - name: Generate artifact attestation for file uses: actions/attest-build-provenance@v1 diff --git a/build.rs b/build.rs index dc894181..df820396 100644 --- a/build.rs +++ b/build.rs @@ -84,7 +84,7 @@ fn nightly_version() { const ENV_KEY: &str = "BTM_BUILD_RELEASE_CALLER"; match env::var_os(ENV_KEY) { - Some(var) if !var.is_empty() && var == "nightly" => { + Some(var) if !var.is_empty() && var == "ci" => { let version = env!("CARGO_PKG_VERSION"); if let Some(hash) = extract_sha(option_env!("CIRRUS_CHANGE_IN_REPO")) { diff --git a/scripts/cirrus/build.py b/scripts/cirrus/release.py similarity index 93% rename from scripts/cirrus/build.py rename to scripts/cirrus/release.py index 0a38ed47..ba12d60a 100644 --- a/scripts/cirrus/build.py +++ b/scripts/cirrus/release.py @@ -34,7 +34,9 @@ def make_query_request(key: str, branch: str, build_type: str): # Dumb but if it works... config_override = ( - Path(".cirrus.yml").read_text().replace("# -PLACEHOLDER FOR CI-", 'BTM_BUILD_RELEASE_CALLER: "nightly"') + Path(".cirrus.yml") + .read_text() + .replace("# -PLACEHOLDER FOR CI-", 'BTM_BUILD_RELEASE_CALLER: "ci"') ) query = """ mutation CreateCirrusCIBuild ( @@ -43,7 +45,7 @@ def make_query_request(key: str, branch: str, build_type: str): $mutation_id: String!, $config_override: String, ) { - createBuild( + createBuild ( input: { repositoryId: $repo, branch: $branch, @@ -108,7 +110,7 @@ def try_download(build_id: str, dl_path: Path): for task, file in TASKS: url = DL_URL_TEMPLATE % (build_id, task, file) out = os.path.join(dl_path, file) - print("Downloading {} to {}".format(file, out)) + print(f"Downloading {file} to {out}") urlretrieve(url, out) @@ -140,7 +142,7 @@ def main(): for i in range(MAX_ATTEMPTS): if success: break - print("Attempt {}:".format(i + 1)) + print(f"Attempt {i + 1}:") with urlopen(make_query_request(key, branch, build_type)) as response: response = json.load(response) @@ -151,14 +153,14 @@ def main(): try: build_id = response["data"]["createBuild"]["build"]["id"] - print("Created build job {}.".format(build_id)) + print(f"Created build job {build_id}.") except KeyError: print("There was an issue with creating a build job.") continue # First, sleep 4 minutes, as it's unlikely it'll finish before then. SLEEP_MINUTES = 4 - print("Sleeping for {} minutes.".format(SLEEP_MINUTES)) + print(f"Sleeping for {SLEEP_MINUTES} minutes.") sleep(60 * SLEEP_MINUTES) print("Mandatory nap over. Starting to check for completion.") @@ -193,7 +195,7 @@ def main(): # Sleep for a minute if something went wrong, just in case. sleep(60) else: - print("Build failed to complete after {} minutes, bailing.".format(MINUTES)) + print(f"Build failed to complete after {MINUTES} minutes, bailing.") if not success: exit(2)