Skip to content

Commit f7bca1b

Browse files
committed
Cirrus CI support
1 parent 9ee1255 commit f7bca1b

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

.cirrus.yml

+2
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ build_task:
7676
BTM_GENERATE: true
7777
COMPLETION_DIR: "target/tmp/bottom/completion/"
7878
MANPAGE_DIR: "target/tmp/bottom/manpage/"
79+
# -PLACEHOLDER FOR CI-
7980
matrix:
8081
- name: "FreeBSD 13 Build"
8182
alias: "freebsd_13_1_build"
@@ -104,6 +105,7 @@ build_task:
104105
- . $HOME/.cargo/env
105106
- cargo build --release --verbose --locked --features deploy
106107
- mv ./target/release/btm ./
108+
- ./btm -V
107109
- mv "$COMPLETION_DIR" completion
108110
- mv "$MANPAGE_DIR" manpage
109111
- tar -czvf bottom_$NAME.tar.gz btm completion

build.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,16 @@ fn nightly_version() {
6464

6565
match env::var_os(ENV_KEY) {
6666
Some(var) if !var.is_empty() && var == "nightly" => {
67-
if let Ok(output) = std::process::Command::new("git")
67+
let version = env!("CARGO_PKG_VERSION");
68+
69+
if let Some(git_hash) = option_env!("CIRRUS_CHANGE_IN_REPO")
70+
.and_then(|cirrus_sha: &str| cirrus_sha.get(0..8))
71+
{
72+
println!("cargo:rustc-env=NIGHTLY_VERSION={version}-nightly-{git_hash}");
73+
} else if let Ok(output) = std::process::Command::new("git")
6874
.args(["rev-parse", "--short", "HEAD"])
6975
.output()
7076
{
71-
let version = env!("CARGO_PKG_VERSION");
7277
let git_hash = String::from_utf8(output.stdout).unwrap();
7378
println!("cargo:rustc-env=NIGHTLY_VERSION={version}-nightly-{git_hash}");
7479
}
@@ -77,6 +82,7 @@ fn nightly_version() {
7782
}
7883

7984
println!("cargo:rerun-if-env-changed={ENV_KEY}");
85+
println!("cargo:rerun-if-env-changed=CIRRUS_CHANGE_IN_REPO");
8086
}
8187

8288
fn main() -> Result<()> {

scripts/cirrus/build.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,24 @@
2828
def make_query_request(key: str, branch: str, build_type: str):
2929
print("Creating query request.")
3030
mutation_id = "Cirrus CI Build {}-{}-{}".format(build_type, branch, int(time()))
31+
32+
# Dumb but if it works...
33+
config_override = (
34+
Path(".cirrus.yml").read_text().replace("# -PLACEHOLDER FOR CI-", 'BTM_BUILD_RELEASE_CALLER: "nightly"')
35+
)
3136
query = """
3237
mutation CreateCirrusCIBuild (
3338
$repo: ID!,
3439
$branch: String!,
35-
$mutation_id: String!
40+
$mutation_id: String!,
41+
$config_override: String,
3642
) {
3743
createBuild(
3844
input: {
3945
repositoryId: $repo,
4046
branch: $branch,
4147
clientMutationId: $mutation_id,
48+
configOverride: $config_override
4249
}
4350
) {
4451
build {
@@ -52,6 +59,7 @@ def make_query_request(key: str, branch: str, build_type: str):
5259
"repo": "6646638922956800",
5360
"branch": branch,
5461
"mutation_id": mutation_id,
62+
"config_override": dedent(config_override),
5563
}
5664
data = {"query": dedent(query), "variables": params}
5765
data = json.dumps(data).encode()

0 commit comments

Comments
 (0)