diff --git a/src/github/matrix.rs b/src/github/matrix.rs index 11c2197..66929dc 100644 --- a/src/github/matrix.rs +++ b/src/github/matrix.rs @@ -3,7 +3,7 @@ use itertools::iproduct; use nix_rs::flake::system::System; use serde::{Deserialize, Serialize}; -use crate::config::Config; +use crate::config::{Config, SubFlakish}; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub struct GitHubMatrixRow { @@ -29,9 +29,25 @@ pub(crate) async fn dump_github_actions_matrix( cfg: &Config, systems: Vec, ) -> 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()); + let include = iproduct!( + systems, + cfg.subflakes + .0 + .iter() + .collect::>() + ) + .flat_map(|(system, (k, v))| { + if v.can_build_on(&vec![system.clone()]) { + Some(GitHubMatrixRow { + system, + subflake: k.to_string(), + }) + } else { + None + } + }) + .collect(); + let matrix = GitHubMatrix { include }; println!("{}", serde_json::to_string(&matrix)?); Ok(()) }