From c570ae93d29ce6b1ba17cea44d0be0dd276c11bd Mon Sep 17 00:00:00 2001 From: James Pace Date: Wed, 3 Jan 2024 21:51:52 -0500 Subject: [PATCH] Add v0 of limbo tasks. --- limbo/kustomization.yaml | 6 ++++ limbo/limbo-just-build.yaml | 20 +++++++++++++ limbo/limbo-pipeline.yaml | 56 ++++++++++++++++++++++++++++++++++ limbo/limbo-trigger.yaml | 60 +++++++++++++++++++++++++++++++++++++ 4 files changed, 142 insertions(+) create mode 100644 limbo/kustomization.yaml create mode 100644 limbo/limbo-just-build.yaml create mode 100644 limbo/limbo-pipeline.yaml create mode 100644 limbo/limbo-trigger.yaml diff --git a/limbo/kustomization.yaml b/limbo/kustomization.yaml new file mode 100644 index 0000000..9d7509f --- /dev/null +++ b/limbo/kustomization.yaml @@ -0,0 +1,6 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: +- limbo-just-build.yaml +- limbo-pipeline.yaml +- limbo-trigger.yaml \ No newline at end of file diff --git a/limbo/limbo-just-build.yaml b/limbo/limbo-just-build.yaml new file mode 100644 index 0000000..c7c54b4 --- /dev/null +++ b/limbo/limbo-just-build.yaml @@ -0,0 +1,20 @@ +apiVersion: tekton.dev/v1beta1 +kind: Task +metadata: + name: limbo-just-build +spec: + workspaces: + - name: source + steps: + - image: harbor.internal.jpace121.net/k8s/ansible-podman:latest + script: | + #!/usr/bin/env bash + set -ex + cp -r $(workspaces.ssh-directory.path) ~/.ssh + chmod 700 ~/.ssh + chmod -R 400 ~/.ssh/* + ssh-keyscan -H -p 2222 git.jpace121.net >> ~/.ssh/known_hosts + + cd $(workspaces.source.path) + just ci/build + just ci/test \ No newline at end of file diff --git a/limbo/limbo-pipeline.yaml b/limbo/limbo-pipeline.yaml new file mode 100644 index 0000000..70d4812 --- /dev/null +++ b/limbo/limbo-pipeline.yaml @@ -0,0 +1,56 @@ +# A pipeline to build limbo. +--- +apiVersion: tekton.dev/v1beta1 +kind: Pipeline +metadata: + name: limbo-pipeline +spec: + description: "Pipeline for limbo project." + workspaces: + - name: shared-data + description: Shared data. + - name: git-credentials + description: tekton git credentials + params: + - name: sha + description: git hash to checkout + default: main + - name: gitea-repo-name + description: name of the repo in gitea (the part right before .git in the clone url) + default: limbo + tasks: + - name: fetch-repo + workspaces: + - name: output + workspace: shared-data + - name: ssh-directory + workspace: git-credentials + params: + - name: url + value: ssh://git@git.jpace121.net:2222/limbo/$(params.gitea-repo-name).git + - name: branch + value: $(params.sha) + taskRef: + name: j7s-git-clone-hash + - name: call-just + runAfter: ["fetch-repo"] + workspaces: + - name: source + workspace: shared-data + taskRef: + name: limbo-just-build + finally: + - name: gitea-status + params: + - name: git-owner + value: limbo + - name: git-repo-name + value: $(params.gitea-repo-name) + - name: name + value: j7s-ci/limbo-pipeline + - name: sha + value: $(tasks.fetch-repo.results.hash) + - name: status + value: $(tasks.status) + taskRef: + name: j7s-gitea-status diff --git a/limbo/limbo-trigger.yaml b/limbo/limbo-trigger.yaml new file mode 100644 index 0000000..a0fb49c --- /dev/null +++ b/limbo/limbo-trigger.yaml @@ -0,0 +1,60 @@ +--- +apiVersion: triggers.tekton.dev/v1beta1 +kind: EventListener +metadata: + name: limbo-pipeline-listener +spec: + triggers: + - name: limbo-pipeline-trigger + bindings: + - ref: limbo-pipeline-binding + template: + ref: limbo-pipeline-template + resources: + kubernetesResource: + serviceType: ClusterIP +--- +apiVersion: triggers.tekton.dev/v1beta1 +kind: TriggerBinding +metadata: + name: limbo-pipeline-binding +spec: + params: + - name: sha + value: $(body.sha) + - name: repo_name + value: $(body.repo_name) +--- +apiVersion: triggers.tekton.dev/v1beta1 +kind: TriggerTemplate +metadata: + name: limbo-pipeline-template +spec: + params: + - name: sha + - name: repo_name + resourcetemplates: + - apiVersion: tekton.dev/v1beta1 + kind: PipelineRun + metadata: + generateName: limbo-pipeline- + spec: + pipelineRef: + name: limbo-pipeline + params: + - name: sha + value: "$(tt.params.sha)" + - name: gitea-repo-name + value: "$(tt.params.repo_name)" + workspaces: + - name: shared-data + volumeClaimTemplate: + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi + - name: git-credentials + secret: + secretName: git-credentials \ No newline at end of file