mirror of
https://github.com/TecharoHQ/anubis.git
synced 2026-05-17 03:53:10 +00:00
03bf695dff
Signed-off-by: Xe Iaso <me@xeiaso.net>
208 lines
6.9 KiB
YAML
208 lines
6.9 KiB
YAML
apiVersion: tekton.dev/v1beta1
|
|
kind: Pipeline
|
|
metadata:
|
|
name: anubis-build-test
|
|
namespace: ci
|
|
|
|
spec:
|
|
description: |
|
|
The CI/CD pipeline for Anubis
|
|
params:
|
|
- name: repo-url
|
|
type: string
|
|
description: "Git repo to clone"
|
|
default: "https://github.com/TecharoHQ/anubis"
|
|
- name: "branch"
|
|
type: string
|
|
description: "Git branch to operate against"
|
|
- name: "commit"
|
|
type: string
|
|
description: "Git revision to check out"
|
|
- name: "actor"
|
|
type: string
|
|
description: "Tangled actor"
|
|
default: "did:web:anubis.techaro.lol"
|
|
- name: docker-image-base
|
|
type: string
|
|
description: string prefix for production docker images
|
|
default: "registry.int.xeserv.us/techarohq"
|
|
- name: docker-cache
|
|
type: string
|
|
description: docker repo to store cache files
|
|
default: "registry.int.xeserv.us/techarohq/anubis/cache"
|
|
- name: go-version
|
|
type: string
|
|
description: "Go version to use"
|
|
default: "1.26.3"
|
|
workspaces:
|
|
- name: repo
|
|
description: |
|
|
Cloned repo files.
|
|
- name: dockerconfig-atcr
|
|
description: |
|
|
Docker config for pushing images to atcr
|
|
- name: dockerconfig-ghcr
|
|
description: |
|
|
Docker config for pushing images to ghcr
|
|
tasks:
|
|
- name: fix-permissions
|
|
taskRef:
|
|
name: fix-permissions
|
|
workspaces:
|
|
- name: dir
|
|
workspace: repo
|
|
- name: clone-repo
|
|
runAfter: ["fix-permissions"]
|
|
taskRef:
|
|
name: git-clone-naive
|
|
workspaces:
|
|
- name: output
|
|
workspace: repo
|
|
params:
|
|
- name: url
|
|
value: $(params.repo-url)
|
|
- name: revision
|
|
value: $(params.commit)
|
|
- name: docker-build-ci
|
|
runAfter: ["clone-repo"]
|
|
workspaces:
|
|
- name: source
|
|
workspace: repo
|
|
taskRef:
|
|
name: kaniko
|
|
params:
|
|
- name: IMAGE
|
|
value: $(params.docker-image-base)/anubis/ci:$(tasks.clone-repo.results.version)
|
|
- name: DOCKERFILE
|
|
value: ./test/ssh-ci/Dockerfile
|
|
- name: EXTRA_ARGS
|
|
value:
|
|
[
|
|
"--build-arg=GO_VERSION=$(params.go-version)",
|
|
"--cache",
|
|
"--cache-copy-layers",
|
|
"--cache-run-layers",
|
|
"--cache-repo=$(params.docker-cache)",
|
|
"--label=org.tangled.actor=$(params.actor)",
|
|
"--snapshot-mode=redo",
|
|
"--use-new-run",
|
|
]
|
|
- name: provision-test-cluster
|
|
runAfter: ["docker-build-ci"]
|
|
taskSpec:
|
|
workspaces:
|
|
- name: repo
|
|
mountPath: /src
|
|
results:
|
|
- name: cluster-name
|
|
description: "k3k cluster name object in k8s"
|
|
steps:
|
|
- name: create-cluster
|
|
image: $(tasks.docker-build-ci.results.IMAGE_URL)@$(tasks.docker-build-ci.results.IMAGE_DIGEST)
|
|
workingDir: $(workspaces.repo.path)/repo
|
|
script: |
|
|
CLUSTER_NAME=`kubectl create -f test/k3k/test-cluster.yaml -ojson | jq -r '.metadata.name'`
|
|
echo -n "${CLUSTER_NAME}" | tee "$(results.cluster-name.path)"
|
|
echo
|
|
kubectl label -n $(context.pipelineRun.namespace) clusters.k3k.io/"${CLUSTER_NAME}" tekton.dev/memberOf=tasks tekton.dev/pipeline="$(context.pipeline.name)" tekton.dev/pipelineRun=$(context.pipelineRun.name) tekton.dev/pipelineRunUID=$(context.pipelineRun.uid)
|
|
kubectl wait --for=condition=Ready clusters.k3k.io/"${CLUSTER_NAME}" -n $(context.pipelineRun.namespace) --timeout 5m
|
|
kubectl wait --for=create "secret/k3k-${CLUSTER_NAME}-kubeconfig" -n $(context.pipelineRun.namespace) --timeout 5m
|
|
mkdir -p $(workspaces.repo.path)/kube
|
|
kubectl get -ojson -n $(context.pipelineRun.namespace) "secret/k3k-${CLUSTER_NAME}-kubeconfig" | jq '.data["kubeconfig.yaml"]' -r | base64 -d > $(workspaces.repo.path)/kube/config
|
|
- name: build-assets
|
|
runAfter: ["docker-build-ci"]
|
|
taskSpec:
|
|
workspaces:
|
|
- name: repo
|
|
mountPath: /src
|
|
steps:
|
|
- name: test
|
|
image: $(tasks.docker-build-ci.results.IMAGE_URL)@$(tasks.docker-build-ci.results.IMAGE_DIGEST)
|
|
workingDir: $(workspaces.repo.path)/repo
|
|
script: |
|
|
npm ci
|
|
npm run assets
|
|
workspaces:
|
|
- name: repo
|
|
workspace: repo
|
|
- name: go-test
|
|
runAfter: ["build-assets"]
|
|
taskSpec:
|
|
workspaces:
|
|
- name: repo
|
|
mountPath: /src
|
|
steps:
|
|
- name: test
|
|
image: $(tasks.docker-build-ci.results.IMAGE_URL)@$(tasks.docker-build-ci.results.IMAGE_DIGEST)
|
|
workingDir: $(workspaces.repo.path)/repo
|
|
script: |
|
|
SKIP_INTEGRATION=1 go test ./...
|
|
workspaces:
|
|
- name: repo
|
|
workspace: repo
|
|
- name: test-anubis
|
|
runAfter: ["build-assets"]
|
|
taskRef:
|
|
name: ko
|
|
workspaces:
|
|
- name: source
|
|
workspace: repo
|
|
params:
|
|
- name: VERSION
|
|
value: $(tasks.clone-repo.results.version)
|
|
- name: SOURCE_DATE_EPOCH
|
|
value: $(tasks.clone-repo.results.source-date-epoch)
|
|
- name: KO_DOCKER_REPO
|
|
value: $(params.docker-image-base)
|
|
- name: extra-args
|
|
value:
|
|
[
|
|
"--platform=all",
|
|
"--base-import-paths",
|
|
"--tags=$(tasks.clone-repo.results.version)",
|
|
"--image-label=org.tangled.actor=$(params.actor)",
|
|
]
|
|
- name: packages
|
|
value:
|
|
- ./cmd/anubis
|
|
- name: integration
|
|
runAfter:
|
|
- "provision-test-cluster"
|
|
- "build-assets"
|
|
- "test-anubis"
|
|
matrix:
|
|
params:
|
|
- name: test-case
|
|
value:
|
|
- default-config-macro
|
|
- i18n
|
|
- robots_txt
|
|
taskSpec:
|
|
params:
|
|
- name: test-case
|
|
type: string
|
|
workspaces:
|
|
- name: repo
|
|
mountPath: /src
|
|
steps:
|
|
- name: exec
|
|
image: $(tasks.docker-build-ci.results.IMAGE_URL)@$(tasks.docker-build-ci.results.IMAGE_DIGEST)
|
|
workingDir: $(workspaces.repo.path)/repo/test/$(params.test-case)
|
|
script: |
|
|
./tekton.sh
|
|
env:
|
|
- name: KUBECONFIG
|
|
value: "$(workspaces.repo.path)/kube/config"
|
|
- name: teardown-cluster
|
|
runAfter: ["provision-test-cluster", "go-test", "integration"]
|
|
taskSpec:
|
|
workspaces:
|
|
- name: repo
|
|
mountPath: /src
|
|
steps:
|
|
- name: delete
|
|
image: $(tasks.docker-build-ci.results.IMAGE_URL)@$(tasks.docker-build-ci.results.IMAGE_DIGEST)
|
|
workingDir: $(workspaces.repo.path)/repo
|
|
script: |
|
|
kubectl delete -n $(context.pipelineRun.namespace) clusters.k3k.io/"$(tasks.provision-test-cluster.results.cluster-name)"
|