Skip to content

Commit

Permalink
Merge pull request #316 from darkdoc/refactor_pipelines
Browse files Browse the repository at this point in the history
Refactor pipelines using helm
  • Loading branch information
mbaldessari authored Nov 28, 2024
2 parents 35ca9de + a37cba4 commit fc315f5
Show file tree
Hide file tree
Showing 21 changed files with 467 additions and 1,639 deletions.
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ check-pipeline-resources: ## wait for all seed resources to be present
scripts/check-pipeline-resources.sh

.PHONY: seed
seed: check-pipeline-resources ## run the seed pipipeline (test and prod, no pr)
seed: check-pipeline-resources ## run the seed pipeline (build all component, push to all env, no pr)
oc create -f charts/datacenter/pipelines/extra/seed-run.yaml

.PHONY: build-and-test-iot-anomaly-detection
build-and-test-iot-anomaly-detection: ## run a build and test pipeline iot anomaly detection
oc create -f charts/datacenter/pipelines/extra/build-and-test-run-iot-anomaly-detection.yaml
build-and-test-iot-anomaly-detection: ## run iot anomaly detection pipeline (build, test, push to manuela-tst-all, pr for prod)
oc create -f charts/datacenter/pipelines/extra/build-and-test-iot-anomaly-detection.yaml

.PHONY: build-and-test-iot-consumer
build-and-test-iot-consumer: ## run a build and test pipeline iot consumer
oc create -f charts/datacenter/pipelines/extra/build-and-test-run-iot-consumer.yaml
build-and-test-iot-consumer: ## run iot consumer pipeline (build, test, push to manuela-tst-all, pr for prod)
oc create -f charts/datacenter/pipelines/extra/build-and-test-iot-consumer.yaml

.PHONY: build-and-test-iot-frontend
build-and-test-iot-frontend: ## run a build and test pipeline iot frontend
build-and-test-iot-frontend: ## run iot frontend pipeline (build, test, push to manuela-tst-all, pr for prod)
oc create -f charts/datacenter/pipelines/extra/build-and-test-iot-frontend.yaml

.PHONY: build-and-test-iot-software-sensor
build-and-test-iot-software-sensor: ## run a build and test pipeline iot software-sensor
build-and-test-iot-software-sensor: ## run iot software-sensor pipeline (build, test, push to manuela-tst-all, pr for prod)
oc create -f charts/datacenter/pipelines/extra/build-and-test-iot-software-sensor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ spec:
- name: build-artifacts
persistentVolumeClaim:
claimName: build-artifacts-rwo
- name: github-secret
secret:
secretName: gitea-admin-secret
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ spec:
- name: build-artifacts
persistentVolumeClaim:
claimName: build-artifacts-rwo
- name: github-secret
secret:
secretName: gitea-admin-secret
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ spec:
- name: build-artifacts
persistentVolumeClaim:
claimName: build-artifacts-rwo
- name: github-secret
secret:
secretName: gitea-admin-secret
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ spec:
- name: build-artifacts
persistentVolumeClaim:
claimName: build-artifacts-rwo
- name: github-secret
secret:
secretName: gitea-admin-secret
293 changes: 293 additions & 0 deletions charts/datacenter/pipelines/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,293 @@
{{- define "build-base-images" -}}
- name: buildah-build
taskRef:
name: buildah
runAfter:
- git-clone-ops
- git-clone-dev
workspaces:
- name: gitrepos
workspace: gitrepos
- name: config
workspace: config
params:
- name: TLSVERIFY
value: "false"
- name: PATH_CONTEXT
value: tekton/images/httpd-ionic
- name: TAG
value: latest
- name: OUTPUT_IMAGE_PROVIDER_CONFIGMAPKEY
value: IMAGE_PROVIDER
- name: OUTPUT_IMAGE_ACCOUNT_CONFIGMAPKEY
value: IMAGE_ACCOUNT
- name: OUTPUT_IMAGE_NAME
value: httpd-ionic
{{- end }} {{/* build-base-images */}}

{{- define "build-iot-component" }}
- name: bump-build-version-{{ .component.component_name }}
displayName: "Bump version for {{ .component.component_name }}"
taskRef:
name: bumpversion
runAfter:
- git-clone-ops
- git-clone-dev
workspaces:
- name: gitrepos
workspace: gitrepos
params:
- name: component_name
value: {{ .component.component_name }}
- name: version_file_path
value: components/{{ .component.component_name }}/VERSION

- name: s2i-build-{{ .component.component_name }}
displayName: "S2I build IoT {{ .component.component_name }}"
taskRef:
name: s2i
runAfter:
- bump-build-version-{{ .component.component_name }}
workspaces:
- name: gitrepos
workspace: gitrepos
- name: build-artifacts
workspace: build-artifacts
params:
- name: TLSVERIFY
value: "false"
- name: PATH_CONTEXT
value: components/{{ .component.component_name }}
- name: BUILDER_IMAGE
value: {{ .component.builder_image }}
{{- if .component.chained_build_dockerfile }}
- name: CHAINED_BUILD_DOCKERFILE
value: {{ .component.chained_build_dockerfile }}
{{- end }}
- name: TAG
value: $(tasks.bump-build-version-{{ .component.component_name }}.results.image-tag)
- name: OUTPUT_IMAGE
value: image-registry.openshift-image-registry.svc:5000/manuela-tst-all/{{ .component.output_image_name }}

