From 6a31013235b40129ebe5e3e081552a1555a2fa92 Mon Sep 17 00:00:00 2001 From: Fabien Boucher Date: Jan 25 2021 17:35:43 +0000 Subject: Manage templates.yaml with dhall --- diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml index aa40c7a..128b79f 100644 --- a/zuul.d/jobs.yaml +++ b/zuul.d/jobs.yaml @@ -1,3 +1,4 @@ +# Code generated by dhall-to-yaml. DO NOT EDIT. - job: name: rpm-install-test diff --git a/zuul.d/templates.dhall b/zuul.d/templates.dhall new file mode 100644 index 0000000..43b80f4 --- /dev/null +++ b/zuul.d/templates.dhall @@ -0,0 +1,128 @@ +{-| + +This Dhall definition helps to maintain the jobs.yaml definition for Zuul. +The Dhall-Zuul library is used to benefit base Dhall type and function for Zuul +objects. + +To compute the jobs.yaml run: + + dhall-to-yaml --generated-comment --file templates.dhall | zuulfmt > templates.yaml + +Install dhall by following https://docs.dhall-lang.org/tutorials/Getting-started_Generate-JSON-or-YAML.html#installation +Install zuulfmt by running: `python3 -mpip install --user zuulfmt` + +-} + +let Zuul = + ~/git/softwarefactory-project.io/software-factory/dhall-zuul/package.dhall + ? https://softwarefactory-project.io/cgit/software-factory/dhall-zuul/plain/package.dhall + +let Prelude = + https://prelude.dhall-lang.org/v17.0.0/package.dhall sha256:10db3c919c25e9046833df897a8ffe2701dc390fa0893d958c3430524be5a43e + +let FZCI = ~/git/pagure.io/fedora-project-config/FZCI.dhall/package.dhall + +let build = + let createSBJobsForArches = + Prelude.List.map + FZCI.Arches.Type + Zuul.Job.Union + ( λ(arch : FZCI.Arches.Type) → + if FZCI.Arches.isX86_64 arch + then Zuul.Job.Name "rpm-scratch-build" + else Zuul.Job.Inline + Zuul.Job::{ + , name = "rpm-scratch-build-${FZCI.Arches.show arch}" + , voting = Some False + } + ) + FZCI.Arches.fedora + + in toMap + { name = Zuul.ProjectTemplate.Name "build" + , check = + Zuul.ProjectTemplate.Pipeline + Zuul.ProjectPipeline::{ + , jobs = + [ Zuul.Job.Name "check-for-arches" ] + # createSBJobsForArches + } + } + +let lint = + toMap + { name = Zuul.ProjectTemplate.Name "lint" + , check = + Zuul.ProjectTemplate.Pipeline + Zuul.ProjectPipeline::{ + , jobs = + [ Zuul.Job.Inline + Zuul.Job::{ + , name = "rpm-linter" + , dependencies = Some + [ Zuul.Job.Dependency.Name "rpm-scratch-build" ] + } + , Zuul.Job.Inline + Zuul.Job::{ + , name = "rpm-rpminspect" + , voting = Some False + , dependencies = Some + [ Zuul.Job.Dependency.Name "rpm-scratch-build" ] + } + ] + } + } + +let test = + toMap + { name = Zuul.ProjectTemplate.Name "test" + , check = + Zuul.ProjectTemplate.Pipeline + Zuul.ProjectPipeline::{ + , jobs = + [ Zuul.Job.Inline + Zuul.Job::{ + , name = "check-for-tests" + , dependencies = Some + [ Zuul.Job.Dependency.Name "rpm-scratch-build" ] + } + , Zuul.Job.Inline + Zuul.Job::{ + , name = "rpm-install-test" + , dependencies = Some + [ Zuul.Job.Dependency.Name "check-for-tests" + , Zuul.Job.Dependency.Name "rpm-scratch-build" + ] + } + , Zuul.Job.Inline + Zuul.Job::{ + , name = "rpm-test" + , dependencies = Some + [ Zuul.Job.Dependency.Name "check-for-tests" + , Zuul.Job.Dependency.Name "rpm-scratch-build" + ] + } + ] + } + } + +let publish = + toMap + { name = Zuul.ProjectTemplate.Name "publish" + , gate = + Zuul.ProjectTemplate.Pipeline + Zuul.ProjectPipeline::{ jobs = [ Zuul.Job.Name "noop" ] } + , promote = + Zuul.ProjectTemplate.Pipeline + Zuul.ProjectPipeline::{ jobs = [ Zuul.Job.Name "rpm-build" ] } + } + +let testTestsDef = + toMap + { name = Zuul.ProjectTemplate.Name "test-tests-def" + , check = + Zuul.ProjectTemplate.Pipeline + Zuul.ProjectPipeline::{ jobs = [ Zuul.Job.Name "rpm-test" ] } + } + +in Zuul.ProjectTemplate.wrap [ build, lint, test, publish, testTestsDef ] diff --git a/zuul.d/templates.yaml b/zuul.d/templates.yaml index 3f53cc0..054ad03 100644 --- a/zuul.d/templates.yaml +++ b/zuul.d/templates.yaml @@ -1,60 +1,61 @@ ---- +# Code generated by dhall-to-yaml. DO NOT EDIT. + - project-template: - name: build check: jobs: - - rpm-scratch-build - - check-for-arches - - rpm-scratch-build-aarch64: - voting: false - - rpm-scratch-build-ppc64le: - voting: false - - rpm-scratch-build-armv7hl: - voting: false - - rpm-scratch-build-i686: - voting: false - - rpm-scratch-build-s390x: - voting: false + - check-for-arches + - rpm-scratch-build + - rpm-scratch-build-s390x: + voting: false + - rpm-scratch-build-ppc64le: + voting: false + - rpm-scratch-build-i686: + voting: false + - rpm-scratch-build-armv7hl: + voting: false + - rpm-scratch-build-aarch64: + voting: false + name: build - project-template: - name: lint check: jobs: - - rpm-linter: - dependencies: - - rpm-scratch-build - - rpm-rpminspect: - voting: False - dependencies: - - rpm-scratch-build + - rpm-linter: + dependencies: + - rpm-scratch-build + - rpm-rpminspect: + dependencies: + - rpm-scratch-build + voting: false + name: lint - project-template: - name: test check: jobs: - - check-for-tests: - dependencies: - - rpm-scratch-build - - rpm-install-test: - dependencies: - - check-for-tests - - rpm-scratch-build - - rpm-test: - dependencies: - - check-for-tests - - rpm-scratch-build + - check-for-tests: + dependencies: + - rpm-scratch-build + - rpm-install-test: + dependencies: + - check-for-tests + - rpm-scratch-build + - rpm-test: + dependencies: + - check-for-tests + - rpm-scratch-build + name: test - project-template: - name: publish gate: jobs: - noop + name: publish promote: jobs: - rpm-build - project-template: - name: test-tests-def check: jobs: - - rpm-test + - rpm-test + name: test-tests-def