generated from srid/rust-nix-template
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
44 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/// Enough types to get branch info from Pull Request URL | ||
use itertools::iproduct; | ||
use nix_rs::flake::system::System; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::config::Config; | ||
|
||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] | ||
pub struct GitHubMatrixRow { | ||
pub system: System, | ||
pub subflake: String, | ||
} | ||
|
||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] | ||
pub struct GitHubMatrix { | ||
pub include: Vec<GitHubMatrixRow>, | ||
} | ||
|
||
impl GitHubMatrix { | ||
pub fn new(systems: Vec<System>, subflakes: Vec<String>) -> Self { | ||
let include = iproduct!(systems, subflakes) | ||
.map(|(system, subflake)| GitHubMatrixRow { system, subflake }) | ||
.collect(); | ||
GitHubMatrix { include } | ||
} | ||
} | ||
|
||
pub(crate) async fn dump_github_actions_matrix( | ||
cfg: &Config, | ||
systems: Vec<System>, | ||
) -> anyhow::Result<()> { | ||
// TODO: Should take into account systems whitelist | ||
// Ref: https://github.com/srid/nixci/blob/efc77c8794e5972617874edd96afa8dd4f1a75b2/src/config.rs#L104-L105 | ||
let matrix = GitHubMatrix::new(systems, cfg.subflakes.0.keys().cloned().collect()); | ||
println!("{}", serde_json::to_string(&matrix)?); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod matrix; | ||
pub mod pull_request; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters