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 d66b3aa0e9.

* hmmm

* bleh back to false
This commit is contained in:
Clement Tsang 2024-08-01 23:52:11 +00:00 committed by GitHub
parent 8811d54058
commit eaff5d009a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 17 additions and 12 deletions

View File

@ -42,12 +42,13 @@ env:
test_task: test_task:
auto_cancellation: "false" # We set this to false to prevent nightly builds from affecting this 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 != "") 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')" skip: "!changesInclude('.cargo/**', '.cirrus.yml', 'sample_configs/**', 'src/**', 'tests/**', 'build.rs', 'Cargo.lock', 'Cargo.toml', 'clippy.toml', 'rustfmt.toml')"
matrix: matrix:
- name: "FreeBSD 14 Test" - name: "FreeBSD 14 Test"
freebsd_instance: freebsd_instance:
image_family: freebsd-14-0 image_family: freebsd-14-0
- name: "FreeBSD 13 Test" - name: "FreeBSD 13 Test"
freebsd_instance: freebsd_instance:
image_family: freebsd-13-3 image_family: freebsd-13-3
@ -67,9 +68,9 @@ test_task:
- cargo clippy --all-targets --workspace --all-features -- -D warnings - cargo clippy --all-targets --workspace --all-features -- -D warnings
<<: *CLEANUP_TEMPLATE <<: *CLEANUP_TEMPLATE
build_task: release_task:
auto_cancellation: "false" auto_cancellation: "false"
only_if: $CIRRUS_BUILD_SOURCE == "api" only_if: $CIRRUS_BUILD_SOURCE == "api" && $BTM_BUILD_RELEASE_CALLER == "ci"
timeout_in: "30m" timeout_in: "30m"
env: env:
BTM_GENERATE: "true" BTM_GENERATE: "true"
@ -84,6 +85,7 @@ build_task:
env: env:
TARGET: "x86_64-unknown-freebsd" TARGET: "x86_64-unknown-freebsd"
NAME: "x86_64-unknown-freebsd-14-0" NAME: "x86_64-unknown-freebsd-14-0"
- name: "FreeBSD 13 Build" - name: "FreeBSD 13 Build"
alias: "freebsd_13_3_build" alias: "freebsd_13_3_build"
freebsd_instance: freebsd_instance:
@ -91,6 +93,7 @@ build_task:
env: env:
TARGET: "x86_64-unknown-freebsd" TARGET: "x86_64-unknown-freebsd"
NAME: "x86_64-unknown-freebsd-13-3" NAME: "x86_64-unknown-freebsd-13-3"
- name: "Legacy Linux (2.17)" - name: "Legacy Linux (2.17)"
alias: "linux_2_17_build" alias: "linux_2_17_build"
container: container:

View File

@ -296,7 +296,7 @@ jobs:
raw=$(git branch -r --contains '${{ github.ref_name }}'); raw=$(git branch -r --contains '${{ github.ref_name }}');
BRANCH=${raw##*/}; BRANCH=${raw##*/};
fi 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 - name: Generate artifact attestation for file
uses: actions/attest-build-provenance@v1 uses: actions/attest-build-provenance@v1

View File

@ -84,7 +84,7 @@ fn nightly_version() {
const ENV_KEY: &str = "BTM_BUILD_RELEASE_CALLER"; const ENV_KEY: &str = "BTM_BUILD_RELEASE_CALLER";
match env::var_os(ENV_KEY) { 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"); let version = env!("CARGO_PKG_VERSION");
if let Some(hash) = extract_sha(option_env!("CIRRUS_CHANGE_IN_REPO")) { if let Some(hash) = extract_sha(option_env!("CIRRUS_CHANGE_IN_REPO")) {

View File

@ -34,7 +34,9 @@ def make_query_request(key: str, branch: str, build_type: str):
# Dumb but if it works... # Dumb but if it works...
config_override = ( 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 = """ query = """
mutation CreateCirrusCIBuild ( mutation CreateCirrusCIBuild (
@ -43,7 +45,7 @@ def make_query_request(key: str, branch: str, build_type: str):
$mutation_id: String!, $mutation_id: String!,
$config_override: String, $config_override: String,
) { ) {
createBuild( createBuild (
input: { input: {
repositoryId: $repo, repositoryId: $repo,
branch: $branch, branch: $branch,
@ -108,7 +110,7 @@ def try_download(build_id: str, dl_path: Path):
for task, file in TASKS: for task, file in TASKS:
url = DL_URL_TEMPLATE % (build_id, task, file) url = DL_URL_TEMPLATE % (build_id, task, file)
out = os.path.join(dl_path, file) out = os.path.join(dl_path, file)
print("Downloading {} to {}".format(file, out)) print(f"Downloading {file} to {out}")
urlretrieve(url, out) urlretrieve(url, out)
@ -140,7 +142,7 @@ def main():
for i in range(MAX_ATTEMPTS): for i in range(MAX_ATTEMPTS):
if success: if success:
break break
print("Attempt {}:".format(i + 1)) print(f"Attempt {i + 1}:")
with urlopen(make_query_request(key, branch, build_type)) as response: with urlopen(make_query_request(key, branch, build_type)) as response:
response = json.load(response) response = json.load(response)
@ -151,14 +153,14 @@ def main():
try: try:
build_id = response["data"]["createBuild"]["build"]["id"] build_id = response["data"]["createBuild"]["build"]["id"]
print("Created build job {}.".format(build_id)) print(f"Created build job {build_id}.")
except KeyError: except KeyError:
print("There was an issue with creating a build job.") print("There was an issue with creating a build job.")
continue continue
# First, sleep 4 minutes, as it's unlikely it'll finish before then. # First, sleep 4 minutes, as it's unlikely it'll finish before then.
SLEEP_MINUTES = 4 SLEEP_MINUTES = 4
print("Sleeping for {} minutes.".format(SLEEP_MINUTES)) print(f"Sleeping for {SLEEP_MINUTES} minutes.")
sleep(60 * SLEEP_MINUTES) sleep(60 * SLEEP_MINUTES)
print("Mandatory nap over. Starting to check for completion.") 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 for a minute if something went wrong, just in case.
sleep(60) sleep(60)
else: else:
print("Build failed to complete after {} minutes, bailing.".format(MINUTES)) print(f"Build failed to complete after {MINUTES} minutes, bailing.")
if not success: if not success:
exit(2) exit(2)