Skip to content

Commit

Permalink
Cirrus CI support
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementTsang committed Jan 2, 2023
1 parent 9ee1255 commit 05cfe66
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ build_task:
BTM_GENERATE: true
COMPLETION_DIR: "target/tmp/bottom/completion/"
MANPAGE_DIR: "target/tmp/bottom/manpage/"
# -PLACEHOLDER FOR CI-
matrix:
- name: "FreeBSD 13 Build"
alias: "freebsd_13_1_build"
Expand Down Expand Up @@ -104,6 +105,7 @@ build_task:
- . $HOME/.cargo/env
- cargo build --release --verbose --locked --features deploy
- mv ./target/release/btm ./
- ./btm -V
- mv "$COMPLETION_DIR" completion
- mv "$MANPAGE_DIR" manpage
- tar -czvf bottom_$NAME.tar.gz btm completion
Expand Down
9 changes: 7 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,15 @@ fn nightly_version() {

match env::var_os(ENV_KEY) {
Some(var) if !var.is_empty() && var == "nightly" => {
if let Ok(output) = std::process::Command::new("git")
let version = env!("CARGO_PKG_VERSION");

if let Some(cirrus_sha) = option_env!("CIRRUS_CHANGE_IN_REPO") {
let git_hash: &str = &cirrus_sha[..8];
println!("cargo:rustc-env=NIGHTLY_VERSION={version}-nightly-{git_hash}");
} else if let Ok(output) = std::process::Command::new("git")
.args(["rev-parse", "--short", "HEAD"])
.output()
{
let version = env!("CARGO_PKG_VERSION");
let git_hash = String::from_utf8(output.stdout).unwrap();
println!("cargo:rustc-env=NIGHTLY_VERSION={version}-nightly-{git_hash}");
}
Expand All @@ -77,6 +81,7 @@ fn nightly_version() {
}

println!("cargo:rerun-if-env-changed={ENV_KEY}");
println!("cargo:rerun-if-env-changed=CIRRUS_CHANGE_IN_REPO");
}

fn main() -> Result<()> {
Expand Down
10 changes: 9 additions & 1 deletion scripts/cirrus/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,24 @@
def make_query_request(key: str, branch: str, build_type: str):
print("Creating query request.")
mutation_id = "Cirrus CI Build {}-{}-{}".format(build_type, branch, int(time()))

# Dumb but if it works...
config_override = (
Path(".cirrus.yml").read_text().replace("# -PLACEHOLDER FOR CI-", 'BTM_BUILD_RELEASE_CALLER: "nightly"')
)
query = """
mutation CreateCirrusCIBuild (
$repo: ID!,
$branch: String!,
$mutation_id: String!
$mutation_id: String!,
$config_override: String,
) {
createBuild(
input: {
repositoryId: $repo,
branch: $branch,
clientMutationId: $mutation_id,
configOverride: $config_override
}
) {
build {
Expand All @@ -52,6 +59,7 @@ def make_query_request(key: str, branch: str, build_type: str):
"repo": "6646638922956800",
"branch": branch,
"mutation_id": mutation_id,
"config_override": dedent(config_override),
}
data = {"query": dedent(query), "variables": params}
data = json.dumps(data).encode()
Expand Down

0 comments on commit 05cfe66

Please sign in to comment.