From 422e8f34b21041c3006f678bb2e152208b380d80 Mon Sep 17 00:00:00 2001 From: Fabien Boucher Date: Jan 05 2021 12:42:25 +0000 Subject: Generate jobs.yaml with dhall-lang --- diff --git a/zuul.d/jobs.dhall b/zuul.d/jobs.dhall new file mode 100644 index 0000000..085500c --- /dev/null +++ b/zuul.d/jobs.dhall @@ -0,0 +1,199 @@ +{-| + +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 --file jobs.dhall > jobs.yaml + +-} + +let Zuul = + https://raw.githubusercontent.com/softwarefactory-project/dhall-zuul/master/package.dhall + ? ~/git/softwarefactory-project.io/software-factory/dhall-zuul/package.dhall + +let Prelude = + https://prelude.dhall-lang.org/v17.0.0/package.dhall sha256:10db3c919c25e9046833df897a8ffe2701dc390fa0893d958c3430524be5a43e + +let Arch = + let Union = < X86_64 | AARCH64 | PPC64LE > + + let eq_def = { X86_64 = False, AARCH64 = False, PPC64LE = False } + + in { Type = Union + , default = Union.X86_64 + , all = [ Union.X86_64, Union.AARCH64, Union.PPC64LE ] + , show = + λ(arch : Union) → + merge + { X86_64 = "x86_64" + , AARCH64 = "aarch64" + , PPC64LE = "ppc64le" + } + arch + , isX86_64 = λ(arch : Union) → merge (eq_def ⫽ { X86_64 = True }) arch + } + +let Branch = + let --| When changing that union, update the `all` attribute too + Union = + < Master | F32 | F33 | Epel8 > + + let eq_def = { Master = False, F32 = False, F33 = False, Epel8 = False } + + let show = + λ(branch : Union) → + merge + { Master = "master", F32 = "f32", F33 = "f33", Epel8 = "epel8" } + branch + + let all = [ Union.Master, Union.F33, Union.F32, Union.Epel8 ] + + in { Type = Union + , default = Union.Master + , all + , allText = Prelude.List.map Union Text show all + , show + , target = + λ(branch : Union) → + merge + { Master = "rawhide" + , F32 = "f32" + , F33 = "f33" + , Epel8 = "epel8" + } + branch + , isMaster = + λ(branch : Union) → merge (eq_def ⫽ { Master = True }) branch + } + +let KojiBuild = + let Union = < Scratch | Final > + + let eq_def = { Scratch = False, Final = False } + + in { Type = Union + , all = [ Union.Scratch, Union.Final ] + , isScratch = λ(kb : Union) → merge (eq_def ⫽ { Scratch = True }) kb + , show = + λ(kb : Union) → merge { Scratch = "scratch", Final = "final" } kb + } + +let executor_nodeset = + Zuul.Nodeset.Inline + Zuul.Nodeset::{ nodes = [] : List Zuul.Nodeset.NodeType } + +let check_for_tests = + Zuul.Job::{ + , name = Some "check-for-tests" + , description = Some "Check the project has a tests/tests.yml" + , branches = Some Branch.allText + , run = Some "playbooks/rpm/check-for-tests.yaml" + , nodeset = Some executor_nodeset + } + +let common_koji_rpm_build = + Zuul.Job::{ + , name = Some "common-koji-rpm-build" + , abstract = Some True + , protected = Some True + , description = Some "Base job for RPM build on Fedora Koji" + , timeout = Some 21600 + , nodeset = Some (Zuul.Nodeset.Name "fedora-33-container") + , roles = Some [ { zuul = "zuul-distro-jobs" } ] + , run = Some "playbooks/koji/build-ng.yaml" + , provides = Some [ "repo" ] + , secrets = Some + [ Zuul.Job.Secret::{ name = "krb_keytab", secret = "krb_keytab" } ] + } + +let setVars = + λ(target : Text) → + λ(release : Text) → + λ(arch : Text) → + λ(scratch_build : Bool) → + λ(fetch_artifacts : Bool) → + let basevars = + [ { mapKey = "fetch_artifacts" + , mapValue = Zuul.Vars.bool fetch_artifacts + } + , { mapKey = "scratch_build" + , mapValue = Zuul.Vars.bool scratch_build + } + , { mapKey = "target", mapValue = Zuul.Vars.string target } + , { mapKey = "release", mapValue = Zuul.Vars.string release } + ] + + let vars = + if scratch_build + then basevars + # [ { mapKey = "arches", mapValue = Zuul.Vars.string arch } + ] + else basevars + + in Zuul.Vars.object vars + +let generateRpmBuildJobName + : Arch.Type → KojiBuild.Type → Text + = λ(arch : Arch.Type) → + λ(kbtype : KojiBuild.Type) → + let suffix = if Arch.isX86_64 arch then "" else "-" ++ Arch.show arch + + let name = + if KojiBuild.isScratch kbtype + then "rpm-scratch-build" ++ suffix + else "rpm-build" + + in name + +let doFetchArtifact + : Arch.Type → KojiBuild.Type → Bool + = λ(arch : Arch.Type) → + λ(kb : KojiBuild.Type) → + Arch.isX86_64 arch && KojiBuild.isScratch kb + +let generateRpmBuildJob = + λ(kbtype : KojiBuild.Type) → + λ(branch : Branch.Type) → + λ(arch : Arch.Type) → + Zuul.Job::{ + , name = Some (generateRpmBuildJobName arch kbtype) + , parent = Some (Zuul.Job.getName common_koji_rpm_build) + , final = Some True + , branches = Some [ Branch.show branch ] + , vars = Some + ( setVars + (Branch.target branch) + (Branch.show branch) + (Arch.show arch) + (KojiBuild.isScratch kbtype) + (doFetchArtifact arch kbtype) + ) + } + +let generateRpmBuildJobs + : KojiBuild.Type → List Zuul.Job.Type + = λ(kbtype : KojiBuild.Type) → + let forBranch = + λ(branch : Branch.Type) → + Prelude.List.map + Arch.Type + Zuul.Job.Type + (generateRpmBuildJob kbtype branch) + ( if KojiBuild.isScratch kbtype + then Arch.all + else [ Arch.Type.X86_64 ] + ) + + in Prelude.List.concatMap + Branch.Type + Zuul.Job.Type + forBranch + Branch.all + +let Jobs = + [ check_for_tests, common_koji_rpm_build ] + # generateRpmBuildJobs KojiBuild.Type.Scratch + # generateRpmBuildJobs KojiBuild.Type.Final + +in Zuul.Job.wrap Jobs diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml index 91f0a15..094d7b8 100644 --- a/zuul.d/jobs.yaml +++ b/zuul.d/jobs.yaml @@ -1,229 +1,215 @@ + - job: - name: check-for-tests - parent: null - nodeset: - nodes: [] branches: - - f32 + - master - f33 + - f32 - epel8 - - master description: Check the project has a tests/tests.yml + name: check-for-tests + nodeset: + nodes: [] run: playbooks/rpm/check-for-tests.yaml - - job: - name: base-cloud-fedora-latest abstract: true - description: Base job to run on a Fedora virtual machine - nodeset: fedora-latest-vm - host-vars: - cloud-host: - ansible_python_interpreter: /usr/bin/python3 - -- job: - name: common-koji-rpm-build - abstract: true - protected: true description: Base job for RPM build on Fedora Koji - # 6h timeout - timeout: 21600 + name: common-koji-rpm-build nodeset: fedora-33-container + protected: true + provides: + - repo roles: - zuul: zuul-distro-jobs - secrets: - - krb_keytab - provides: repo run: playbooks/koji/build-ng.yaml - -### To be removed when rpms/python-gear project pipelines is re-init + secrets: + - name: krb_keytab + secret: krb_keytab + timeout: 21600 - job: - name: rpm-scratch-build-ng - parent: common-koji-rpm-build + branches: + - master final: true - branches: master - vars: - target: rawhide - release: master - scratch_build: true - fetch_artifacts: false -### - -- job: name: rpm-scratch-build parent: common-koji-rpm-build - final: true - branches: master vars: - target: rawhide + arches: x86_64 + fetch_artifacts: true release: master scratch_build: true - + target: rawhide - job: + branches: + - master + final: true name: rpm-scratch-build-aarch64 parent: common-koji-rpm-build - final: true - branches: master vars: - target: rawhide - release: master - scratch_build: true arches: aarch64 fetch_artifacts: false - + release: master + scratch_build: true + target: rawhide - job: + branches: + - master + final: true name: rpm-scratch-build-ppc64le parent: common-koji-rpm-build - final: true - branches: master vars: - target: rawhide - release: master - scratch_build: true arches: ppc64le fetch_artifacts: false - + release: master + scratch_build: true + target: rawhide - job: + branches: + - f33 + final: true name: rpm-scratch-build parent: common-koji-rpm-build - final: true - branches: f33 vars: - target: f33 + arches: x86_64 + fetch_artifacts: true release: f33 scratch_build: true - + target: f33 - job: + branches: + - f33 + final: true name: rpm-scratch-build-aarch64 parent: common-koji-rpm-build - final: true - branches: f33 vars: - target: f33 - release: f33 - scratch_build: true arches: aarch64 fetch_artifacts: false - + release: f33 + scratch_build: true + target: f33 - job: + branches: + - f33 + final: true name: rpm-scratch-build-ppc64le parent: common-koji-rpm-build - final: true - branches: f33 vars: - target: f33 - release: f33 - scratch_build: true arches: ppc64le fetch_artifacts: false - + release: f33 + scratch_build: true + target: f33 - job: + branches: + - f32 + final: true name: rpm-scratch-build parent: common-koji-rpm-build - final: true - branches: f32 vars: - target: f32 + arches: x86_64 + fetch_artifacts: true release: f32 scratch_build: true - + target: f32 - job: + branches: + - f32 + final: true name: rpm-scratch-build-aarch64 parent: common-koji-rpm-build - final: true - branches: f32 vars: - target: f32 - release: f32 - scratch_build: true arches: aarch64 fetch_artifacts: false - + release: f32 + scratch_build: true + target: f32 - job: + branches: + - f32 + final: true name: rpm-scratch-build-ppc64le parent: common-koji-rpm-build - final: true - branches: f32 vars: - target: f32 - release: f32 - scratch_build: true arches: ppc64le fetch_artifacts: false - + release: f32 + scratch_build: true + target: f32 - job: + branches: + - epel8 + final: true name: rpm-scratch-build parent: common-koji-rpm-build - final: true - branches: epel8 vars: - target: epel8 + arches: x86_64 + fetch_artifacts: true release: epel8 scratch_build: true - + target: epel8 - job: + branches: + - epel8 + final: true name: rpm-scratch-build-aarch64 parent: common-koji-rpm-build - final: true - branches: epel8 vars: - target: epel8 - release: epel8 - scratch_build: true arches: aarch64 fetch_artifacts: false - + release: epel8 + scratch_build: true + target: epel8 - job: + branches: + - epel8 + final: true name: rpm-scratch-build-ppc64le parent: common-koji-rpm-build - final: true - branches: epel8 vars: - target: epel8 - release: epel8 - scratch_build: true arches: ppc64le fetch_artifacts: false - + release: epel8 + scratch_build: true + target: epel8 - job: + branches: + - master + final: true name: rpm-build parent: common-koji-rpm-build - final: true - branches: master vars: - target: rawhide + fetch_artifacts: false release: master scratch_build: false - fetch_artifacts: false - + target: rawhide - job: + branches: + - f33 + final: true name: rpm-build parent: common-koji-rpm-build - final: true - branches: f33 vars: - target: f33 + fetch_artifacts: false release: f33 scratch_build: false - fetch_artifacts: false - + target: f33 - job: + branches: + - f32 + final: true name: rpm-build parent: common-koji-rpm-build - final: true - branches: f32 vars: - target: f32 + fetch_artifacts: false release: f32 scratch_build: false - fetch_artifacts: false - + target: f32 - job: + branches: + - epel8 + final: true name: rpm-build parent: common-koji-rpm-build - final: true - branches: epel8 vars: - target: epel8 + fetch_artifacts: false release: epel8 scratch_build: false - fetch_artifacts: false + target: epel8 diff --git a/zuul.d/projects.yaml b/zuul.d/projects.yaml index e84baf7..d88cce2 100644 --- a/zuul.d/projects.yaml +++ b/zuul.d/projects.yaml @@ -18,10 +18,6 @@ name: rpms/python-gear templates: - publish - check: - jobs: - - rpm-scratch-build-ng: - voting: false - project: name: rpms/python-ws4py