Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add build hash to nightly builds for version #951

Merged
merged 2 commits into from
Jan 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Cirrus CI support
  • Loading branch information
ClementTsang committed Jan 2, 2023
commit f7bca1bda29be6fac0a3f7892516d09c801ed1d4
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
10 changes: 8 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,16 @@ 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(git_hash) = option_env!("CIRRUS_CHANGE_IN_REPO")
.and_then(|cirrus_sha: &str| cirrus_sha.get(0..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 +82,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