Rename check prefixes to ofborg

* If the sha we're operating on already has checks beginning with the old
`grahamcofborg-` prefix (e.g. someone just used `@ofborg eval`, `@ofborg build`,
or `@ofborg test`), continue using that prefix.

* If the sha we're operating on doesn't have any checks beginning with the old
`grahamcofborg-` prefix, use the new `ofborg-` prefix. This will take effect on
all new PRs immediately, and after a force-push for all existing PRs.
This commit is contained in:
Cole Helbling 2021-02-04 11:16:34 -08:00
parent 491ebda5e3
commit bc00b523ea
3 changed files with 42 additions and 10 deletions

View file

@ -20,8 +20,8 @@ impl EvalChecker {
} }
} }
pub fn name(&self) -> String { pub fn name(&self) -> &str {
format!("grahamcofborg-eval-{}", self.name) &self.name
} }
pub fn execute(&self, path: &Path) -> Result<File, File> { pub fn execute(&self, path: &Path) -> Result<File, File> {

View file

@ -14,7 +14,7 @@ use crate::tagger::{
use crate::tasks::eval::{ use crate::tasks::eval::{
stdenvs::Stdenvs, Error, EvaluationComplete, EvaluationStrategy, StepResult, stdenvs::Stdenvs, Error, EvaluationComplete, EvaluationStrategy, StepResult,
}; };
use crate::tasks::evaluate::{make_gist, update_labels}; use crate::tasks::evaluate::{get_prefix, make_gist, update_labels};
use std::collections::HashMap; use std::collections::HashMap;
use std::path::Path; use std::path::Path;
@ -272,6 +272,8 @@ impl<'a> NixpkgsStrategy<'a> {
}, },
); );
let prefix = get_prefix(self.repo.statuses(), &self.job.pr.head_sha)?;
if changed_paths.len() > MAINTAINER_REVIEW_MAX_CHANGED_PATHS { if changed_paths.len() > MAINTAINER_REVIEW_MAX_CHANGED_PATHS {
info!( info!(
"pull request has {} changed paths, skipping review requests", "pull request has {} changed paths, skipping review requests",
@ -280,7 +282,7 @@ impl<'a> NixpkgsStrategy<'a> {
let status = CommitStatus::new( let status = CommitStatus::new(
self.repo.statuses(), self.repo.statuses(),
self.job.pr.head_sha.clone(), self.job.pr.head_sha.clone(),
String::from("grahamcofborg-eval-check-maintainers"), format!("{}-eval-check-maintainers", prefix),
String::from("large change, skipping automatic review requests"), String::from("large change, skipping automatic review requests"),
gist_url, gist_url,
); );
@ -291,7 +293,7 @@ impl<'a> NixpkgsStrategy<'a> {
let status = CommitStatus::new( let status = CommitStatus::new(
self.repo.statuses(), self.repo.statuses(),
self.job.pr.head_sha.clone(), self.job.pr.head_sha.clone(),
String::from("grahamcofborg-eval-check-maintainers"), format!("{}-eval-check-maintainers", prefix),
String::from("matching changed paths to changed attrs..."), String::from("matching changed paths to changed attrs..."),
gist_url, gist_url,
); );
@ -315,10 +317,12 @@ impl<'a> NixpkgsStrategy<'a> {
fn check_meta_queue_builds(&self, dir: &Path) -> StepResult<Vec<BuildJob>> { fn check_meta_queue_builds(&self, dir: &Path) -> StepResult<Vec<BuildJob>> {
if let Some(ref possibly_touched_packages) = self.touched_packages { if let Some(ref possibly_touched_packages) = self.touched_packages {
let prefix = get_prefix(self.repo.statuses(), &self.job.pr.head_sha)?;
let mut status = CommitStatus::new( let mut status = CommitStatus::new(
self.repo.statuses(), self.repo.statuses(),
self.job.pr.head_sha.clone(), self.job.pr.head_sha.clone(),
String::from("grahamcofborg-eval-check-meta"), format!("{}-eval-check-meta", prefix),
String::from("config.nix: checkMeta = true"), String::from("config.nix: checkMeta = true"),
None, None,
); );

View file

@ -186,9 +186,13 @@ impl<'a, E: stats::SysEvents + 'static> OneEval<'a, E> {
} else { } else {
description description
}; };
let repo = self
.client_app
.repo(self.job.repo.owner.clone(), self.job.repo.name.clone());
let prefix = get_prefix(repo.statuses(), &self.job.pr.head_sha)?;
let mut builder = hubcaps::statuses::StatusOptions::builder(state); let mut builder = hubcaps::statuses::StatusOptions::builder(state);
builder.context("grahamcofborg-eval"); builder.context(format!("{}-eval", prefix));
builder.description(description.clone()); builder.description(description.clone());
if let Some(url) = url { if let Some(url) = url {
@ -322,10 +326,12 @@ impl<'a, E: stats::SysEvents + 'static> OneEval<'a, E> {
Box::new(eval::GenericStrategy::new()) Box::new(eval::GenericStrategy::new())
}; };
let prefix = get_prefix(repo.statuses(), &job.pr.head_sha)?;
let mut overall_status = CommitStatus::new( let mut overall_status = CommitStatus::new(
repo.statuses(), repo.statuses(),
job.pr.head_sha.clone(), job.pr.head_sha.clone(),
"grahamcofborg-eval".to_owned(), format!("{}-eval", &prefix),
"Starting".to_owned(), "Starting".to_owned(),
None, None,
); );
@ -422,7 +428,7 @@ impl<'a, E: stats::SysEvents + 'static> OneEval<'a, E> {
let mut status = CommitStatus::new( let mut status = CommitStatus::new(
repo.statuses(), repo.statuses(),
job.pr.head_sha.clone(), job.pr.head_sha.clone(),
check.name(), format!("{}-eval-{}", prefix, check.name()),
check.cli_cmd(), check.cli_cmd(),
None, None,
); );
@ -441,7 +447,7 @@ impl<'a, E: stats::SysEvents + 'static> OneEval<'a, E> {
Err(mut out) => { Err(mut out) => {
state = hubcaps::statuses::State::Failure; state = hubcaps::statuses::State::Failure;
gist_url = self.make_gist( gist_url = self.make_gist(
&check.name(), &format!("{}-eval-{}", prefix, check.name()),
Some(format!("{:?}", state)), Some(format!("{:?}", state)),
file_to_str(&mut out), file_to_str(&mut out),
); );
@ -618,6 +624,28 @@ fn indicates_wip(text: &str) -> bool {
false false
} }
/// Determine whether or not to use the "old" status prefix, `grahamcofborg`, or
/// the new one, `ofborg`.
///
/// If the PR already has any `grahamcofborg`-prefixed statuses, continue to use
/// that (e.g. if someone used `@ofborg eval`, `@ofborg build`, `@ofborg test`).
/// Otherwise, if it's a new PR or was recently force-pushed (and therefore
/// doesn't have any old `grahamcofborg`-prefixed statuses), use the new prefix.
pub fn get_prefix<'a>(
statuses: hubcaps::statuses::Statuses,
sha: &'a str,
) -> Result<&'a str, CommitStatusError> {
if statuses
.list(&sha)?
.iter()
.any(|s| s.context.starts_with("grahamcofborg-"))
{
Ok("grahamcofborg")
} else {
Ok("ofborg")
}
}
enum EvalWorkerError { enum EvalWorkerError {
EvalError(eval::Error), EvalError(eval::Error),
CommitStatusWrite(CommitStatusError), CommitStatusWrite(CommitStatusError),