- name: copy-image-to-remote-registry-{{ .component.component_name }}
displayName: "Copy image to remote registry"
taskRef:
name: skopeo-copy
runAfter:
- s2i-build-{{ .component.component_name }}
workspaces:
- name: config
workspace: config
params:
- name: TAG
value: $(tasks.bump-build-version-{{ .component.component_name }}.results.image-tag)
- name: SOURCE_IMAGE
value: image-registry.openshift-image-registry.svc:5000/manuela-tst-all/{{ .component.output_image_name }}
- name: TARGET_IMAGE_CONFIGMAPKEY
value: {{ .component.configmap_prefix }}_IMAGE

- name: push-dev-tag-{{ .component.component_name }}
taskRef:
name: github-push
runAfter:
- copy-image-to-remote-registry-{{ .component.component_name }}
workspaces:
- name: gitrepos
workspace: gitrepos
params:
- name: PUSH_FLAGS
value: --tags

- name: modify-ops-test-iot-component-{{ .component.component_name }}
taskRef:
name: gitops-imagetag
runAfter:
- push-dev-tag-{{ .component.component_name }}
workspaces:
- name: gitrepos
workspace: gitrepos
- name: config
workspace: config
params:
- name: CONFIGMAP_PREFIX
value: {{ .component.configmap_prefix }}
- name: ENVIRONMENT
value: TEST
- name: TAG
value: $(tasks.bump-build-version-{{ .component.component_name }}.results.image-tag)
- name: subdirectory
value: ops

- name: modify-ops-prod-iot-component-{{ .component.component_name }}
when:
- input: "{{ .seed_prod }}"
operator: in
values: ["true"]
taskRef:
name: gitops-imagetag
runAfter:
- modify-ops-test-iot-component-{{ .component.component_name }}
workspaces:
- name: gitrepos
workspace: gitrepos
- name: config
workspace: config
params:
- name: CONFIGMAP_PREFIX
value: {{ .component.configmap_prefix }}
- name: ENVIRONMENT
value: PROD
- name: TAG
value: $(tasks.bump-build-version-{{ .component.component_name }}.results.image-tag)
- name: subdirectory
value: ops

- name: commit-ops-{{ .component.component_name }}
taskRef:
name: git-commit
runAfter:
- modify-ops-prod-iot-component-{{ .component.component_name }}
workspaces:
- name: gitrepos
workspace: gitrepos
- name: config
workspace: config
params:
- name: subdirectory
value: ops

- name: push-ops-{{ .component.component_name }}
taskRef:
name: github-push
runAfter:
- commit-ops-{{ .component.component_name }}
workspaces:
- name: gitrepos
workspace: gitrepos
params:
- name: subdirectory
value: ops
- name: PUSH_FLAGS
value: --all
{{- end }} {{/* build-iot-component */}}

{{- define "test-all" }}
- name: sensor-broker-test
taskRef:
name: mock
kind: Task
runAfter:
- argocd-sync-application
params:
- name: MESSAGE
value: "succesfully sent messages to broker..."
- name: consumer-broker-test
taskRef:
name: mock
kind: Task
runAfter:
- argocd-sync-application
params:
- name: MESSAGE
value: "succesfully processed messages from broker..."
- name: consumer-frontend-test
taskRef:
name: mock
kind: Task
runAfter:
- argocd-sync-application
params:
- name: MESSAGE
value: "succesfully executed Websocket APIs..."
- name: e2e-test
taskRef:
name: mock
kind: Task
runAfter:
- sensor-broker-test
- consumer-broker-test
- consumer-frontend-test
params:
- name: MESSAGE
value: "e2e testsuite succesfully executed"
{{- end }}

{{- define "trigger-staging" }}
- name: checkout-staging-branch
taskRef:
name: git-checkout
runAfter:
- e2e-test
workspaces:
- name: gitrepos
workspace: gitrepos
params:
- name: subdirectory
value: ops
- name: BRANCH
value: staging-approval
- name: STARTINGBRANCH
value: {{ .root.global.targetRevision }}
- name: modify-ops-prod
taskRef:
name: gitops-imagetag
runAfter:
- checkout-staging-branch
workspaces:
- name: gitrepos
workspace: gitrepos
- name: config
workspace: config
params:
- name: CONFIGMAP_PREFIX
value: {{ .component.configmap_prefix }}
- name: ENVIRONMENT
value: PROD
- name: TAG
value: $(tasks.bump-build-version-{{ .component.component_name }}.results.image-tag)
- name: subdirectory
value: ops
- name: commit-ops-prod
taskRef:
name: git-commit
runAfter:
- modify-ops-prod
workspaces:
- name: gitrepos
workspace: gitrepos
- name: config
workspace: config
params:
- name: subdirectory
value: ops
- name: push-ops-prod
taskRef:
name: github-push
runAfter:
- commit-ops-prod
workspaces:
- name: gitrepos
workspace: gitrepos
params:
- name: subdirectory
value: ops
- name: PUSH_FLAGS
value: --set-upstream origin staging-approval -f
- name: github-pull-request
taskRef:
name: github-add-pull-request
runAfter:
- push-ops-prod
workspaces:
- name: config
workspace: config
- name: github-secret
workspace: github-secret
params:
- name: GITHUB_REPO_CONFIGMAPKEY
value: GIT_OPS_REPO_PROD_URL
- name: GIT_BRANCH_HEAD
value: staging-approval
- name: GIT_BRANCH_BASE
value: {{ .root.global.targetRevision }}
{{- end }}
Loading

0 comments on commit fc315f5

Please sign in to comment.