Skip to content

Commit

Permalink
refactor(CI): introduce short job names
Browse files Browse the repository at this point in the history
  • Loading branch information
wucke13 committed Nov 1, 2024
1 parent 5e15efd commit a8e7e67
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 67 deletions.
39 changes: 24 additions & 15 deletions .ci/gen-workflow-files.nu
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,33 @@ def depends [
def get-attr-names [
exprs: # nix expressions to get attrNames of
] {
$exprs
$exprs
| par-each {
|expr| nix eval --json $expr --apply builtins.attrNames
| from json
}
| flatten
| uniq
|expr| nix eval --json $expr --apply builtins.attrNames
| from json
}
| flatten
| uniq
| sort
}

def job-id [
derivation:string,
] {
$derivation
| parse '.#{type}.{system}.{name}'
$derivation
| parse '.#{type}.{system}.{name}'
| $"($in.system.0)---($in.type.0)---($in.name.0)"
}


def job-name [
derivation:string,
] {
$derivation
| parse '.#{type}.{system}.{name}'
| $in.name.0
}

# map from nixos system to github runner type
let systems_map = {
# aarch64-darwin
Expand All @@ -61,11 +70,11 @@ let systems_map = {
let categories = [".#packages" ".#devShells" ".#checks"]
let targets = (get-attr-names $categories
| par-each {|system| { $system : (
$categories
$categories
| par-each {
|cat| get-attr-names [$"($cat).($system)"]
| each { $"($cat).($system).($in)" }
}
|cat| get-attr-names [$"($cat).($system)"]
| each { $"($cat).($system).($in)" }
}
| flatten
) } }
| reduce {|it, acc| $acc | merge $it }
Expand Down Expand Up @@ -122,7 +131,7 @@ for system in ($targets | columns) {
let id = ( job-id $derivation )

# name displayed
let name = ( job-id $derivation )
let name = ( job-name $derivation )

# collection of dependencies
# TODO currently only considers dependencies on the same $system
Expand Down Expand Up @@ -152,8 +161,8 @@ for system in ($targets | columns) {
$cachix_workflow.jobs = ($cachix_workflow.jobs | insert $id $new_job )
}

let checks = $derivations
| filter { $in | str contains $'.#checks.($system)' }
let checks = $derivations
| filter { $in | str contains $'.#checks.($system)' }
| each { job-id $in }

# add check job
Expand Down
Loading

0 comments on commit a8e7e67

Please sign in to comment.