Skip to content

Commit

Permalink
Add Reports to ArtifactsSpec and correctly render them
Browse files Browse the repository at this point in the history
  • Loading branch information
draoncc committed May 4, 2022
1 parent 293ac07 commit 5715741
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 18 deletions.
8 changes: 5 additions & 3 deletions GitLab/ArtifactsSpec/Type.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ let When = ../When/Type.dhall

let Duration = ../Duration/Type.dhall

let Reports = ../Reports/Type.dhall

in { when : When
, expire_in : Duration
, reports : { junit : Optional Text }
, paths : List Text
, expire_in : Optional Duration
, reports : Optional Reports
, paths : Optional (List Text)
}
12 changes: 8 additions & 4 deletions GitLab/ArtifactsSpec/append.dhall
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
let ArtifactsSpec = ./Type.dhall

let mergeOptionalRight = ../utils/mergeOptionalRight.dhall
let Reports = ../Reports/package.dhall

let mergeOptional = ../utils/mergeOptional.dhall

let mergeOptionalList = ../utils/mergeOptionalList.dhall

let append
: ArtifactsSpec ArtifactsSpec ArtifactsSpec
= λ(a : ArtifactsSpec)
λ(b : ArtifactsSpec)
{ when = b.when
, expire_in = b.expire_in
, reports.junit =
mergeOptionalRight Text a.reports.junit b.reports.junit
, paths = a.paths # b.paths
, reports =
mergeOptional Reports.Type Reports.append a.reports b.reports
, paths = mergeOptionalList Text a.paths b.paths
}

in append
10 changes: 7 additions & 3 deletions GitLab/ArtifactsSpec/default.dhall
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
let When = ../When/Type.dhall

let Duration = ../Duration/Type.dhall

let Reports = ../Reports/Type.dhall

in { when = When.OnSuccess
, expire_in = ../Duration/fromDays.dhall 30
, reports.junit = None Text
, paths = [] : List Text
, expire_in = None Duration
, reports = None Reports
, paths = None (List Text)
}
: ./Type.dhall
35 changes: 27 additions & 8 deletions GitLab/ArtifactsSpec/toJSON.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,48 @@ let JSON = Prelude.JSON

let ArtifactsSpec = ../ArtifactsSpec/Type.dhall

let Reports = ../Reports/package.dhall

let Duration = ../Duration/package.dhall

let Optional/map = Prelude.Optional.map

let dropNones = ../utils/dropNones.dhall

let When/toJSON = ../When/toJSON.dhall

let Duration/toJSON = ../Duration/toJSON.dhall

let List/map = Prelude.List.map

let Optional/map = Prelude.Optional.map

let stringsArray
: List Text JSON.Type
= λ(xs : List Text)
JSON.array (Prelude.List.map Text JSON.Type JSON.string xs)

in let ArtifactsSpec/toJSON
: ArtifactsSpec JSON.Type
= λ(cs : ArtifactsSpec)
let obj
: Map.Type Text JSON.Type
: Map.Type Text (Optional JSON.Type)
= toMap
{ when = When/toJSON cs.when
, expire_in = Duration/toJSON cs.expire_in
{ when = Some (When/toJSON cs.when)
, expire_in =
Optional/map
Duration.Type
JSON.Type
Duration.toJSON
cs.expire_in
, reports =
Optional/map
Reports.Type
JSON.Type
Reports.toJSON
cs.reports
, paths =
JSON.array
(List/map Text JSON.Type JSON.string cs.paths)
Optional/map (List Text) JSON.Type stringsArray cs.paths
}

in JSON.object obj
in JSON.object (dropNones Text JSON.Type obj)

in ArtifactsSpec/toJSON
1 change: 1 addition & 0 deletions GitLab/Reports/Type.dhall
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ junit : Optional (List Text) }
11 changes: 11 additions & 0 deletions GitLab/Reports/append.dhall
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
let Reports = ./Type.dhall

let mergeOptionalList = ../utils/mergeOptionalList.dhall

let append
: Reports Reports Reports
= λ(a : Reports)
λ(b : Reports)
{ junit = mergeOptionalList Text a.junit b.junit }

in append
1 change: 1 addition & 0 deletions GitLab/Reports/default.dhall
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ junit = None (List Text) } : ./Type.dhall
5 changes: 5 additions & 0 deletions GitLab/Reports/package.dhall
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{ Type = ./Type.dhall
, default = ./default.dhall
, toJSON = ./toJSON.dhall
, append = ./append.dhall
}
34 changes: 34 additions & 0 deletions GitLab/Reports/toJSON.dhall
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
let Prelude = ../Prelude.dhall

let Map = Prelude.Map

let JSON = Prelude.JSON

let dropNones = ../utils/dropNones.dhall

let Optional/map = Prelude.Optional.map

let Reports = ./Type.dhall

let stringsArray
: List Text JSON.Type
= λ(xs : List Text)
JSON.array (Prelude.List.map Text JSON.Type JSON.string xs)

in let Reports/toJSON
: Reports JSON.Type
= λ(reports : Reports)
let everything
: Map.Type Text (Optional JSON.Type)
= toMap
{ junit =
Optional/map
(List Text)
JSON.Type
stringsArray
reports.junit
}

in JSON.object (dropNones Text JSON.Type everything)

in Reports/toJSON

0 comments on commit 5715741

Please sign in to comment.