manager: Add first version of the techtree manager
The techtree manager is a CI tool that derives the techtree graph from the forgejo issues in this repository. It then adds graph visualizations to each issue and the wiki, to give an overview of the tree.
This commit is contained in:
parent
8ab73f4a4a
commit
870e54e263
9 changed files with 2768 additions and 0 deletions
57
techtree-manager/src/event_meta.rs
Normal file
57
techtree-manager/src/event_meta.rs
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
use anyhow::Context as _;
|
||||
|
||||
#[derive(serde::Deserialize, Debug, Clone, PartialEq, Eq)]
|
||||
pub struct IssueEventMeta {
|
||||
pub action: IssueAction,
|
||||
pub issue: IssueMeta,
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum IssueAction {
|
||||
Opened,
|
||||
Reopened,
|
||||
Closed,
|
||||
Assigned,
|
||||
Unassigned,
|
||||
Edited,
|
||||
#[serde(rename = "label_updated")]
|
||||
LabelUpdated,
|
||||
Labeled,
|
||||
#[serde(rename = "label_cleared")]
|
||||
LabelCleared,
|
||||
Unlabeled,
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize, Debug, Clone, PartialEq, Eq)]
|
||||
pub struct IssueMeta {
|
||||
pub number: u64,
|
||||
pub repository: RepoMeta,
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize, Debug, Clone, PartialEq, Eq)]
|
||||
pub struct RepoMeta {
|
||||
pub name: String,
|
||||
pub owner: String,
|
||||
}
|
||||
|
||||
pub fn get_issue_event_meta_from_env() -> anyhow::Result<IssueEventMeta> {
|
||||
let path = std::env::var_os("GITHUB_EVENT_PATH")
|
||||
.context("Could not get event description file path (GITHUB_EVENT_PATH)")?;
|
||||
let f = std::fs::File::open(path).context("Could not open GITHUB_EVENT_PATH file")?;
|
||||
let meta: IssueEventMeta = serde_json::de::from_reader(f).context("Failed to parse")?;
|
||||
Ok(meta)
|
||||
}
|
||||
|
||||
pub fn fake() -> IssueEventMeta {
|
||||
IssueEventMeta {
|
||||
action: IssueAction::Edited,
|
||||
issue: IssueMeta {
|
||||
number: 1337,
|
||||
repository: RepoMeta {
|
||||
name: "techtree-poc".to_owned(),
|
||||
owner: "rahix".to_owned(),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue