mirror of
https://github.com/ClementTsang/bottom.git
synced 2024-09-11 11:46:59 +03:00
ci: add build hash to nightly builds for version (#951)
This adds the build hash to the btm -V output for nightly builds, making it easier to troubleshoot when someone might have obtained a nightly build, and what commit it corresponds to.
This commit is contained in:
parent
a56e7f6cc9
commit
7c53f088c3
@ -76,6 +76,7 @@ build_task:
|
|||||||
BTM_GENERATE: true
|
BTM_GENERATE: true
|
||||||
COMPLETION_DIR: "target/tmp/bottom/completion/"
|
COMPLETION_DIR: "target/tmp/bottom/completion/"
|
||||||
MANPAGE_DIR: "target/tmp/bottom/manpage/"
|
MANPAGE_DIR: "target/tmp/bottom/manpage/"
|
||||||
|
# -PLACEHOLDER FOR CI-
|
||||||
matrix:
|
matrix:
|
||||||
- name: "FreeBSD 13 Build"
|
- name: "FreeBSD 13 Build"
|
||||||
alias: "freebsd_13_1_build"
|
alias: "freebsd_13_1_build"
|
||||||
@ -104,6 +105,7 @@ build_task:
|
|||||||
- . $HOME/.cargo/env
|
- . $HOME/.cargo/env
|
||||||
- cargo build --release --verbose --locked --features deploy
|
- cargo build --release --verbose --locked --features deploy
|
||||||
- mv ./target/release/btm ./
|
- mv ./target/release/btm ./
|
||||||
|
- ./btm -V
|
||||||
- mv "$COMPLETION_DIR" completion
|
- mv "$COMPLETION_DIR" completion
|
||||||
- mv "$MANPAGE_DIR" manpage
|
- mv "$MANPAGE_DIR" manpage
|
||||||
- tar -czvf bottom_$NAME.tar.gz btm completion
|
- tar -czvf bottom_$NAME.tar.gz btm completion
|
||||||
|
2
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
2
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@ -73,7 +73,7 @@ body:
|
|||||||
label: What version of `bottom` are you running?
|
label: What version of `bottom` are you running?
|
||||||
description: >
|
description: >
|
||||||
Please provide which version of `bottom` you're running, which you can find with `btm -V`. If you are using
|
Please provide which version of `bottom` you're running, which you can find with `btm -V`. If you are using
|
||||||
a nightly/non-release version, please specify that and any related details (e.g. the commit hash/which nightly build).
|
a nightly/non-release version, please also specify that.
|
||||||
placeholder: 0.7.0
|
placeholder: 0.7.0
|
||||||
|
|
||||||
- type: input
|
- type: input
|
||||||
|
1
.github/workflows/build_releases.yml
vendored
1
.github/workflows/build_releases.yml
vendored
@ -152,6 +152,7 @@ jobs:
|
|||||||
uses: ClementTsang/cargo-action@v0.0.3
|
uses: ClementTsang/cargo-action@v0.0.3
|
||||||
env:
|
env:
|
||||||
BTM_GENERATE: true
|
BTM_GENERATE: true
|
||||||
|
BTM_BUILD_RELEASE_CALLER: ${{ inputs.caller }}
|
||||||
with:
|
with:
|
||||||
command: build
|
command: build
|
||||||
args: --release --verbose --locked --target=${{ matrix.info.target }} --features deploy
|
args: --release --verbose --locked --target=${{ matrix.info.target }} --features deploy
|
||||||
|
@ -315,7 +315,7 @@ More details on configuration can be found [in the documentation](https://clemen
|
|||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
If some things aren't working, give the [Troubleshooting page](https://clementtsang.github.io/bottom/nightly/troubleshooting) a look. If things still aren't
|
If some things aren't working, give the [Troubleshooting page](https://clementtsang.github.io/bottom/nightly/troubleshooting) a look. If things still aren't
|
||||||
working, then consider asking a [question by opening a question](https://github.com/ClementTsang/bottom/discussions) or filing a [bug report](https://github.com/ClementTsang/bottom/issues/new/choose).
|
working, then consider opening [a question](https://github.com/ClementTsang/bottom/discussions) or filing a [bug report](https://github.com/ClementTsang/bottom/issues/new/choose).
|
||||||
|
|
||||||
## Contribution
|
## Contribution
|
||||||
|
|
||||||
|
50
build.rs
50
build.rs
@ -1,6 +1,5 @@
|
|||||||
use std::{
|
use std::{
|
||||||
env, fs,
|
env, fs, io,
|
||||||
io::Result,
|
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -8,7 +7,7 @@ use clap_complete::{generate_to, shells::Shell};
|
|||||||
|
|
||||||
include!("src/clap.rs");
|
include!("src/clap.rs");
|
||||||
|
|
||||||
fn create_dir(dir: &Path) -> Result<()> {
|
fn create_dir(dir: &Path) -> io::Result<()> {
|
||||||
let res = fs::create_dir_all(dir);
|
let res = fs::create_dir_all(dir);
|
||||||
match &res {
|
match &res {
|
||||||
Ok(()) => {}
|
Ok(()) => {}
|
||||||
@ -23,12 +22,14 @@ fn create_dir(dir: &Path) -> Result<()> {
|
|||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn btm_generate() -> io::Result<()> {
|
||||||
const COMPLETION_DIR: &str = "./target/tmp/bottom/completion/";
|
const ENV_KEY: &str = "BTM_GENERATE";
|
||||||
const MANPAGE_DIR: &str = "./target/tmp/bottom/manpage/";
|
|
||||||
|
|
||||||
match env::var_os("BTM_GENERATE") {
|
match env::var_os(ENV_KEY) {
|
||||||
Some(var) if !var.is_empty() => {
|
Some(var) if !var.is_empty() => {
|
||||||
|
const COMPLETION_DIR: &str = "./target/tmp/bottom/completion/";
|
||||||
|
const MANPAGE_DIR: &str = "./target/tmp/bottom/manpage/";
|
||||||
|
|
||||||
let completion_out_dir = PathBuf::from(COMPLETION_DIR);
|
let completion_out_dir = PathBuf::from(COMPLETION_DIR);
|
||||||
let manpage_out_dir = PathBuf::from(MANPAGE_DIR);
|
let manpage_out_dir = PathBuf::from(MANPAGE_DIR);
|
||||||
|
|
||||||
@ -53,7 +54,40 @@ fn main() -> Result<()> {
|
|||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("cargo:rerun-if-env-changed=BTM_GENERATE");
|
println!("cargo:rerun-if-env-changed={ENV_KEY}");
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
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" => {
|
||||||
|
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 git_hash = String::from_utf8(output.stdout).unwrap();
|
||||||
|
println!("cargo:rustc-env=NIGHTLY_VERSION={version}-nightly-{git_hash}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
|
||||||
|
println!("cargo:rerun-if-env-changed={ENV_KEY}");
|
||||||
|
println!("cargo:rerun-if-env-changed=CIRRUS_CHANGE_IN_REPO");
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() -> Result<()> {
|
||||||
|
btm_generate()?;
|
||||||
|
nightly_version();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -28,17 +28,24 @@ DL_URL_TEMPLATE = "https://api.cirrus-ci.com/v1/artifact/build/%s/%s/binaries/%s
|
|||||||
def make_query_request(key: str, branch: str, build_type: str):
|
def make_query_request(key: str, branch: str, build_type: str):
|
||||||
print("Creating query request.")
|
print("Creating query request.")
|
||||||
mutation_id = "Cirrus CI Build {}-{}-{}".format(build_type, branch, int(time()))
|
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 = """
|
query = """
|
||||||
mutation CreateCirrusCIBuild (
|
mutation CreateCirrusCIBuild (
|
||||||
$repo: ID!,
|
$repo: ID!,
|
||||||
$branch: String!,
|
$branch: String!,
|
||||||
$mutation_id: String!
|
$mutation_id: String!,
|
||||||
|
$config_override: String,
|
||||||
) {
|
) {
|
||||||
createBuild(
|
createBuild(
|
||||||
input: {
|
input: {
|
||||||
repositoryId: $repo,
|
repositoryId: $repo,
|
||||||
branch: $branch,
|
branch: $branch,
|
||||||
clientMutationId: $mutation_id,
|
clientMutationId: $mutation_id,
|
||||||
|
configOverride: $config_override
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
build {
|
build {
|
||||||
@ -52,6 +59,7 @@ def make_query_request(key: str, branch: str, build_type: str):
|
|||||||
"repo": "6646638922956800",
|
"repo": "6646638922956800",
|
||||||
"branch": branch,
|
"branch": branch,
|
||||||
"mutation_id": mutation_id,
|
"mutation_id": mutation_id,
|
||||||
|
"config_override": dedent(config_override),
|
||||||
}
|
}
|
||||||
data = {"query": dedent(query), "variables": params}
|
data = {"query": dedent(query), "variables": params}
|
||||||
data = json.dumps(data).encode()
|
data = json.dumps(data).encode()
|
||||||
|
@ -368,9 +368,14 @@ use CPU (3) as the default instead.
|
|||||||
.help("The timespan of data kept.")
|
.help("The timespan of data kept.")
|
||||||
.long_help("How much data is stored at once in terms of time. Takes in human-readable time spans (e.g. 10m, 1h), with a minimum of 1 minute. Note higher values will take up more memory. Defaults to 10 minutes.");
|
.long_help("How much data is stored at once in terms of time. Takes in human-readable time spans (e.g. 10m, 1h), with a minimum of 1 minute. Note higher values will take up more memory. Defaults to 10 minutes.");
|
||||||
|
|
||||||
|
const VERSION: &str = match option_env!("NIGHTLY_VERSION") {
|
||||||
|
Some(nightly_version) => nightly_version,
|
||||||
|
None => crate_version!(),
|
||||||
|
};
|
||||||
|
|
||||||
#[allow(unused_mut)]
|
#[allow(unused_mut)]
|
||||||
let mut app = Command::new(crate_name!())
|
let mut app = Command::new(crate_name!())
|
||||||
.version(crate_version!())
|
.version(VERSION)
|
||||||
.author(crate_authors!())
|
.author(crate_authors!())
|
||||||
.about(crate_description!())
|
.about(crate_description!())
|
||||||
.override_usage(USAGE)
|
.override_usage(USAGE)
|
||||||
|
Loading…
Reference in New Issue
Block a user