Allow for github expressions
Hi! Quite new to Dhall so sorry if this is a dumb question. I'm in the process of converting our entire GH CICD to Dhalll.
Github workflow files extend the standard YAML syntax, in that they allow you to add expressions which can be used to programmatically set variables and inputs for jobs. For example, in our use-case we generate a list of services that need to be re-deployed (call this job A), which is then used as the deployment field in the strategy.matrix key of a later job (call this job B). The strategy in GH workflow syntax looks like:
jobs:
jobA:
outputs:
deployment-matrix: ...
jobB:
strategy:
matrix:
deployment: ${{ fromJson(needs.jobA.outputs.deployment-matrix) }}
However with the current definition of Strategy a value in a matrix needs to be of type List Text, which makes the above impossible.
This isn't specific to strategy.matrix: from what I gather, almost any value in a workflow file can be replaced with a github expression. This is fine when the value is of type Text or Optional Text, but for any other type (like List Text above) it's impossible to use an expression.
Generic solution idea: we could wrap problematic types in a new polymorphic type, e.g.
-- OrGHExpression.dhall
λ(a : Type) → < GHExpression : Text | Value : a >
-- Strategy.dhall
let OrGHExpression = ./OrGHExpression.dhall
in { matrix : List { mapKey : Text, mapValue : OrGHExpression (List Text) }
, fail-fast : Optional Bool
, max-parallel : Optional Natural
}
-- Example.dhall
Some GithubActions.Strategy::{
, matrix =
{ deployment = ListTextOrGH.GHExpression "\${{ fromJson(needs.jobA.outputs.deployment-matrix) }}"
, something-else = ListTextOrGH.Value [ "ubuntu-latest" ]
}
}