feat: remove gists from this codebase
Bye bye, one piece of GitHub! Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
This commit is contained in:
parent
cf30f9017f
commit
83a7f35b52
|
@ -55,7 +55,6 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
tasks::evaluate::EvaluationWorker::new(
|
||||
cloner,
|
||||
&nix,
|
||||
cfg.github(),
|
||||
cfg.github_app_vendingmachine(),
|
||||
cfg.acl(),
|
||||
cfg.runner.identity.clone(),
|
||||
|
|
|
@ -41,7 +41,7 @@ pub struct EvaluationComplete {
|
|||
pub enum Error {
|
||||
CommitStatusWrite(CommitStatusError),
|
||||
Fail(String),
|
||||
FailWithGist(String, String, String),
|
||||
FailWithPastebin(String, String, String),
|
||||
}
|
||||
|
||||
impl From<CommitStatusError> for Error {
|
||||
|
|
|
@ -12,13 +12,12 @@ use crate::tagger::{MaintainerPrTagger, PkgsAddedRemovedTagger, RebuildTagger, S
|
|||
use crate::tasks::eval::{
|
||||
stdenvs::Stdenvs, Error, EvaluationComplete, EvaluationStrategy, StepResult,
|
||||
};
|
||||
use crate::tasks::evaluate::{get_prefix, make_gist, update_labels};
|
||||
use crate::tasks::evaluate::{get_prefix, update_labels};
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use chrono::Utc;
|
||||
use hubcaps::checks::{CheckRunOptions, CheckRunState, Conclusion, Output};
|
||||
use hubcaps::gists::Gists;
|
||||
use hubcaps::issues::{Issue, IssueRef};
|
||||
use hubcaps::repositories::Repository;
|
||||
use regex::Regex;
|
||||
|
@ -53,7 +52,6 @@ pub struct NixpkgsStrategy<'a> {
|
|||
issue: &'a Issue,
|
||||
issue_ref: &'a IssueRef,
|
||||
repo: &'a Repository,
|
||||
gists: &'a Gists,
|
||||
nix: Nix,
|
||||
stdenv_diff: Option<Stdenvs>,
|
||||
outpath_diff: Option<OutPathDiff>,
|
||||
|
@ -69,7 +67,6 @@ impl<'a> NixpkgsStrategy<'a> {
|
|||
issue: &'a Issue,
|
||||
issue_ref: &'a IssueRef,
|
||||
repo: &'a Repository,
|
||||
gists: &'a Gists,
|
||||
nix: Nix,
|
||||
) -> NixpkgsStrategy<'a> {
|
||||
Self {
|
||||
|
@ -78,7 +75,6 @@ impl<'a> NixpkgsStrategy<'a> {
|
|||
issue,
|
||||
issue_ref,
|
||||
repo,
|
||||
gists,
|
||||
nix,
|
||||
stdenv_diff: None,
|
||||
outpath_diff: None,
|
||||
|
@ -137,7 +133,7 @@ impl<'a> NixpkgsStrategy<'a> {
|
|||
.notify(Event::TargetBranchFailsEvaluation(target_branch.clone()));
|
||||
*/
|
||||
|
||||
Err(Error::FailWithGist(
|
||||
Err(Error::FailWithPastebin(
|
||||
String::from("The branch this PR will merge in to does not cleanly evaluate, and so this PR cannot be checked."),
|
||||
String::from("Output path comparison"),
|
||||
err.display(),
|
||||
|
@ -151,7 +147,7 @@ impl<'a> NixpkgsStrategy<'a> {
|
|||
fn check_outpaths_after(&mut self) -> StepResult<()> {
|
||||
if let Some(ref mut rebuildsniff) = self.outpath_diff {
|
||||
if let Err(err) = rebuildsniff.find_after() {
|
||||
Err(Error::FailWithGist(
|
||||
Err(Error::FailWithPastebin(
|
||||
String::from("This PR does not cleanly list package outputs after merging."),
|
||||
String::from("Output path comparison"),
|
||||
err.display(),
|
||||
|
@ -235,16 +231,15 @@ impl<'a> NixpkgsStrategy<'a> {
|
|||
}
|
||||
|
||||
fn gist_changed_paths(&self, attrs: &[PackageArch]) -> Option<String> {
|
||||
make_gist(
|
||||
self.gists,
|
||||
crate::utils::pastebin::make_pastebin(
|
||||
"Changed Paths",
|
||||
Some("".to_owned()),
|
||||
attrs
|
||||
.iter()
|
||||
.map(|attr| format!("{}\t{}", &attr.architecture, &attr.package))
|
||||
.collect::<Vec<String>>()
|
||||
.join("\n"),
|
||||
)
|
||||
.map(|pp| pp.uri)
|
||||
}
|
||||
|
||||
fn record_impacted_maintainers(&self, dir: &Path, attrs: &[PackageArch]) -> Result<(), Error> {
|
||||
|
@ -257,15 +252,14 @@ impl<'a> NixpkgsStrategy<'a> {
|
|||
let m =
|
||||
ImpactedMaintainers::calculate(&self.nix, dir, changed_paths, &changed_attributes);
|
||||
|
||||
let gist_url = make_gist(
|
||||
self.gists,
|
||||
let gist_url = crate::utils::pastebin::make_pastebin(
|
||||
"Potential Maintainers",
|
||||
Some("".to_owned()),
|
||||
match m {
|
||||
Ok(ref maintainers) => format!("Maintainers:\n{}", maintainers),
|
||||
Err(ref e) => format!("Ignorable calculation error:\n{:?}", e),
|
||||
},
|
||||
);
|
||||
)
|
||||
.map(|pp| pp.uri);
|
||||
|
||||
let prefix = get_prefix(self.repo.statuses(), &self.job.pr.head_sha)?;
|
||||
|
||||
|
@ -357,7 +351,10 @@ impl<'a> NixpkgsStrategy<'a> {
|
|||
}
|
||||
}
|
||||
Err(out) => {
|
||||
status.set_url(make_gist(self.gists, "Meta Check", None, out.display()));
|
||||
status.set_url(
|
||||
crate::utils::pastebin::make_pastebin("Meta Check", out.display())
|
||||
.map(|pp| pp.uri),
|
||||
);
|
||||
status.set(hubcaps::statuses::State::Failure)?;
|
||||
Err(Error::Fail(String::from(
|
||||
"Failed to validate package metadata.",
|
||||
|
|
|
@ -9,23 +9,21 @@ use crate::nix;
|
|||
use crate::stats::{self, Event};
|
||||
use crate::systems;
|
||||
use crate::tasks::eval;
|
||||
use crate::utils::pastebin::PersistedPastebin;
|
||||
use crate::worker;
|
||||
use futures_util::TryFutureExt;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::path::Path;
|
||||
use std::sync::RwLock;
|
||||
use std::time::Instant;
|
||||
|
||||
use hubcaps::checks::CheckRunOptions;
|
||||
use hubcaps::gists::Gists;
|
||||
use hubcaps::issues::Issue;
|
||||
use tracing::{debug, debug_span, error, info, warn};
|
||||
|
||||
pub struct EvaluationWorker<E> {
|
||||
cloner: checkout::CachedCloner,
|
||||
nix: nix::Nix,
|
||||
github: hubcaps::Github,
|
||||
github_vend: RwLock<GithubAppVendingMachine>,
|
||||
acl: Acl,
|
||||
identity: String,
|
||||
|
@ -37,7 +35,6 @@ impl<E: stats::SysEvents> EvaluationWorker<E> {
|
|||
pub fn new(
|
||||
cloner: checkout::CachedCloner,
|
||||
nix: &nix::Nix,
|
||||
github: hubcaps::Github,
|
||||
github_vend: GithubAppVendingMachine,
|
||||
acl: Acl,
|
||||
identity: String,
|
||||
|
@ -46,7 +43,6 @@ impl<E: stats::SysEvents> EvaluationWorker<E> {
|
|||
EvaluationWorker {
|
||||
cloner,
|
||||
nix: nix.without_limited_supported_systems(),
|
||||
github,
|
||||
github_vend: RwLock::new(github_vend),
|
||||
acl,
|
||||
identity,
|
||||
|
@ -92,7 +88,6 @@ impl<E: stats::SysEvents + 'static> worker::SimpleWorker for EvaluationWorker<E>
|
|||
|
||||
OneEval::new(
|
||||
github_client,
|
||||
&self.github,
|
||||
&self.nix,
|
||||
&self.acl,
|
||||
&mut self.events,
|
||||
|
@ -107,7 +102,6 @@ impl<E: stats::SysEvents + 'static> worker::SimpleWorker for EvaluationWorker<E>
|
|||
struct OneEval<'a, E> {
|
||||
client_app: &'a hubcaps::Github,
|
||||
repo: hubcaps::repositories::Repository,
|
||||
gists: Gists,
|
||||
nix: &'a nix::Nix,
|
||||
acl: &'a Acl,
|
||||
events: &'a mut E,
|
||||
|
@ -120,7 +114,6 @@ impl<'a, E: stats::SysEvents + 'static> OneEval<'a, E> {
|
|||
#[allow(clippy::too_many_arguments)]
|
||||
fn new(
|
||||
client_app: &'a hubcaps::Github,
|
||||
client_legacy: &'a hubcaps::Github,
|
||||
nix: &'a nix::Nix,
|
||||
acl: &'a Acl,
|
||||
events: &'a mut E,
|
||||
|
@ -128,13 +121,10 @@ impl<'a, E: stats::SysEvents + 'static> OneEval<'a, E> {
|
|||
cloner: &'a checkout::CachedCloner,
|
||||
job: &'a evaluationjob::EvaluationJob,
|
||||
) -> OneEval<'a, E> {
|
||||
let gists = client_legacy.gists();
|
||||
|
||||
let repo = client_app.repo(job.repo.owner.clone(), job.repo.name.clone());
|
||||
OneEval {
|
||||
client_app,
|
||||
repo,
|
||||
gists,
|
||||
nix,
|
||||
acl,
|
||||
events,
|
||||
|
@ -190,13 +180,8 @@ impl<'a, E: stats::SysEvents + 'static> OneEval<'a, E> {
|
|||
)
|
||||
}
|
||||
|
||||
fn make_gist(
|
||||
&self,
|
||||
filename: &str,
|
||||
description: Option<String>,
|
||||
content: String,
|
||||
) -> Option<String> {
|
||||
make_gist(&self.gists, filename, description, content)
|
||||
fn make_pastebin(&self, title: &str, contents: String) -> Option<PersistedPastebin> {
|
||||
crate::utils::pastebin::make_pastebin(title, contents)
|
||||
}
|
||||
|
||||
fn worker_actions(&mut self) -> worker::Actions {
|
||||
|
@ -206,10 +191,10 @@ impl<'a, E: stats::SysEvents + 'static> OneEval<'a, E> {
|
|||
EvalWorkerError::EvalError(eval::Error::Fail(msg)) => {
|
||||
self.update_status(msg, None, hubcaps::statuses::State::Failure)
|
||||
}
|
||||
EvalWorkerError::EvalError(eval::Error::FailWithGist(msg, filename, content)) => self
|
||||
EvalWorkerError::EvalError(eval::Error::FailWithPastebin(msg, title, content)) => self
|
||||
.update_status(
|
||||
msg,
|
||||
self.make_gist(&filename, Some("".to_owned()), content),
|
||||
self.make_pastebin(&title, content).map(|pp| pp.uri),
|
||||
hubcaps::statuses::State::Failure,
|
||||
),
|
||||
EvalWorkerError::EvalError(eval::Error::CommitStatusWrite(e)) => Err(e),
|
||||
|
@ -297,7 +282,6 @@ impl<'a, E: stats::SysEvents + 'static> OneEval<'a, E> {
|
|||
&issue,
|
||||
&issue_ref,
|
||||
&repo,
|
||||
&self.gists,
|
||||
self.nix.clone(),
|
||||
))
|
||||
} else {
|
||||
|
@ -422,11 +406,12 @@ impl<'a, E: stats::SysEvents + 'static> OneEval<'a, E> {
|
|||
}
|
||||
Err(mut out) => {
|
||||
state = hubcaps::statuses::State::Failure;
|
||||
gist_url = self.make_gist(
|
||||
&format!("{}-eval-{}", prefix, check.name()),
|
||||
Some(format!("{:?}", state)),
|
||||
file_to_str(&mut out),
|
||||
);
|
||||
gist_url = self
|
||||
.make_pastebin(
|
||||
&format!("[{}] Evaluation of {}", prefix, check.name()),
|
||||
file_to_str(&mut out),
|
||||
)
|
||||
.map(|pp| pp.uri);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -507,32 +492,6 @@ fn schedule_builds(
|
|||
response
|
||||
}
|
||||
|
||||
pub fn make_gist(
|
||||
gists: &hubcaps::gists::Gists,
|
||||
name: &str,
|
||||
description: Option<String>,
|
||||
contents: String,
|
||||
) -> Option<String> {
|
||||
let mut files: HashMap<String, hubcaps::gists::Content> = HashMap::new();
|
||||
files.insert(
|
||||
name.to_string(),
|
||||
hubcaps::gists::Content {
|
||||
filename: Some(name.to_string()),
|
||||
content: contents,
|
||||
},
|
||||
);
|
||||
|
||||
Some(
|
||||
async_std::task::block_on(gists.create(&hubcaps::gists::GistOptions {
|
||||
description,
|
||||
public: Some(true),
|
||||
files,
|
||||
}))
|
||||
.expect("Failed to create gist!")
|
||||
.html_url,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn update_labels(issueref: &hubcaps::issues::IssueRef, add: &[String], remove: &[String]) {
|
||||
let l = issueref.labels();
|
||||
let issue = async_std::task::block_on(issueref.get()).expect("Failed to get issue");
|
||||
|
|
|
@ -4,6 +4,6 @@ pub mod evaluate;
|
|||
pub mod evaluationfilter;
|
||||
pub mod githubcommentfilter;
|
||||
pub mod githubcommentposter;
|
||||
pub mod pastebin_collector;
|
||||
pub mod log_message_collector;
|
||||
pub mod pastebin_collector;
|
||||
pub mod statscollector;
|
||||
|
|
|
@ -12,16 +12,9 @@ use crate::{
|
|||
worker,
|
||||
};
|
||||
|
||||
enum CompressionMethod {
|
||||
//None,
|
||||
Zstd,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub struct PastebinCollector {
|
||||
pastebin_root: PathBuf,
|
||||
db_path: PathBuf,
|
||||
compression_method: CompressionMethod,
|
||||
}
|
||||
|
||||
impl PastebinCollector {
|
||||
|
@ -29,7 +22,6 @@ impl PastebinCollector {
|
|||
Self {
|
||||
pastebin_root,
|
||||
db_path,
|
||||
compression_method: CompressionMethod::Zstd,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ impl From<&Pastebin> for PersistedPastebin {
|
|||
let uuid_str = uuid.as_bytes();
|
||||
let encoded_uri = BASE64_URL_SAFE_NO_PAD.encode(uuid_str);
|
||||
let path = format!("pastes/{}", uuid.simple());
|
||||
// derive a uri and a path from it.
|
||||
PersistedPastebin {
|
||||
title: value.title.clone(),
|
||||
uri: encoded_uri,
|
||||
|
@ -31,3 +30,15 @@ impl From<&Pastebin> for PersistedPastebin {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn make_pastebin(title: &str, contents: String) -> Option<PersistedPastebin> {
|
||||
let pastebin = Pastebin {
|
||||
title: title.to_owned(),
|
||||
contents,
|
||||
};
|
||||
|
||||
// wait for a reply?
|
||||
//async_std::task::block_on(publish_serde_action(pastebin));
|
||||
|
||||
None
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue