Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for github expressions #75

Open
fpringle opened this issue Sep 10, 2023 · 0 comments
Open

Allow for github expressions #75

fpringle opened this issue Sep 10, 2023 · 0 comments

Comments

@fpringle
Copy link

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" ] 
  } 
} 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant