From 2d1d4c0522d116bf165db6741924a2529e439269 Mon Sep 17 00:00:00 2001 From: Mykola Serdiuk Date: Thu, 12 Oct 2023 14:45:56 +0300 Subject: [PATCH] chore: Join Kaniko task for ECR and Harbor into one (#47) Jira EPMDEDP-12618 Related https://github.com/epam/edp-tekton/issues/47 Change-Id: I2174845e6c8351e891c451f25213a1a873c55aba --- .../templates/pipelines/_common_docker.yaml | 34 +- .../templates/pipelines/_common_dotnet.yaml | 33 +- .../templates/pipelines/_common_go.yaml | 33 +- .../pipelines/_common_java_gradle.yaml | 33 +- .../pipelines/_common_java_maven.yaml | 36 +- .../templates/pipelines/_common_js_npm.yaml | 64 +- .../templates/pipelines/_common_python.yaml | 33 +- .../templates/tasks/kaniko-eks.yaml | 28 + .../tests/test_container_pipelines.py | 201 ---- .../tests/test_dotnet_pipelines.py | 334 ------- .../tests/test_go_pipelines.py | 247 ----- .../tests/test_java_gradle_pipelines.py | 333 ------- .../tests/test_java_maven_pipelines.py | 418 --------- .../tests/test_javascript_antora_pipelines.py | 214 ----- .../tests/test_javascript_pipelines.py | 351 ------- .../tests/test_python_pipelines.py | 883 ------------------ 16 files changed, 43 insertions(+), 3232 deletions(-) diff --git a/charts/pipelines-library/templates/pipelines/_common_docker.yaml b/charts/pipelines-library/templates/pipelines/_common_docker.yaml index 77d3cc94..9bd938b9 100644 --- a/charts/pipelines-library/templates/pipelines/_common_docker.yaml +++ b/charts/pipelines-library/templates/pipelines/_common_docker.yaml @@ -1,34 +1,4 @@ {{- define "build-pipeline-docker-image-build-push-common" -}} -{{- if eq .Values.global.dockerRegistry.type "ecr" }} -- name: create-ecr-repository - taskRef: - kind: Task - name: create-ecr-repository - runAfter: - - dockerfile-lint - params: - - name: REPO_NAME - value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/$(params.CODEBASE_NAME)" - -- name: kaniko-build - taskRef: - kind: Task - name: kaniko - runAfter: - - create-ecr-repository - params: - - name: IMAGE - value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/$(params.CODEBASE_NAME):$(tasks.get-version.results.IS_TAG)" - - name: IMAGE_TAR - value: "$(params.CODEBASE_NAME)_$(tasks.get-version.results.IS_TAG)" - - name: KANIKO_CACHE_REPO - value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/kaniko-cache" - workspaces: - - name: source - workspace: shared-workspace -{{- end }} - -{{- if or (eq .Values.global.dockerRegistry.type "harbor") (eq .Values.global.dockerRegistry.type "dockerhub") }} - name: kaniko-build taskRef: kind: Task @@ -42,8 +12,10 @@ value: "$(params.CODEBASE_NAME)_$(tasks.get-version.results.IS_TAG)" - name: KANIKO_CACHE_REPO value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/kaniko-cache" + - name: REPO_NAME + value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/$(params.CODEBASE_NAME)" + workspaces: - name: source workspace: shared-workspace -{{- end }} {{- end -}} diff --git a/charts/pipelines-library/templates/pipelines/_common_dotnet.yaml b/charts/pipelines-library/templates/pipelines/_common_dotnet.yaml index 2dcd7d19..94282ec5 100644 --- a/charts/pipelines-library/templates/pipelines/_common_dotnet.yaml +++ b/charts/pipelines-library/templates/pipelines/_common_dotnet.yaml @@ -382,36 +382,6 @@ {{- end -}} {{- define "build-pipeline-dotnet-image-build-push-common" -}} -{{- if eq .Values.global.dockerRegistry.type "ecr" }} -- name: create-ecr-repository - taskRef: - kind: Task - name: create-ecr-repository - runAfter: - - dotnet-publish - params: - - name: REPO_NAME - value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/$(params.CODEBASE_NAME)" - -- name: kaniko-build - taskRef: - kind: Task - name: kaniko - runAfter: - - create-ecr-repository - params: - - name: IMAGE - value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/$(params.CODEBASE_NAME):$(tasks.get-version.results.IS_TAG)" - - name: IMAGE_TAR - value: "$(params.CODEBASE_NAME)_$(tasks.get-version.results.IS_TAG)" - - name: KANIKO_CACHE_REPO - value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/kaniko-cache" - workspaces: - - name: source - workspace: shared-workspace -{{- end }} - -{{- if or (eq .Values.global.dockerRegistry.type "harbor") (eq .Values.global.dockerRegistry.type "dockerhub") }} - name: kaniko-build taskRef: kind: Task @@ -425,8 +395,9 @@ value: "$(params.CODEBASE_NAME)_$(tasks.get-version.results.IS_TAG)" - name: KANIKO_CACHE_REPO value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/kaniko-cache" + - name: REPO_NAME + value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/$(params.CODEBASE_NAME)" workspaces: - name: source workspace: shared-workspace -{{- end }} {{- end -}} diff --git a/charts/pipelines-library/templates/pipelines/_common_go.yaml b/charts/pipelines-library/templates/pipelines/_common_go.yaml index 491c99ed..98038d63 100644 --- a/charts/pipelines-library/templates/pipelines/_common_go.yaml +++ b/charts/pipelines-library/templates/pipelines/_common_go.yaml @@ -64,36 +64,6 @@ {{- end -}} {{- define "build-pipeline-golang-image-build-push-common" -}} -{{- if eq .Values.global.dockerRegistry.type "ecr" }} -- name: create-ecr-repository - taskRef: - kind: Task - name: create-ecr-repository - runAfter: - - build - params: - - name: REPO_NAME - value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/$(params.CODEBASE_NAME)" - -- name: kaniko-build - taskRef: - kind: Task - name: kaniko - runAfter: - - create-ecr-repository - params: - - name: IMAGE - value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/$(params.CODEBASE_NAME):$(tasks.get-version.results.IS_TAG)" - - name: IMAGE_TAR - value: "$(params.CODEBASE_NAME)_$(tasks.get-version.results.IS_TAG)" - - name: KANIKO_CACHE_REPO - value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/kaniko-cache" - workspaces: - - name: source - workspace: shared-workspace -{{- end }} - -{{- if or (eq .Values.global.dockerRegistry.type "harbor") (eq .Values.global.dockerRegistry.type "dockerhub") }} - name: kaniko-build taskRef: kind: Task @@ -107,10 +77,11 @@ value: "$(params.CODEBASE_NAME)_$(tasks.get-version.results.IS_TAG)" - name: KANIKO_CACHE_REPO value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/kaniko-cache" + - name: REPO_NAME + value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/$(params.CODEBASE_NAME)" workspaces: - name: source workspace: shared-workspace -{{- end }} {{- end -}} {{- define "golang-review-common" -}} diff --git a/charts/pipelines-library/templates/pipelines/_common_java_gradle.yaml b/charts/pipelines-library/templates/pipelines/_common_java_gradle.yaml index b065a5a7..ffc50095 100644 --- a/charts/pipelines-library/templates/pipelines/_common_java_gradle.yaml +++ b/charts/pipelines-library/templates/pipelines/_common_java_gradle.yaml @@ -191,36 +191,6 @@ {{- end -}} {{- define "build-pipeline-java-gradle-image-build-push-common" -}} -{{- if eq .Values.global.dockerRegistry.type "ecr" }} -- name: create-ecr-repository - taskRef: - kind: Task - name: create-ecr-repository - runAfter: - - push - params: - - name: REPO_NAME - value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/$(params.CODEBASE_NAME)" - -- name: kaniko-build - taskRef: - kind: Task - name: kaniko - runAfter: - - create-ecr-repository - params: - - name: IMAGE - value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/$(params.CODEBASE_NAME):$(tasks.get-version.results.IS_TAG)" - - name: IMAGE_TAR - value: "$(params.CODEBASE_NAME)_$(tasks.get-version.results.IS_TAG)" - - name: KANIKO_CACHE_REPO - value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/kaniko-cache" - workspaces: - - name: source - workspace: shared-workspace -{{- end }} - -{{- if or (eq .Values.global.dockerRegistry.type "harbor") (eq .Values.global.dockerRegistry.type "dockerhub") }} - name: kaniko-build taskRef: kind: Task @@ -234,8 +204,9 @@ value: "$(params.CODEBASE_NAME)_$(tasks.get-version.results.IS_TAG)" - name: KANIKO_CACHE_REPO value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/kaniko-cache" + - name: REPO_NAME + value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/$(params.CODEBASE_NAME)" workspaces: - name: source workspace: shared-workspace -{{- end }} {{- end -}} diff --git a/charts/pipelines-library/templates/pipelines/_common_java_maven.yaml b/charts/pipelines-library/templates/pipelines/_common_java_maven.yaml index cdcbfa70..87eff4c2 100644 --- a/charts/pipelines-library/templates/pipelines/_common_java_maven.yaml +++ b/charts/pipelines-library/templates/pipelines/_common_java_maven.yaml @@ -259,46 +259,13 @@ {{- end -}} {{- define "build-pipeline-java-maven-image-build-push-common" -}} -{{- if eq .Values.global.dockerRegistry.type "ecr" }} -- name: create-ecr-repository - taskRef: - kind: Task - name: create-ecr-repository - runAfter: - - push - params: - - name: REPO_NAME - value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/$(params.CODEBASE_NAME)" - - name: kaniko-build taskRef: kind: Task name: kaniko runAfter: - get-maven-module - - create-ecr-repository - params: - - name: IMAGE - value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/$(params.CODEBASE_NAME):$(tasks.get-version.results.IS_TAG)" - - name: IMAGE_TAR - value: "$(params.CODEBASE_NAME)_$(tasks.get-version.results.IS_TAG)" - - name: KANIKO_CACHE_REPO - value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/kaniko-cache" - - name: CONTEXT - value: "$(tasks.get-maven-module.results.DEPLOYABLE_MODULE_DIR)" - workspaces: - - name: source - workspace: shared-workspace -{{- end }} - -{{- if or (eq .Values.global.dockerRegistry.type "harbor") (eq .Values.global.dockerRegistry.type "dockerhub") }} -- name: kaniko-build - taskRef: - kind: Task - name: kaniko - runAfter: - push - - get-maven-module params: - name: IMAGE value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/$(params.CODEBASE_NAME):$(tasks.get-version.results.IS_TAG)" @@ -308,8 +275,9 @@ value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/kaniko-cache" - name: CONTEXT value: "$(tasks.get-maven-module.results.DEPLOYABLE_MODULE_DIR)" + - name: REPO_NAME + value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/$(params.CODEBASE_NAME)" workspaces: - name: source workspace: shared-workspace -{{- end }} {{- end -}} diff --git a/charts/pipelines-library/templates/pipelines/_common_js_npm.yaml b/charts/pipelines-library/templates/pipelines/_common_js_npm.yaml index b220eb47..f04ee5e1 100644 --- a/charts/pipelines-library/templates/pipelines/_common_js_npm.yaml +++ b/charts/pipelines-library/templates/pipelines/_common_js_npm.yaml @@ -239,36 +239,6 @@ {{- end -}} {{- define "build-pipeline-js-image-build-push-common" -}} -{{- if eq .Values.global.dockerRegistry.type "ecr" }} -- name: create-ecr-repository - taskRef: - kind: Task - name: create-ecr-repository - runAfter: - - push - params: - - name: REPO_NAME - value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/$(params.CODEBASE_NAME)" - -- name: kaniko-build - taskRef: - kind: Task - name: kaniko - runAfter: - - create-ecr-repository - params: - - name: IMAGE - value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/$(params.CODEBASE_NAME):$(tasks.get-version.results.IS_TAG)" - - name: IMAGE_TAR - value: "$(params.CODEBASE_NAME)_$(tasks.get-version.results.IS_TAG)" - - name: KANIKO_CACHE_REPO - value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/kaniko-cache" - workspaces: - - name: source - workspace: shared-workspace -{{- end }} - -{{- if or (eq .Values.global.dockerRegistry.type "harbor") (eq .Values.global.dockerRegistry.type "dockerhub") }} - name: kaniko-build taskRef: kind: Task @@ -285,40 +255,9 @@ workspaces: - name: source workspace: shared-workspace -{{- end }} {{- end -}} {{- define "build-pipeline-antora-image-build-push-common" -}} -{{- if eq .Values.global.dockerRegistry.type "ecr" }} -- name: create-ecr-repository - taskRef: - kind: Task - name: create-ecr-repository - runAfter: - - build - params: - - name: REPO_NAME - value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/$(params.CODEBASE_NAME)" - -- name: kaniko-build - taskRef: - kind: Task - name: kaniko - runAfter: - - create-ecr-repository - params: - - name: IMAGE - value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/$(params.CODEBASE_NAME):$(tasks.get-version.results.IS_TAG)" - - name: IMAGE_TAR - value: "$(params.CODEBASE_NAME)_$(tasks.get-version.results.IS_TAG)" - - name: KANIKO_CACHE_REPO - value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/kaniko-cache" - workspaces: - - name: source - workspace: shared-workspace -{{- end }} - -{{- if or (eq .Values.global.dockerRegistry.type "harbor") (eq .Values.global.dockerRegistry.type "dockerhub") }} - name: kaniko-build taskRef: kind: Task @@ -332,8 +271,9 @@ value: "$(params.CODEBASE_NAME)_$(tasks.get-version.results.IS_TAG)" - name: KANIKO_CACHE_REPO value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/kaniko-cache" + - name: REPO_NAME + value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/$(params.CODEBASE_NAME)" workspaces: - name: source workspace: shared-workspace -{{- end }} {{- end -}} diff --git a/charts/pipelines-library/templates/pipelines/_common_python.yaml b/charts/pipelines-library/templates/pipelines/_common_python.yaml index 7c13b9c9..e8871aea 100644 --- a/charts/pipelines-library/templates/pipelines/_common_python.yaml +++ b/charts/pipelines-library/templates/pipelines/_common_python.yaml @@ -162,36 +162,6 @@ {{- end -}} {{- define "build-pipeline-python-image-build-push-common" -}} -{{- if eq .Values.global.dockerRegistry.type "ecr" }} -- name: create-ecr-repository - taskRef: - kind: Task - name: create-ecr-repository - runAfter: - - push - params: - - name: REPO_NAME - value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/$(params.CODEBASE_NAME)" - -- name: kaniko-build - taskRef: - kind: Task - name: kaniko - runAfter: - - create-ecr-repository - params: - - name: IMAGE - value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/$(params.CODEBASE_NAME):$(tasks.get-version.results.IS_TAG)" - - name: IMAGE_TAR - value: "$(params.CODEBASE_NAME)_$(tasks.get-version.results.IS_TAG)" - - name: KANIKO_CACHE_REPO - value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/kaniko-cache" - workspaces: - - name: source - workspace: shared-workspace -{{- end }} - -{{- if or (eq .Values.global.dockerRegistry.type "harbor") (eq .Values.global.dockerRegistry.type "dockerhub") }} - name: kaniko-build taskRef: kind: Task @@ -205,8 +175,9 @@ value: "$(params.CODEBASE_NAME)_$(tasks.get-version.results.IS_TAG)" - name: KANIKO_CACHE_REPO value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/kaniko-cache" + - name: REPO_NAME + value: "$(tasks.init-values.results.DOCKER_REGISTRY_HOST)/$(params.CODEBASE_NAME)" workspaces: - name: source workspace: shared-workspace -{{- end }} {{- end -}} diff --git a/charts/pipelines-library/templates/tasks/kaniko-eks.yaml b/charts/pipelines-library/templates/tasks/kaniko-eks.yaml index ebcb4ae1..67812f5d 100644 --- a/charts/pipelines-library/templates/tasks/kaniko-eks.yaml +++ b/charts/pipelines-library/templates/tasks/kaniko-eks.yaml @@ -35,6 +35,8 @@ spec: - name: KANIKO_CACHE_REPO description: The repo where Kaniko stores cached image layers default: "" + - name: REPO_NAME + description: "The name of the ecr repository where we are going to push the image" workspaces: - name: source description: Holds the context and Dockerfile @@ -60,6 +62,32 @@ spec: - name: IMAGE_URL description: URL of the image just built. steps: + - name: init-repository + image: amazon/aws-cli:2.7.35 + env: + - name: REPO_NAME + value: "$(params.REPO_NAME)" + - name: AWS_DEFAULT_REGION + valueFrom: + configMapKeyRef: + name: "edp-config" + key: 'aws_region' + - name: CONTAINER_REGISTRY_TYPE + valueFrom: + configMapKeyRef: + name: edp-config + key: container_registry_type + command: ["/bin/sh"] + args: + - "-c" + - | + if [[ "$CONTAINER_REGISTRY_TYPE" == "ecr" ]]; then + ECR_REPO_NAME=$(echo "${REPO_NAME}" | cut -d'/' -f2-) + aws ecr describe-repositories --repository-names "$ECR_REPO_NAME" || aws ecr create-repository --repository-name "$ECR_REPO_NAME"; + else + echo 'Registry not ECR, stage skipped'; + fi + - name: build-and-push workingDir: $(workspaces.source.path) image: $(params.BUILDER_IMAGE) diff --git a/charts/pipelines-library/tests/test_container_pipelines.py b/charts/pipelines-library/tests/test_container_pipelines.py index 89c787aa..bab357c9 100644 --- a/charts/pipelines-library/tests/test_container_pipelines.py +++ b/charts/pipelines-library/tests/test_container_pipelines.py @@ -1,208 +1,11 @@ from .helpers import helm_template -def test_container_pipelines_gerrit(): - config = """ -global: - dnsWildCard: "example.com" - gitProvider: gerrit - dockerRegistry: - type: "ecr" - """ - - r = helm_template(config) - - assert "gerrit-kaniko-docker-lib-review" in r["pipeline"] - assert "gerrit-kaniko-docker-lib-build-default" in r["pipeline"] - assert "gerrit-kaniko-docker-lib-build-edp" in r["pipeline"] - - # ensure pipelines have proper steps - for buildtool in ['kaniko']: - for framework in ['docker']: - - gerrit_review_pipeline = f"gerrit-{buildtool}-{framework}-lib-review" - gerrit_build_pipeline_def = f"gerrit-{buildtool}-{framework}-lib-build-default" - gerrit_build_pipeline_edp = f"gerrit-{buildtool}-{framework}-lib-build-edp" - - rt = r["pipeline"][gerrit_review_pipeline]["spec"]["tasks"] - assert "fetch-repository" in rt[0]["name"] - assert "gerrit-notify" in rt[1]["name"] - assert "init-values" in rt[2]["name"] - assert "fetch-target-branch" in rt[3]["name"] - assert "dockerfile-lint" in rt[4]["name"] - assert "dockerbuild-verify" in rt[5]["name"] - assert "gerrit-vote-success" in r["pipeline"][gerrit_review_pipeline]["spec"]["finally"][0]["name"] - assert "gerrit-vote-failure" in r["pipeline"][gerrit_review_pipeline]["spec"]["finally"][1]["name"] - - # build with default versioning - btd = r["pipeline"][gerrit_build_pipeline_def]["spec"]["tasks"] - assert "fetch-repository" in btd[0]["name"] - assert "gerrit-notify" in btd[1]["name"] - assert "init-values" in btd[2]["name"] - assert "get-version" in btd[3]["name"] - assert f"get-version-default" == btd[3]["taskRef"]["name"] - assert "sast" in btd[4]["name"] - assert "dockerfile-lint" in btd[5]["name"] - assert "create-ecr-repository" in btd[6]["name"] - # ensure we have default versioning - assert "kaniko-build" in btd[7]["name"] - assert buildtool == btd[7]["taskRef"]["name"] - assert "git-tag" in btd[8]["name"] - assert "update-cbis" in btd[9]["name"] - assert "push-to-jira" in r["pipeline"][gerrit_build_pipeline_def]["spec"]["finally"][0]["name"] - - # build with edp versioning - btedp = r["pipeline"][gerrit_build_pipeline_edp]["spec"]["tasks"] - assert "fetch-repository" in btedp[0]["name"] - assert "gerrit-notify" in btedp[1]["name"] - assert "init-values" in btedp[2]["name"] - assert "get-version" in btedp[3]["name"] - assert "get-version-edp" == btedp[3]["taskRef"]["name"] - assert "sast" in btedp[4]["name"] - assert "dockerfile-lint" in btedp[5]["name"] - assert "create-ecr-repository" in btedp[6]["name"] - assert "kaniko-build" in btedp[7]["name"] - assert "git-tag" in btedp[8]["name"] - assert "update-cbis" in btedp[9]["name"] - assert "update-cbb" in r["pipeline"][gerrit_build_pipeline_edp]["spec"]["finally"][0]["name"] - assert "push-to-jira" in r["pipeline"][gerrit_build_pipeline_edp]["spec"]["finally"][1]["name"] - - -def test_container_pipelines_github(): - config = """ -global: - gitProvider: github - dockerRegistry: - type: "ecr" - """ - - r = helm_template(config) - vcs = "github" - - # ensure pipelines have proper steps - for buildtool in ['kaniko']: - for framework in ['docker']: - - github_review_pipeline = f"{vcs}-{buildtool}-{framework}-lib-review" - github_build_pipeline_def = f"{vcs}-{buildtool}-{framework}-lib-build-default" - github_build_pipeline_edp = f"{vcs}-{buildtool}-{framework}-lib-build-edp" - - assert github_review_pipeline in r["pipeline"] - assert github_build_pipeline_def in r["pipeline"] - assert github_build_pipeline_edp in r["pipeline"] - - rt = r["pipeline"][github_review_pipeline]["spec"]["tasks"] - assert "github-set-pending-status" in rt[0]["name"] - assert "fetch-repository" in rt[1]["name"] - assert "dockerfile-lint" in rt[2]["name"] - assert "dockerbuild-verify" in rt[3]["name"] - - assert "github-set-success-status" in r["pipeline"][github_review_pipeline]["spec"]["finally"][0]["name"] - assert "github-set-failure-status" in r["pipeline"][github_review_pipeline]["spec"]["finally"][1]["name"] - - # build with default versioning - btd = r["pipeline"][github_build_pipeline_def]["spec"]["tasks"] - assert "fetch-repository" in btd[0]["name"] - assert "init-values" in btd[1]["name"] - assert "get-version" in btd[2]["name"] - assert f"get-version-default" == btd[2]["taskRef"]["name"] - assert "sast" in btd[3]["name"] - assert "dockerfile-lint" in btd[4]["name"] - assert "create-ecr-repository" in btd[5]["name"] - # ensure we have default versioning - assert "kaniko-build" in btd[6]["name"] - assert buildtool == btd[6]["taskRef"]["name"] - assert "git-tag" in btd[7]["name"] - assert "update-cbis" in btd[8]["name"] - assert "push-to-jira" in r["pipeline"][github_build_pipeline_def]["spec"]["finally"][0]["name"] - - # build with edp versioning - btedp = r["pipeline"][github_build_pipeline_edp]["spec"]["tasks"] - assert "fetch-repository" in btedp[0]["name"] - assert "init-values" in btedp[1]["name"] - assert "get-version" in btedp[2]["name"] - assert "get-version-edp" == btedp[2]["taskRef"]["name"] - assert "sast" in btedp[3]["name"] - assert "dockerfile-lint" in btedp[4]["name"] - assert "create-ecr-repository" in btedp[5]["name"] - assert "kaniko-build" in btedp[6]["name"] - assert "git-tag" in btedp[7]["name"] - assert "update-cbis" in btedp[8]["name"] - assert "update-cbb" in r["pipeline"][github_build_pipeline_edp]["spec"]["finally"][0]["name"] - assert "push-to-jira" in r["pipeline"][github_build_pipeline_edp]["spec"]["finally"][1]["name"] - - -def test_container_pipelines_gitlab(): - config = """ -global: - gitProvider: gitlab - dockerRegistry: - type: "ecr" - """ - - r = helm_template(config) - vcs = "gitlab" - - # ensure pipelines have proper steps - for buildtool in ['kaniko']: - for framework in ['docker']: - - gitlab_review_pipeline = f"{vcs}-{buildtool}-{framework}-lib-review" - gitlab_build_pipeline_def = f"{vcs}-{buildtool}-{framework}-lib-build-default" - gitlab_build_pipeline_edp = f"{vcs}-{buildtool}-{framework}-lib-build-edp" - - assert gitlab_review_pipeline in r["pipeline"] - assert gitlab_build_pipeline_def in r["pipeline"] - assert gitlab_build_pipeline_edp in r["pipeline"] - - rt = r["pipeline"][gitlab_review_pipeline]["spec"]["tasks"] - assert "report-pipeline-start-to-gitlab" in rt[0]["name"] - assert "fetch-repository" in rt[1]["name"] - assert "dockerfile-lint" in rt[2]["name"] - assert "dockerbuild-verify" in rt[3]["name"] - - assert "gitlab-set-success-status" in r["pipeline"][gitlab_review_pipeline]["spec"]["finally"][0]["name"] - assert "gitlab-set-failure-status" in r["pipeline"][gitlab_review_pipeline]["spec"]["finally"][1]["name"] - - # build with default versioning - btd = r["pipeline"][gitlab_build_pipeline_def]["spec"]["tasks"] - assert "fetch-repository" in btd[0]["name"] - assert "init-values" in btd[1]["name"] - assert "get-version" in btd[2]["name"] - assert f"get-version-default" == btd[2]["taskRef"]["name"] - assert "sast" in btd[3]["name"] - assert "dockerfile-lint" in btd[4]["name"] - assert "create-ecr-repository" in btd[5]["name"] - # ensure we have default versioning - assert "kaniko-build" in btd[6]["name"] - assert buildtool == btd[6]["taskRef"]["name"] - assert "git-tag" in btd[7]["name"] - assert "update-cbis" in btd[8]["name"] - assert "push-to-jira" in r["pipeline"][gitlab_build_pipeline_def]["spec"]["finally"][0]["name"] - - # build with edp versioning - btedp = r["pipeline"][gitlab_build_pipeline_edp]["spec"]["tasks"] - assert "fetch-repository" in btedp[0]["name"] - assert "init-values" in btedp[1]["name"] - assert "get-version" in btedp[2]["name"] - assert "get-version-edp" == btedp[2]["taskRef"]["name"] - assert "sast" in btedp[3]["name"] - assert "dockerfile-lint" in btedp[4]["name"] - assert "create-ecr-repository" in btedp[5]["name"] - assert "kaniko-build" in btedp[6]["name"] - assert "git-tag" in btedp[7]["name"] - assert "update-cbis" in btedp[8]["name"] - assert "update-cbb" in r["pipeline"][gitlab_build_pipeline_edp]["spec"]["finally"][0]["name"] - assert "push-to-jira" in r["pipeline"][gitlab_build_pipeline_edp]["spec"]["finally"][1]["name"] - - def test_container_pipelines_harbor_gerrit(): config = """ global: dnsWildCard: "example.com" gitProvider: gerrit - dockerRegistry: - type: "harbor" """ r = helm_template(config) @@ -265,8 +68,6 @@ def test_container_pipelines_harbor_github(): config = """ global: gitProvider: github - dockerRegistry: - type: "harbor" """ r = helm_template(config) @@ -327,8 +128,6 @@ def test_container_pipelines_harbor_gitlab(): config = """ global: gitProvider: gitlab - dockerRegistry: - type: "harbor" """ r = helm_template(config) diff --git a/charts/pipelines-library/tests/test_dotnet_pipelines.py b/charts/pipelines-library/tests/test_dotnet_pipelines.py index 32775b4d..5e25230d 100644 --- a/charts/pipelines-library/tests/test_dotnet_pipelines.py +++ b/charts/pipelines-library/tests/test_dotnet_pipelines.py @@ -1,340 +1,10 @@ from .helpers import helm_template -def test_dotnet_pipelines_gerrit(): - config = """ -global: - gitProvider: gerrit - dockerRegistry: - type: "ecr" - """ - - ht = helm_template(config) - - buildtool = "dotnet" - - for framework in ['dotnet-3.1', 'dotnet-6.0']: - for cbtype in ['app', 'lib']: - - review = f"gerrit-{buildtool}-{framework}-{cbtype}-review" - build_default = f"gerrit-{buildtool}-{framework}-{cbtype}-build-default" - build_edp = f"gerrit-{buildtool}-{framework}-{cbtype}-build-edp" - - assert review in ht["pipeline"] - assert build_default in ht["pipeline"] - assert build_edp in ht["pipeline"] - - r = ht["pipeline"][review]["spec"]["tasks"] - if cbtype == "app": - assert "fetch-repository" in r[0]["name"] - assert "gerrit-notify" in r[1]["name"] - assert "init-values" in r[2]["name"] - assert "helm-docs" in r[3]["name"] - assert "dotnet-build" in r[4]["name"] - assert "test" in r[5]["name"] - assert "fetch-target-branch" in r[6]["name"] - assert "sonar-prepare-files" in r[7]["name"] - assert "sonar-prepare-files-dotnet" == r[7]["taskRef"]["name"] - assert "sonar" in r[8]["name"] - assert "dotnet-publish" in r[9]["name"] - assert "dockerfile-lint" in r[10]["name"] - assert "dockerbuild-verify" in r[11]["name"] - assert "helm-lint" in r[12]["name"] - if cbtype == "lib": - assert "fetch-repository" in r[0]["name"] - assert "gerrit-notify" in r[1]["name"] - assert "init-values" in r[2]["name"] - assert "dotnet-build" in r[3]["name"] - assert "test" in r[4]["name"] - assert "fetch-target-branch" in r[5]["name"] - assert "sonar-prepare-files" in r[6]["name"] - assert "sonar-prepare-files-dotnet" == r[6]["taskRef"]["name"] - assert "sonar" in r[7]["name"] - - assert "gerrit-vote-success" in ht["pipeline"][review]["spec"]["finally"][0]["name"] - assert "gerrit-vote-failure" in ht["pipeline"][review]["spec"]["finally"][1]["name"] - - # build with default versioning - bd = ht["pipeline"][build_default]["spec"]["tasks"] - assert "fetch-repository" in bd[0]["name"] - assert "gerrit-notify" in bd[1]["name"] - assert "init-values" in bd[2]["name"] - assert "get-version" in bd[3]["name"] - assert f"get-version-default" == bd[3]["taskRef"]["name"] - assert "sonar-cleanup" in bd[4]["name"] - assert "sast" in bd[5]["name"] - assert "dotnet-build" in bd[6]["name"] - assert "test" in bd[7]["name"] - assert buildtool == bd[7]["taskRef"]["name"] - assert "sonar" in bd[8]["name"] - assert buildtool == bd[8]["taskRef"]["name"] - assert "get-nexus-repository-url" in bd[9]["name"] - assert "get-nexus-repository-url" == bd[9]["taskRef"]["name"] - assert "get-nuget-token" in bd[10]["name"] - assert "push" in bd[11]["name"] - assert buildtool == bd[11]["taskRef"]["name"] - if cbtype == "app": - assert "dotnet-publish" in bd[12]["name"] - assert "create-ecr-repository" in bd[13]["name"] - assert "kaniko-build" in bd[14]["name"] - assert "git-tag" in bd[15]["name"] - assert "update-cbis" in bd[16]["name"] - if cbtype == "lib": - assert "git-tag" in bd[12]["name"] - assert "push-to-jira" in ht["pipeline"][build_default]["spec"]["finally"][0]["name"] - - # build with edp versioning - bedp = ht["pipeline"][build_edp]["spec"]["tasks"] - assert "fetch-repository" in bedp[0]["name"] - assert "gerrit-notify" in bedp[1]["name"] - assert "init-values" in bedp[2]["name"] - assert "get-version" in bedp[3]["name"] - assert "get-version-edp" == bedp[3]["taskRef"]["name"] - assert "update-build-number" in bedp[4]["taskRef"]["name"] - assert f"update-build-number-csharp" == bedp[4]["taskRef"]["name"] - assert "sonar-cleanup" in bedp[5]["name"] - assert "sast" in bedp[6]["name"] - assert "dotnet-build" in bedp[7]["name"] - assert buildtool == bedp[7]["taskRef"]["name"] - assert "test" in bedp[8]["name"] - assert buildtool == bedp[8]["taskRef"]["name"] - assert "sonar" in bedp[9]["name"] - assert buildtool == bedp[9]["taskRef"]["name"] - assert "get-nexus-repository-url" in bedp[10]["name"] - assert "get-nexus-repository-url" == bedp[10]["taskRef"]["name"] - assert "get-nuget-token" in bedp[11]["name"] - assert "push" in bedp[12]["name"] - assert buildtool == bedp[12]["taskRef"]["name"] - if cbtype == "app": - assert "dotnet-publish" in bedp[13]["name"] - assert "create-ecr-repository" in bedp[14]["name"] - assert "kaniko-build" in bedp[15]["name"] - assert "git-tag" in bedp[16]["name"] - assert "update-cbis" in bedp[17]["name"] - if cbtype == "lib": - assert "git-tag" in bedp[13]["name"] - assert "update-cbb" in ht["pipeline"][build_edp]["spec"]["finally"][0]["name"] - assert "push-to-jira" in ht["pipeline"][build_edp]["spec"]["finally"][1]["name"] - - -def test_dotnet_pipelines_gitlab(): - config = """ -global: - gitProvider: gitlab - dockerRegistry: - type: "ecr" - """ - - ht = helm_template(config) - - buildtool = "dotnet" - - for framework in ['dotnet-3.1', 'dotnet-6.0']: - for cbtype in ['app', 'lib']: - - review = f"gitlab-{buildtool}-{framework}-{cbtype}-review" - build_default = f"gitlab-{buildtool}-{framework}-{cbtype}-build-default" - build_edp = f"gitlab-{buildtool}-{framework}-{cbtype}-build-edp" - - assert review in ht["pipeline"] - assert build_default in ht["pipeline"] - assert build_edp in ht["pipeline"] - - r = ht["pipeline"][review]["spec"]["tasks"] - if cbtype == "lib": - assert "report-pipeline-start-to-gitlab" in r[0]["name"] - assert "fetch-repository" in r[1]["name"] - assert "init-values" in r[2]["name"] - assert "dotnet-build" in r[3]["name"] - assert "test" in r[4]["name"] - assert "sonar" in r[5]["name"] - if cbtype == "app": - assert "report-pipeline-start-to-gitlab" in r[0]["name"] - assert "fetch-repository" in r[1]["name"] - assert "init-values" in r[2]["name"] - assert "helm-docs" in r[3]["name"] - assert "dotnet-build" in r[4]["name"] - assert "test" in r[5]["name"] - assert "sonar" in r[6]["name"] - assert "dotnet-publish" in r[7]["name"] - assert "dockerfile-lint" in r[8]["name"] - assert "dockerbuild-verify" in r[9]["name"] - assert "helm-lint" in r[10]["name"] - - assert "gitlab-set-success-status" in ht["pipeline"][review]["spec"]["finally"][0]["name"] - assert "gitlab-set-failure-status" in ht["pipeline"][review]["spec"]["finally"][1]["name"] - - # build with default versioning - bd = ht["pipeline"][build_default]["spec"]["tasks"] - assert "fetch-repository" in bd[0]["name"] - assert "init-values" in bd[1]["name"] - assert "get-version" in bd[2]["name"] - assert f"get-version-default" == bd[2]["taskRef"]["name"] - assert "sast" in bd[3]["name"] - assert "dotnet-build" in bd[4]["name"] - assert "test" in bd[5]["name"] - assert buildtool == bd[5]["taskRef"]["name"] - assert "sonar" in bd[6]["name"] - assert buildtool == bd[6]["taskRef"]["name"] - assert "get-nexus-repository-url" in bd[7]["name"] - assert "get-nexus-repository-url" == bd[7]["taskRef"]["name"] - assert "get-nuget-token" in bd[8]["name"] - assert "push" in bd[9]["name"] - assert buildtool == bd[9]["taskRef"]["name"] - if cbtype == "app": - assert "dotnet-publish" in bd[10]["name"] - assert "create-ecr-repository" in bd[11]["name"] - assert "kaniko-build" in bd[12]["name"] - assert "git-tag" in bd[13]["name"] - assert "update-cbis" in bd[14]["name"] - if cbtype == "lib": - assert "git-tag" in bd[10]["name"] - assert "push-to-jira" in ht["pipeline"][build_default]["spec"]["finally"][0]["name"] - - # build with edp versioning - bedp = ht["pipeline"][build_edp]["spec"]["tasks"] - assert "fetch-repository" in bedp[0]["name"] - assert "init-values" in bedp[1]["name"] - assert "get-version" in bedp[2]["name"] - assert "get-version-edp" == bedp[2]["taskRef"]["name"] - assert "update-build-number" in bedp[3]["taskRef"]["name"] - assert f"update-build-number-csharp" == bedp[3]["taskRef"]["name"] - assert "sast" in bedp[4]["name"] - assert "dotnet-build" in bedp[5]["name"] - assert buildtool == bedp[5]["taskRef"]["name"] - assert "test" in bedp[6]["name"] - assert buildtool == bedp[6]["taskRef"]["name"] - assert "sonar" in bedp[7]["name"] - assert buildtool == bedp[7]["taskRef"]["name"] - assert "get-nexus-repository-url" in bedp[8]["name"] - assert "get-nexus-repository-url" == bedp[8]["taskRef"]["name"] - assert "get-nuget-token" in bedp[9]["name"] - assert "push" in bedp[10]["name"] - assert buildtool == bedp[10]["taskRef"]["name"] - if cbtype == "app": - assert "dotnet-publish" in bedp[11]["name"] - assert "create-ecr-repository" in bedp[12]["name"] - assert "kaniko-build" in bedp[13]["name"] - assert "git-tag" in bedp[14]["name"] - assert "update-cbis" in bedp[15]["name"] - if cbtype == "lib": - assert "git-tag" in bedp[11]["name"] - assert "update-cbb" in ht["pipeline"][build_edp]["spec"]["finally"][0]["name"] - assert "push-to-jira" in ht["pipeline"][build_edp]["spec"]["finally"][1]["name"] - - -def test_dotnet_pipelines_github(): - config = """ -global: - gitProvider: github - dockerRegistry: - type: "ecr" - """ - - ht = helm_template(config) - - buildtool = "dotnet" - - for framework in ['dotnet-3.1', 'dotnet-6.0']: - for cbtype in ['app', 'lib']: - - review = f"github-{buildtool}-{framework}-{cbtype}-review" - build_default = f"github-{buildtool}-{framework}-{cbtype}-build-default" - build_edp = f"github-{buildtool}-{framework}-{cbtype}-build-edp" - - assert review in ht["pipeline"] - assert build_default in ht["pipeline"] - assert build_edp in ht["pipeline"] - - r = ht["pipeline"][review]["spec"]["tasks"] - if cbtype == "lib": - assert "github-set-pending-status" in r[0]["name"] - assert "fetch-repository" in r[1]["name"] - assert "init-values" in r[2]["name"] - assert "dotnet-build" in r[3]["name"] - assert "test" in r[4]["name"] - assert "sonar" in r[5]["name"] - if cbtype == "app": - assert "github-set-pending-status" in r[0]["name"] - assert "fetch-repository" in r[1]["name"] - assert "init-values" in r[2]["name"] - assert "helm-docs" in r[3]["name"] - assert "dotnet-build" in r[4]["name"] - assert "test" in r[5]["name"] - assert "sonar" in r[6]["name"] - assert "dotnet-publish" in r[7]["name"] - assert "dockerfile-lint" in r[8]["name"] - assert "dockerbuild-verify" in r[9]["name"] - assert "helm-lint" in r[10]["name"] - - assert "github-set-success-status" in ht["pipeline"][review]["spec"]["finally"][0]["name"] - assert "github-set-failure-status" in ht["pipeline"][review]["spec"]["finally"][1]["name"] - - # build with default versioning - bd = ht["pipeline"][build_default]["spec"]["tasks"] - assert "fetch-repository" in bd[0]["name"] - assert "init-values" in bd[1]["name"] - assert "get-version" in bd[2]["name"] - assert f"get-version-default" == bd[2]["taskRef"]["name"] - assert "sast" in bd[3]["name"] - assert "dotnet-build" in bd[4]["name"] - assert "test" in bd[5]["name"] - assert buildtool == bd[5]["taskRef"]["name"] - assert "sonar" in bd[6]["name"] - assert buildtool == bd[6]["taskRef"]["name"] - assert "get-nexus-repository-url" in bd[7]["name"] - assert "get-nexus-repository-url" == bd[7]["taskRef"]["name"] - assert "get-nuget-token" in bd[8]["name"] - assert "push" in bd[9]["name"] - assert buildtool == bd[9]["taskRef"]["name"] - if cbtype == "app": - assert "dotnet-publish" in bd[10]["name"] - assert "create-ecr-repository" in bd[11]["name"] - assert "kaniko-build" in bd[12]["name"] - assert "git-tag" in bd[13]["name"] - assert "update-cbis" in bd[14]["name"] - if cbtype == "lib": - assert "git-tag" in bd[10]["name"] - assert "push-to-jira" in ht["pipeline"][build_default]["spec"]["finally"][0]["name"] - - # build with edp versioning - bedp = ht["pipeline"][build_edp]["spec"]["tasks"] - assert "fetch-repository" in bedp[0]["name"] - assert "init-values" in bedp[1]["name"] - assert "get-version" in bedp[2]["name"] - assert "get-version-edp" == bedp[2]["taskRef"]["name"] - assert "update-build-number" in bedp[3]["taskRef"]["name"] - assert f"update-build-number-csharp" == bedp[3]["taskRef"]["name"] - assert "sast" in bedp[4]["name"] - assert "dotnet-build" in bedp[5]["name"] - assert buildtool == bedp[5]["taskRef"]["name"] - assert "test" in bedp[6]["name"] - assert buildtool == bedp[6]["taskRef"]["name"] - assert "sonar" in bedp[7]["name"] - assert buildtool == bedp[7]["taskRef"]["name"] - assert "get-nexus-repository-url" in bedp[8]["name"] - assert "get-nexus-repository-url" == bedp[8]["taskRef"]["name"] - assert "get-nuget-token" in bedp[9]["name"] - assert "push" in bedp[10]["name"] - assert buildtool == bedp[10]["taskRef"]["name"] - if cbtype == "app": - assert "dotnet-publish" in bedp[11]["name"] - assert "create-ecr-repository" in bedp[12]["name"] - assert "kaniko-build" in bedp[13]["name"] - assert "git-tag" in bedp[14]["name"] - assert "update-cbis" in bedp[15]["name"] - if cbtype == "lib": - assert "git-tag" in bedp[11]["name"] - assert "update-cbb" in ht["pipeline"][build_edp]["spec"]["finally"][0]["name"] - assert "push-to-jira" in ht["pipeline"][build_edp]["spec"]["finally"][1]["name"] - - def test_dotnet_pipelines_harbor_gerrit(): config = """ global: gitProvider: gerrit - dockerRegistry: - type: "harbor" """ ht = helm_template(config) @@ -447,8 +117,6 @@ def test_dotnet_pipelines_harbor_gitlab(): config = """ global: gitProvider: gitlab - dockerRegistry: - type: "harbor" """ ht = helm_template(config) @@ -551,8 +219,6 @@ def test_dotnet_pipelines_harbor_github(): config = """ global: gitProvider: github - dockerRegistry: - type: "harbor" """ ht = helm_template(config) diff --git a/charts/pipelines-library/tests/test_go_pipelines.py b/charts/pipelines-library/tests/test_go_pipelines.py index 22379857..1e009af7 100644 --- a/charts/pipelines-library/tests/test_go_pipelines.py +++ b/charts/pipelines-library/tests/test_go_pipelines.py @@ -1,252 +1,9 @@ from .helpers import helm_template - -def test_go_pipelines_gerrit(): - config = """ -global: - gitProvider: gerrit - dockerRegistry: - type: "ecr" - """ - - r = helm_template(config) - - # ensure pipelines have proper steps - for buildtool in ['go']: - for framework in ['beego', 'gin', 'operator-sdk']: - - assert f"gerrit-go-{framework}-app-review" in r["pipeline"] - assert f"gerrit-go-{framework}-app-build-default" in r["pipeline"] - assert f"gerrit-go-{framework}-app-build-edp" in r["pipeline"] - - gerrit_review_pipeline = f"gerrit-{buildtool}-{framework}-app-review" - gerrit_build_pipeline_def = f"gerrit-{buildtool}-{framework}-app-build-default" - gerrit_build_pipeline_edp = f"gerrit-{buildtool}-{framework}-app-build-edp" - - rt = r["pipeline"][gerrit_review_pipeline]["spec"]["tasks"] - assert "fetch-repository" in rt[0]["name"] - assert "gerrit-notify" in rt[1]["name"] - assert "init-values" in rt[2]["name"] - assert "helm-docs" in rt[3]["name"] - assert "build" in rt[4]["name"] - assert "test" in rt[5]["name"] - assert "fetch-target-branch" in rt[6]["name"] - assert "sonar-prepare-files" in rt[7]["name"] - assert "sonar-prepare-files-general" == rt[7]["taskRef"]["name"] - assert "sonar" in rt[8]["name"] - assert "dockerfile-lint" in rt[9]["name"] - assert "dockerbuild-verify" in rt[10]["name"] - assert "helm-lint" in rt[11]["name"] - assert "gerrit-vote-success" in r["pipeline"][gerrit_review_pipeline]["spec"]["finally"][0]["name"] - assert "gerrit-vote-failure" in r["pipeline"][gerrit_review_pipeline]["spec"]["finally"][1]["name"] - - # build with default versioning - btd = r["pipeline"][gerrit_build_pipeline_def]["spec"]["tasks"] - assert "fetch-repository" in btd[0]["name"] - assert "gerrit-notify" in btd[1]["name"] - assert "init-values" in btd[2]["name"] - assert "get-version" in btd[3]["name"] - # ensure we have default versioning - assert f"get-version-default" == btd[3]["taskRef"]["name"] - assert "sonar-cleanup" in btd[4]["name"] - assert "sast" in btd[5]["name"] - assert "test" in btd[6]["name"] - assert "golang" == btd[6]["taskRef"]["name"] - assert "sonar" in btd[7]["name"] - assert "sonarqube-scanner" == btd[7]["taskRef"]["name"] - assert "build" in btd[8]["name"] - assert "golang" == btd[8]["taskRef"]["name"] - assert "create-ecr-repository" in btd[9]["name"] - assert "kaniko-build" in btd[10]["name"] - assert "git-tag" in btd[11]["name"] - assert "update-cbis" in btd[12]["name"] - assert "push-to-jira" in r["pipeline"][gerrit_build_pipeline_def]["spec"]["finally"][0]["name"] - - # build with edp versioning - btedp = r["pipeline"][gerrit_build_pipeline_edp]["spec"]["tasks"] - assert "fetch-repository" in btedp[0]["name"] - assert "gerrit-notify" in btedp[1]["name"] - assert "init-values" in btedp[2]["name"] - assert "get-version" in btedp[3]["name"] - assert "get-version-edp" == btedp[3]["taskRef"]["name"] - assert "sonar-cleanup" in btedp[4]["name"] - assert "sast" in btedp[5]["name"] - assert "test" in btedp[6]["name"] - assert "golang" == btedp[6]["taskRef"]["name"] - assert "sonar" in btedp[7]["name"] - assert "sonarqube-scanner" == btedp[7]["taskRef"]["name"] - assert "build" in btedp[8]["name"] - assert "golang" == btedp[8]["taskRef"]["name"] - assert "create-ecr-repository" in btd[9]["name"] - assert "kaniko-build" in btedp[10]["name"] - assert "git-tag" in btedp[11]["name"] - assert "update-cbis" in btedp[12]["name"] - assert "update-cbb" in r["pipeline"][gerrit_build_pipeline_edp]["spec"]["finally"][0]["name"] - assert "push-to-jira" in r["pipeline"][gerrit_build_pipeline_edp]["spec"]["finally"][1]["name"] - - -def test_go_pipelines_github(): - config = """ -global: - gitProvider: github - dockerRegistry: - type: "ecr" - """ - - r = helm_template(config) - vcs = "github" - - # ensure pipelines have proper steps - for buildtool in ['go']: - for framework in ['beego', 'gin', 'operator-sdk']: - - github_review_pipeline = f"{vcs}-{buildtool}-{framework}-app-review" - github_build_pipeline_def = f"{vcs}-{buildtool}-{framework}-app-build-default" - github_build_pipeline_edp = f"{vcs}-{buildtool}-{framework}-app-build-edp" - - assert github_review_pipeline in r["pipeline"] - assert github_build_pipeline_def in r["pipeline"] - assert github_build_pipeline_edp in r["pipeline"] - - rt = r["pipeline"][github_review_pipeline]["spec"]["tasks"] - assert "github-set-pending-status" in rt[0]["name"] - assert "fetch-repository" in rt[1]["name"] - assert "init-values" in rt[2]["name"] - assert "helm-docs" in rt[3]["name"] - assert "build" in rt[4]["name"] - assert "test" in rt[5]["name"] - assert "sonar" in rt[6]["name"] - assert "dockerfile-lint" in rt[7]["name"] - assert "dockerbuild-verify" in rt[8]["name"] - assert "helm-lint" in rt[9]["name"] - assert "github-set-success-status" in r["pipeline"][github_review_pipeline]["spec"]["finally"][0]["name"] - assert "github-set-failure-status" in r["pipeline"][github_review_pipeline]["spec"]["finally"][1]["name"] - - # build with default versioning - btd = r["pipeline"][github_build_pipeline_def]["spec"]["tasks"] - assert "fetch-repository" in btd[0]["name"] - assert "init-values" in btd[1]["name"] - assert "get-version" in btd[2]["name"] - # ensure we have default versioning - assert f"get-version-default" == btd[2]["taskRef"]["name"] - assert "sast" in btd[3]["name"] - assert "test" in btd[4]["name"] - assert "golang" == btd[4]["taskRef"]["name"] - assert "sonar" in btd[5]["name"] - assert "sonarqube-scanner" == btd[5]["taskRef"]["name"] - assert "build" in btd[6]["name"] - assert "golang" == btd[6]["taskRef"]["name"] - assert "create-ecr-repository" in btd[7]["name"] - assert "kaniko-build" in btd[8]["name"] - assert "git-tag" in btd[9]["name"] - assert "update-cbis" in btd[10]["name"] - assert "push-to-jira" in r["pipeline"][github_build_pipeline_def]["spec"]["finally"][0]["name"] - - # build with edp versioning - btedp = r["pipeline"][github_build_pipeline_edp]["spec"]["tasks"] - assert "fetch-repository" in btedp[0]["name"] - assert "init-values" in btedp[1]["name"] - assert "get-version" in btedp[2]["name"] - assert "get-version-edp" == btedp[2]["taskRef"]["name"] - assert "sast" in btedp[3]["name"] - assert "test" in btedp[4]["name"] - assert "golang" == btedp[4]["taskRef"]["name"] - assert "sonar" in btedp[5]["name"] - assert "sonarqube-scanner" == btedp[5]["taskRef"]["name"] - assert "build" in btedp[6]["name"] - assert "golang" == btedp[6]["taskRef"]["name"] - assert "create-ecr-repository" in btd[7]["name"] - assert "kaniko-build" in btedp[8]["name"] - assert "git-tag" in btedp[9]["name"] - assert "update-cbis" in btedp[10]["name"] - assert "update-cbb" in r["pipeline"][github_build_pipeline_edp]["spec"]["finally"][0]["name"] - assert "push-to-jira" in r["pipeline"][github_build_pipeline_edp]["spec"]["finally"][1]["name"] - - -def test_go_pipelines_gitlab(): - config = """ -global: - gitProvider: gitlab - dockerRegistry: - type: "ecr" - """ - - r = helm_template(config) - vcs = "gitlab" - - # ensure pipelines have proper steps - for buildtool in ['go']: - for framework in ['beego', 'gin', 'operator-sdk']: - - review_pipeline = f"{vcs}-{buildtool}-{framework}-app-review" - build_pipeline_def = f"{vcs}-{buildtool}-{framework}-app-build-default" - build_pipeline_edp = f"{vcs}-{buildtool}-{framework}-app-build-edp" - - assert review_pipeline in r["pipeline"] - assert build_pipeline_def in r["pipeline"] - assert build_pipeline_edp in r["pipeline"] - - rt = r["pipeline"][review_pipeline]["spec"]["tasks"] - assert "report-pipeline-start-to-gitlab" in rt[0]["name"] - assert "fetch-repository" in rt[1]["name"] - assert "init-values" in rt[2]["name"] - assert "helm-docs" in rt[3]["name"] - assert "build" in rt[4]["name"] - assert "test" in rt[5]["name"] - assert "sonar" in rt[6]["name"] - assert "dockerfile-lint" in rt[7]["name"] - assert "dockerbuild-verify" in rt[8]["name"] - assert "helm-lint" in rt[9]["name"] - assert "gitlab-set-success-status" in r["pipeline"][review_pipeline]["spec"]["finally"][0]["name"] - assert "gitlab-set-failure-status" in r["pipeline"][review_pipeline]["spec"]["finally"][1]["name"] - - # build with default versioning - btd = r["pipeline"][build_pipeline_def]["spec"]["tasks"] - assert "fetch-repository" in btd[0]["name"] - assert "init-values" in btd[1]["name"] - assert "get-version" in btd[2]["name"] - # ensure we have default versioning - assert f"get-version-default" == btd[2]["taskRef"]["name"] - assert "sast" in btd[3]["name"] - assert "test" in btd[4]["name"] - assert "golang" == btd[4]["taskRef"]["name"] - assert "sonar" in btd[5]["name"] - assert "sonarqube-scanner" == btd[5]["taskRef"]["name"] - assert "build" in btd[6]["name"] - assert "golang" == btd[6]["taskRef"]["name"] - assert "create-ecr-repository" in btd[7]["name"] - assert "kaniko-build" in btd[8]["name"] - assert "git-tag" in btd[9]["name"] - assert "update-cbis" in btd[10]["name"] - assert "push-to-jira" in r["pipeline"][build_pipeline_def]["spec"]["finally"][0]["name"] - - # build with edp versioning - btedp = r["pipeline"][build_pipeline_edp]["spec"]["tasks"] - assert "fetch-repository" in btedp[0]["name"] - assert "init-values" in btedp[1]["name"] - assert "get-version" in btedp[2]["name"] - assert "get-version-edp" == btedp[2]["taskRef"]["name"] - assert "sast" in btedp[3]["name"] - assert "test" in btedp[4]["name"] - assert "golang" == btedp[4]["taskRef"]["name"] - assert "sonar" in btedp[5]["name"] - assert "sonarqube-scanner" == btedp[5]["taskRef"]["name"] - assert "build" in btedp[6]["name"] - assert "golang" == btedp[6]["taskRef"]["name"] - assert "create-ecr-repository" in btd[7]["name"] - assert "kaniko-build" in btedp[8]["name"] - assert "git-tag" in btedp[9]["name"] - assert "update-cbis" in btedp[10]["name"] - assert "update-cbb" in r["pipeline"][build_pipeline_edp]["spec"]["finally"][0]["name"] - assert "push-to-jira" in r["pipeline"][build_pipeline_edp]["spec"]["finally"][1]["name"] - - def test_go_pipelines_harbor_gerrit(): config = """ global: gitProvider: gerrit - dockerRegistry: - type: "harbor" """ r = helm_template(config) @@ -327,8 +84,6 @@ def test_go_pipelines_harbor_github(): config = """ global: gitProvider: github - dockerRegistry: - type: "harbor" """ r = helm_template(config) @@ -403,8 +158,6 @@ def test_go_pipelines_harbor_gitlab(): config = """ global: gitProvider: gitlab - dockerRegistry: - type: "harbor" """ r = helm_template(config) diff --git a/charts/pipelines-library/tests/test_java_gradle_pipelines.py b/charts/pipelines-library/tests/test_java_gradle_pipelines.py index f0666e85..3360ade1 100644 --- a/charts/pipelines-library/tests/test_java_gradle_pipelines.py +++ b/charts/pipelines-library/tests/test_java_gradle_pipelines.py @@ -1,339 +1,10 @@ from .helpers import helm_template -def test_java_gradle_pipelines_gerrit(): - config = """ -global: - gitProvider: gerrit - dockerRegistry: - type: "ecr" - """ - - r = helm_template(config) - - # ensure pipelines have proper steps - for buildtool in ['gradle']: - for framework in ['java8', 'java11', 'java17']: - for cbtype in ['app', 'lib']: - - gerrit_review_pipeline = f"gerrit-{buildtool}-{framework}-{cbtype}-review" - gerrit_build_pipeline_def = f"gerrit-{buildtool}-{framework}-{cbtype}-build-default" - gerrit_build_pipeline_edp = f"gerrit-{buildtool}-{framework}-{cbtype}-build-edp" - - assert gerrit_review_pipeline in r["pipeline"] - assert gerrit_build_pipeline_def in r["pipeline"] - assert gerrit_build_pipeline_edp in r["pipeline"] - - rt = r["pipeline"][gerrit_review_pipeline]["spec"]["tasks"] - if cbtype == "lib": - assert "fetch-repository" in rt[0]["name"] - assert "gerrit-notify" in rt[1]["name"] - assert "init-values" in rt[2]["name"] - assert "compile" in rt[3]["name"] - assert "test" in rt[4]["name"] - assert "fetch-target-branch" in rt[5]["name"] - assert "sonar-prepare-files" in rt[6]["name"] - assert f"sonar-prepare-files-{buildtool}" == rt[6]["taskRef"]["name"] - assert "sonar" in rt[7]["name"] - if cbtype == "app": - assert "fetch-repository" in rt[0]["name"] - assert "gerrit-notify" in rt[1]["name"] - assert "init-values" in rt[2]["name"] - assert "helm-docs" in rt[3]["name"] - assert "compile" in rt[4]["name"] - assert "test" in rt[5]["name"] - assert "fetch-target-branch" in rt[6]["name"] - assert "sonar-prepare-files" in rt[7]["name"] - assert f"sonar-prepare-files-{buildtool}" == rt[7]["taskRef"]["name"] - assert "sonar" in rt[8]["name"] - assert "build" in rt[9]["name"] - assert "dockerfile-lint" in rt[10]["name"] - assert "dockerbuild-verify" in rt[11]["name"] - assert "helm-lint" in rt[12]["name"] - - assert "gerrit-vote-success" in r["pipeline"][gerrit_review_pipeline]["spec"]["finally"][0]["name"] - assert "gerrit-vote-failure" in r["pipeline"][gerrit_review_pipeline]["spec"]["finally"][1]["name"] - - # build with default versioning - btd = r["pipeline"][gerrit_build_pipeline_def]["spec"]["tasks"] - assert "fetch-repository" in btd[0]["name"] - assert "gerrit-notify" in btd[1]["name"] - assert "init-values" in btd[2]["name"] - assert "get-version" in btd[3]["name"] - # ensure we have default versioning - assert f"get-version-default" == btd[3]["taskRef"]["name"] - assert "update-build-number" in btd[4]["name"] - assert "sonar-cleanup" in btd[5]["name"] - assert "sast" in btd[6]["name"] - assert "compile" in btd[7]["name"] - assert buildtool == btd[7]["taskRef"]["name"] - assert "test" in btd[8]["name"] - assert buildtool == btd[8]["taskRef"]["name"] - assert "sonar" in btd[9]["name"] - assert buildtool == btd[9]["taskRef"]["name"] - assert "build" in btd[10]["name"] - assert buildtool == btd[10]["taskRef"]["name"] - assert "get-nexus-repository-url" in btd[11]["name"] - assert "push" in btd[12]["name"] - assert buildtool == btd[12]["taskRef"]["name"] - if cbtype == "app": - assert "create-ecr-repository" in btd[13]["name"] - assert "kaniko-build" in btd[14]["name"] - assert "git-tag" in btd[15]["name"] - assert "update-cbis" in btd[16]["name"] - else: - assert "git-tag" in btd[13]["name"] - assert "push-to-jira" in r["pipeline"][gerrit_build_pipeline_def]["spec"]["finally"][0]["name"] - - # build with edp versioning - btedp = r["pipeline"][gerrit_build_pipeline_edp]["spec"]["tasks"] - assert "fetch-repository" in btedp[0]["name"] - assert "gerrit-notify" in btedp[1]["name"] - assert "init-values" in btedp[2]["name"] - assert "get-version" in btedp[3]["name"] - assert "get-version-edp" == btedp[3]["taskRef"]["name"] - idx = 3 - # we have update-build-number only for gradle - if buildtool == "gradle": - assert "update-build-number" in btedp[4]["taskRef"]["name"] - assert f"update-build-number-{buildtool}" == btedp[4]["taskRef"]["name"] - idx = 4 - assert "sonar-cleanup" in btedp[idx+1]["name"] - assert "sast" in btedp[idx+2]["name"] - assert "compile" in btedp[idx+3]["name"] - assert buildtool == btedp[idx+3]["taskRef"]["name"] - assert "test" in btedp[idx+4]["name"] - assert buildtool == btedp[idx+4]["taskRef"]["name"] - assert "sonar" in btedp[idx+5]["name"] - assert buildtool == btedp[idx+5]["taskRef"]["name"] - assert "build" in btedp[idx+6]["name"] - assert buildtool == btedp[idx+6]["taskRef"]["name"] - assert "get-nexus-repository-url" in btedp[idx+7]["name"] - assert "push" in btedp[idx+8]["name"] - assert buildtool == btedp[idx+8]["taskRef"]["name"] - if cbtype == "app": - assert "create-ecr-repository" in btedp[idx+9]["name"] - assert "kaniko-build" in btedp[idx+10]["name"] - assert "git-tag" in btedp[idx+11]["name"] - assert "update-cbis" in btedp[idx+12]["name"] - else: - assert "git-tag" in btedp[idx+9]["name"] - assert "update-cbb" in r["pipeline"][gerrit_build_pipeline_edp]["spec"]["finally"][0]["name"] - assert "push-to-jira" in r["pipeline"][gerrit_build_pipeline_edp]["spec"]["finally"][1]["name"] - - -def test_java_gradle_pipelines_github(): - config = """ -global: - gitProvider: github - dockerRegistry: - type: "ecr" - """ - - r = helm_template(config) - - # ensure pipelines have proper steps - for buildtool in ['gradle']: - for framework in ['java8', 'java11', 'java17']: - for cbtype in ['app', 'lib']: - - github_review_pipeline = f"github-{buildtool}-{framework}-{cbtype}-review" - github_build_pipeline_def = f"github-{buildtool}-{framework}-{cbtype}-build-default" - github_build_pipeline_edp = f"github-{buildtool}-{framework}-{cbtype}-build-edp" - - assert github_review_pipeline in r["pipeline"] - assert github_build_pipeline_def in r["pipeline"] - assert github_build_pipeline_edp in r["pipeline"] - - rt = r["pipeline"][github_review_pipeline]["spec"]["tasks"] - if cbtype == "lib": - assert "github-set-pending-status" in rt[0]["name"] - assert "fetch-repository" in rt[1]["name"] - assert "init-values" in rt[2]["name"] - assert "compile" in rt[3]["name"] - assert "test" in rt[4]["name"] - assert "sonar" in rt[5]["name"] - if cbtype == "app": - assert "github-set-pending-status" in rt[0]["name"] - assert "fetch-repository" in rt[1]["name"] - assert "init-values" in rt[2]["name"] - assert "helm-docs" in rt[3]["name"] - assert "compile" in rt[4]["name"] - assert "test" in rt[5]["name"] - assert "sonar" in rt[6]["name"] - assert "build" in rt[7]["name"] - assert "dockerfile-lint" in rt[8]["name"] - assert "dockerbuild-verify" in rt[9]["name"] - assert "helm-lint" in rt[10]["name"] - - assert "github-set-success-status" in r["pipeline"][github_review_pipeline]["spec"]["finally"][0]["name"] - assert "github-set-failure-status" in r["pipeline"][github_review_pipeline]["spec"]["finally"][1]["name"] - - # build with default versioning - btd = r["pipeline"][github_build_pipeline_def]["spec"]["tasks"] - assert "fetch-repository" in btd[0]["name"] - assert "init-values" in btd[1]["name"] - assert "get-version" in btd[2]["name"] - # ensure we have default versioning - assert f"get-version-default" == btd[2]["taskRef"]["name"] - assert "update-build-number" in btd[3]["name"] - assert "sast" in btd[4]["name"] - assert "compile" in btd[5]["name"] - assert buildtool == btd[5]["taskRef"]["name"] - assert "test" in btd[6]["name"] - assert buildtool == btd[6]["taskRef"]["name"] - assert "sonar" in btd[7]["name"] - assert buildtool == btd[7]["taskRef"]["name"] - assert "build" in btd[8]["name"] - assert buildtool == btd[8]["taskRef"]["name"] - assert "get-nexus-repository-url" in btd[9]["name"] - assert "push" in btd[10]["name"] - assert buildtool == btd[10]["taskRef"]["name"] - if cbtype == "app": - assert "create-ecr-repository" in btd[11]["name"] - assert "kaniko-build" in btd[12]["name"] - assert "git-tag" in btd[13]["name"] - assert "update-cbis" in btd[14]["name"] - if cbtype == "lib": - assert "git-tag" in btd[11]["name"] - assert "push-to-jira" in r["pipeline"][github_build_pipeline_def]["spec"]["finally"][0]["name"] - - # build with edp versioning - btedp = r["pipeline"][github_build_pipeline_edp]["spec"]["tasks"] - assert "fetch-repository" in btedp[0]["name"] - assert "init-values" in btedp[1]["name"] - assert "get-version" in btedp[2]["name"] - assert "get-version-edp" == btedp[2]["taskRef"]["name"] - assert "update-build-number" in btedp[3]["name"] - assert "sast" in btedp[4]["name"] - assert "compile" in btedp[5]["name"] - assert buildtool == btedp[5]["taskRef"]["name"] - assert "test" in btedp[6]["name"] - assert buildtool == btedp[6]["taskRef"]["name"] - assert "sonar" in btedp[7]["name"] - assert buildtool == btedp[7]["taskRef"]["name"] - assert "build" in btedp[8]["name"] - assert buildtool == btedp[8]["taskRef"]["name"] - assert "get-nexus-repository-url" in btedp[9]["name"] - assert "push" in btedp[10]["name"] - assert buildtool == btedp[10]["taskRef"]["name"] - if cbtype == "app": - assert "create-ecr-repository" in btedp[11]["name"] - assert "kaniko-build" in btedp[12]["name"] - assert "git-tag" in btedp[13]["name"] - assert "update-cbis" in btedp[14]["name"] - if cbtype == "lib": - assert "git-tag" in btedp[11]["name"] - assert "update-cbb" in r["pipeline"][github_build_pipeline_edp]["spec"]["finally"][0]["name"] - assert "push-to-jira" in r["pipeline"][github_build_pipeline_edp]["spec"]["finally"][1]["name"] - - -def test_java_gradle_pipelines_gitlab(): - config = """ -global: - gitProvider: gitlab - dockerRegistry: - type: "ecr" - """ - r = helm_template(config) - # ensure pipelines have proper steps - for buildtool in ['gradle']: - for framework in ['java8', 'java11', 'java17']: - for cbtype in ['app', 'lib']: - gitlab_review_pipeline = f"gitlab-{buildtool}-{framework}-{cbtype}-review" - gitlab_build_pipeline_def = f"gitlab-{buildtool}-{framework}-{cbtype}-build-default" - gitlab_build_pipeline_edp = f"gitlab-{buildtool}-{framework}-{cbtype}-build-edp" - assert gitlab_review_pipeline in r["pipeline"] - assert gitlab_build_pipeline_def in r["pipeline"] - assert gitlab_build_pipeline_edp in r["pipeline"] - rt = r["pipeline"][gitlab_review_pipeline]["spec"]["tasks"] - if cbtype == "lib": - assert "report-pipeline-start-to-gitlab" in rt[0]["name"] - assert "fetch-repository" in rt[1]["name"] - assert "init-values" in rt[2]["name"] - assert "compile" in rt[3]["name"] - assert "test" in rt[4]["name"] - assert "sonar" in rt[5]["name"] - if cbtype == "app": - assert "report-pipeline-start-to-gitlab" in rt[0]["name"] - assert "fetch-repository" in rt[1]["name"] - assert "init-values" in rt[2]["name"] - assert "helm-docs" in rt[3]["name"] - assert "compile" in rt[4]["name"] - assert "test" in rt[5]["name"] - assert "sonar" in rt[6]["name"] - assert "build" in rt[7]["name"] - assert "dockerfile-lint" in rt[8]["name"] - assert "dockerbuild-verify" in rt[9]["name"] - assert "helm-lint" in rt[10]["name"] - assert "gitlab-set-success-status" in r["pipeline"][gitlab_review_pipeline]["spec"]["finally"][0]["name"] - assert "gitlab-set-failure-status" in r["pipeline"][gitlab_review_pipeline]["spec"]["finally"][1]["name"] - - # build with default versioning - btd = r["pipeline"][gitlab_build_pipeline_def]["spec"]["tasks"] - assert "fetch-repository" in btd[0]["name"] - assert "init-values" in btd[1]["name"] - assert "get-version" in btd[2]["name"] - # ensure we have default versioning - assert f"get-version-default" == btd[2]["taskRef"]["name"] - assert "update-build-number" in btd[3]["name"] - assert "sast" in btd[4]["name"] - assert "compile" in btd[5]["name"] - assert buildtool == btd[5]["taskRef"]["name"] - assert "test" in btd[6]["name"] - assert buildtool == btd[6]["taskRef"]["name"] - assert "sonar" in btd[7]["name"] - assert buildtool == btd[7]["taskRef"]["name"] - assert "build" in btd[8]["name"] - assert buildtool == btd[8]["taskRef"]["name"] - assert "get-nexus-repository-url" in btd[9]["name"] - assert "push" in btd[10]["name"] - assert buildtool == btd[10]["taskRef"]["name"] - if cbtype == "app": - assert "create-ecr-repository" in btd[11]["name"] - assert "kaniko-build" in btd[12]["name"] - assert "git-tag" in btd[13]["name"] - assert "update-cbis" in btd[14]["name"] - if cbtype == "lib": - assert "git-tag" in btd[11]["name"] - assert "push-to-jira" in r["pipeline"][gitlab_build_pipeline_def]["spec"]["finally"][0]["name"] - - # build with edp versioning - btedp = r["pipeline"][gitlab_build_pipeline_edp]["spec"]["tasks"] - assert "fetch-repository" in btedp[0]["name"] - assert "init-values" in btedp[1]["name"] - assert "get-version" in btedp[2]["name"] - assert "get-version-edp" == btedp[2]["taskRef"]["name"] - assert "update-build-number" in btedp[3]["name"] - assert "sast" in btedp[4]["name"] - assert "compile" in btedp[5]["name"] - assert buildtool == btedp[5]["taskRef"]["name"] - assert "test" in btedp[6]["name"] - assert buildtool == btedp[6]["taskRef"]["name"] - assert "sonar" in btedp[7]["name"] - assert buildtool == btedp[7]["taskRef"]["name"] - assert "build" in btedp[8]["name"] - assert buildtool == btedp[8]["taskRef"]["name"] - assert "get-nexus-repository-url" in btedp[9]["name"] - assert "push" in btedp[10]["name"] - assert buildtool == btedp[10]["taskRef"]["name"] - if cbtype == "app": - assert "create-ecr-repository" in btedp[11]["name"] - assert "kaniko-build" in btedp[12]["name"] - assert "git-tag" in btedp[13]["name"] - assert "update-cbis" in btedp[14]["name"] - if cbtype == "lib": - assert "git-tag" in btedp[11]["name"] - assert "update-cbb" in r["pipeline"][gitlab_build_pipeline_edp]["spec"]["finally"][0]["name"] - assert "push-to-jira" in r["pipeline"][gitlab_build_pipeline_edp]["spec"]["finally"][1]["name"] - - def test_java_gradle_pipelines_harbor_gerrit(): config = """ global: gitProvider: gerrit - dockerRegistry: - type: "harbor" """ r = helm_template(config) @@ -452,8 +123,6 @@ def test_java_gradle_pipelines_harbor_github(): config = """ global: gitProvider: github - dockerRegistry: - type: "harbor" """ r = helm_template(config) @@ -556,8 +225,6 @@ def test_java_gradle_pipelines_harbor_gitlab(): config = """ global: gitProvider: gitlab - dockerRegistry: - type: "harbor" """ r = helm_template(config) # ensure pipelines have proper steps diff --git a/charts/pipelines-library/tests/test_java_maven_pipelines.py b/charts/pipelines-library/tests/test_java_maven_pipelines.py index 46f03a59..3796b823 100644 --- a/charts/pipelines-library/tests/test_java_maven_pipelines.py +++ b/charts/pipelines-library/tests/test_java_maven_pipelines.py @@ -1,424 +1,10 @@ from .helpers import helm_template -def test_java_maven_pipelines_gerrit(): - config = """ -global: - gitProvider: gerrit - dockerRegistry: - type: "ecr" - """ - - r = helm_template(config) - - # ensure pipelines have proper steps - for buildtool in ['maven']: - for framework in ['java8', 'java11', 'java17']: - for cbtype in ['app', 'lib']: - - assert f"gerrit-{buildtool}-{framework}-{cbtype}-review" in r["pipeline"] - assert f"gerrit-{buildtool}-{framework}-{cbtype}-build-default" in r["pipeline"] - assert f"gerrit-{buildtool}-{framework}-{cbtype}-build-edp" in r["pipeline"] - - gerrit_review_pipeline = f"gerrit-{buildtool}-{framework}-{cbtype}-review" - gerrit_build_pipeline_def = f"gerrit-{buildtool}-{framework}-{cbtype}-build-default" - gerrit_build_pipeline_edp = f"gerrit-{buildtool}-{framework}-{cbtype}-build-edp" - - rt = r["pipeline"][gerrit_review_pipeline]["spec"]["tasks"] - if cbtype == "app": - assert "fetch-repository" in rt[0]["name"] - assert "gerrit-notify" in rt[1]["name"] - assert "init-values" in rt[2]["name"] - assert "helm-docs" in rt[3]["name"] - assert "get-maven-module" in rt[4]["name"] - assert "compile" in rt[5]["name"] - assert "test" in rt[6]["name"] - assert "fetch-target-branch" in rt[7]["name"] - assert "sonar-prepare-files" in rt[8]["name"] - assert f"sonar-prepare-files-{buildtool}" == rt[8]["taskRef"]["name"] - assert "sonar" in rt[9]["name"] - assert "build" in rt[10]["name"] - assert "dockerfile-lint" in rt[11]["name"] - assert "dockerbuild-verify" in rt[12]["name"] - assert "helm-lint" in rt[13]["name"] - if cbtype == "lib": - assert "fetch-repository" in rt[0]["name"] - assert "gerrit-notify" in rt[1]["name"] - assert "init-values" in rt[2]["name"] - assert "compile" in rt[3]["name"] - assert "test" in rt[4]["name"] - assert "fetch-target-branch" in rt[5]["name"] - assert "sonar-prepare-files" in rt[6]["name"] - assert f"sonar-prepare-files-{buildtool}" == rt[6]["taskRef"]["name"] - assert "sonar" in rt[7]["name"] - - assert "gerrit-vote-success" in r["pipeline"][gerrit_review_pipeline]["spec"]["finally"][0]["name"] - assert "gerrit-vote-failure" in r["pipeline"][gerrit_review_pipeline]["spec"]["finally"][1]["name"] - - # build with default versioning - btd = r["pipeline"][gerrit_build_pipeline_def]["spec"]["tasks"] - assert "fetch-repository" in btd[0]["name"] - assert "gerrit-notify" in btd[1]["name"] - assert "init-values" in btd[2]["name"] - assert "get-version" in btd[3]["name"] - # ensure we have default versioning - assert f"get-version-default" == btd[3]["taskRef"]["name"] - assert "update-build-number" == btd[4]["name"] - if cbtype == "app": - assert "get-maven-module" in btd[5]["name"] - assert "sonar-cleanup" in btd[6]["name"] - assert "sast" in btd[7]["name"] - assert "compile" in btd[8]["name"] - assert buildtool == btd[8]["taskRef"]["name"] - assert "test" in btd[9]["name"] - assert buildtool == btd[9]["taskRef"]["name"] - assert "sonar" in btd[10]["name"] - assert buildtool == btd[10]["taskRef"]["name"] - assert "build" in btd[11]["name"] - assert buildtool == btd[11]["taskRef"]["name"] - assert "get-nexus-repository-url" in btd[12]["name"] - assert "push" in btd[13]["name"] - assert buildtool == btd[13]["taskRef"]["name"] - assert "create-ecr-repository" in btd[14]["name"] - assert "kaniko-build" in btd[15]["name"] - assert "git-tag" in btd[16]["name"] - assert "update-cbis" in btd[17]["name"] - else: - assert "sonar-cleanup" in btd[5]["name"] - assert "sast" in btd[6]["name"] - assert "compile" in btd[7]["name"] - assert buildtool == btd[7]["taskRef"]["name"] - assert "test" in btd[8]["name"] - assert buildtool == btd[8]["taskRef"]["name"] - assert "sonar" in btd[9]["name"] - assert buildtool == btd[9]["taskRef"]["name"] - assert "build" in btd[10]["name"] - assert buildtool == btd[10]["taskRef"]["name"] - assert "get-nexus-repository-url" in btd[11]["name"] - assert "push" in btd[12]["name"] - assert buildtool == btd[12]["taskRef"]["name"] - assert "git-tag" in btd[13]["name"] - assert "push-to-jira" in r["pipeline"][gerrit_build_pipeline_def]["spec"]["finally"][0]["name"] - - # build with edp versioning - btedp = r["pipeline"][gerrit_build_pipeline_edp]["spec"]["tasks"] - assert "fetch-repository" in btedp[0]["name"] - assert "gerrit-notify" in btedp[1]["name"] - assert "init-values" in btedp[2]["name"] - assert "get-version" in btedp[3]["name"] - assert "get-version-edp" == btedp[3]["taskRef"]["name"] - assert "update-build-number" in btedp[4]["taskRef"]["name"] - assert f"update-build-number-{buildtool}" == btedp[4]["taskRef"]["name"] - if cbtype == "app": - assert "get-maven-module" in btedp[5]["name"] - assert "sonar-cleanup" in btedp[6]["name"] - assert "sast" in btedp[7]["name"] - assert "compile" in btedp[8]["name"] - assert buildtool == btedp[8]["taskRef"]["name"] - assert "test" in btedp[9]["name"] - assert buildtool == btedp[9]["taskRef"]["name"] - assert "sonar" in btedp[10]["name"] - assert buildtool == btedp[10]["taskRef"]["name"] - assert "build" in btedp[11]["name"] - assert buildtool == btedp[11]["taskRef"]["name"] - assert "get-nexus-repository-url" in btedp[12]["name"] - assert "push" in btedp[13]["name"] - assert buildtool == btedp[13]["taskRef"]["name"] - assert "create-ecr-repository" in btedp[14]["name"] - assert "kaniko-build" in btedp[15]["name"] - assert "git-tag" in btedp[16]["name"] - assert "update-cbis" in btedp[17]["name"] - else: - assert "sonar-cleanup" in btedp[5]["name"] - assert "sast" in btedp[6]["name"] - assert "compile" in btedp[7]["name"] - assert buildtool == btedp[7]["taskRef"]["name"] - assert "test" in btedp[8]["name"] - assert buildtool == btedp[8]["taskRef"]["name"] - assert "sonar" in btedp[9]["name"] - assert buildtool == btedp[9]["taskRef"]["name"] - assert "build" in btedp[10]["name"] - assert buildtool == btedp[10]["taskRef"]["name"] - assert "get-nexus-repository-url" in btedp[11]["name"] - assert "push" in btedp[12]["name"] - assert buildtool == btedp[12]["taskRef"]["name"] - assert "git-tag" in btedp[13]["name"] - assert "update-cbb" in r["pipeline"][gerrit_build_pipeline_edp]["spec"]["finally"][0]["name"] - assert "push-to-jira" in r["pipeline"][gerrit_build_pipeline_edp]["spec"]["finally"][1]["name"] - - -def test_java_maven_pipelines_github(): - config = """ -global: - gitProvider: github - dockerRegistry: - type: "ecr" - """ - - r = helm_template(config) - - # ensure pipelines have proper steps - for buildtool in ['maven']: - for framework in ['java8', 'java11', 'java17']: - for cbtype in ['app', 'lib']: - - github_review_pipeline = f"github-{buildtool}-{framework}-{cbtype}-review" - github_build_pipeline_def = f"github-{buildtool}-{framework}-{cbtype}-build-default" - github_build_pipeline_edp = f"github-{buildtool}-{framework}-{cbtype}-build-edp" - - assert github_review_pipeline in r["pipeline"] - assert github_build_pipeline_def in r["pipeline"] - assert github_build_pipeline_edp in r["pipeline"] - - rt = r["pipeline"][github_review_pipeline]["spec"]["tasks"] - if cbtype == "app": - assert "github-set-pending-status" in rt[0]["name"] - assert "fetch-repository" in rt[1]["name"] - assert "init-values" in rt[2]["name"] - assert "helm-docs" in rt[3]["name"] - assert "get-maven-module" in rt[4]["name"] - assert "compile" in rt[5]["name"] - assert "test" in rt[6]["name"] - assert "sonar" in rt[7]["name"] - assert "build" in rt[8]["name"] - assert "dockerfile-lint" in rt[9]["name"] - assert "dockerbuild-verify" in rt[10]["name"] - assert "helm-lint" in rt[11]["name"] - if cbtype == "lib": - assert "github-set-pending-status" in rt[0]["name"] - assert "fetch-repository" in rt[1]["name"] - assert "init-values" in rt[2]["name"] - assert "compile" in rt[3]["name"] - assert "test" in rt[4]["name"] - assert "sonar" in rt[5]["name"] - - assert "github-set-success-status" in r["pipeline"][github_review_pipeline]["spec"]["finally"][0]["name"] - assert "github-set-failure-status" in r["pipeline"][github_review_pipeline]["spec"]["finally"][1]["name"] - - # build with default versioning - btd = r["pipeline"][github_build_pipeline_def]["spec"]["tasks"] - assert "fetch-repository" in btd[0]["name"] - assert "init-values" in btd[1]["name"] - assert "get-version" in btd[2]["name"] - assert f"get-version-default" == btd[2]["taskRef"]["name"] - assert "update-build-number" == btd[3]["name"] - if cbtype == "app": - assert "get-maven-module" in btd[4]["name"] - assert "sast" in btd[5]["name"] - assert "compile" in btd[6]["name"] - assert buildtool == btd[6]["taskRef"]["name"] - assert "test" in btd[7]["name"] - assert buildtool == btd[7]["taskRef"]["name"] - assert "sonar" in btd[8]["name"] - assert buildtool == btd[8]["taskRef"]["name"] - assert "build" in btd[9]["name"] - assert buildtool == btd[9]["taskRef"]["name"] - assert "get-nexus-repository-url" in btd[10]["name"] - assert "push" in btd[11]["name"] - assert buildtool == btd[11]["taskRef"]["name"] - assert "create-ecr-repository" in btd[12]["name"] - assert "kaniko-build" in btd[13]["name"] - assert "git-tag" in btd[14]["name"] - assert "update-cbis" in btd[15]["name"] - if cbtype == "lib": - assert "sast" in btd[4]["name"] - assert "compile" in btd[5]["name"] - assert buildtool == btd[5]["taskRef"]["name"] - assert "test" in btd[6]["name"] - assert buildtool == btd[6]["taskRef"]["name"] - assert "sonar" in btd[7]["name"] - assert buildtool == btd[7]["taskRef"]["name"] - assert "build" in btd[8]["name"] - assert buildtool == btd[8]["taskRef"]["name"] - assert "get-nexus-repository-url" in btd[9]["name"] - assert "push" in btd[10]["name"] - assert buildtool == btd[10]["taskRef"]["name"] - assert "git-tag" in btd[11]["name"] - assert "push-to-jira" in r["pipeline"][github_build_pipeline_def]["spec"]["finally"][0]["name"] - - # build with edp versioning - btedp = r["pipeline"][github_build_pipeline_edp]["spec"]["tasks"] - assert "fetch-repository" in btedp[0]["name"] - assert "init-values" in btedp[1]["name"] - assert "get-version" in btedp[2]["name"] - assert "get-version-edp" == btedp[2]["taskRef"]["name"] - assert "update-build-number" in btedp[3]["taskRef"]["name"] - assert f"update-build-number-{buildtool}" == btedp[3]["taskRef"]["name"] - if cbtype == "app": - assert "get-maven-module" in btedp[4]["name"] - assert "sast" in btedp[5]["name"] - assert "compile" in btedp[6]["name"] - assert buildtool == btedp[6]["taskRef"]["name"] - assert "test" in btedp[7]["name"] - assert buildtool == btedp[7]["taskRef"]["name"] - assert "sonar" in btedp[8]["name"] - assert buildtool == btedp[8]["taskRef"]["name"] - assert "build" in btedp[9]["name"] - assert buildtool == btedp[9]["taskRef"]["name"] - assert "get-nexus-repository-url" in btedp[10]["name"] - assert "push" in btedp[11]["name"] - assert buildtool == btedp[11]["taskRef"]["name"] - assert "create-ecr-repository" in btedp[12]["name"] - assert "kaniko-build" in btedp[13]["name"] - assert "git-tag" in btedp[14]["name"] - assert "update-cbis" in btedp[15]["name"] - if cbtype == "lib": - assert "sast" in btedp[4]["name"] - assert "compile" in btedp[5]["name"] - assert buildtool == btedp[5]["taskRef"]["name"] - assert "test" in btedp[6]["name"] - assert buildtool == btedp[6]["taskRef"]["name"] - assert "sonar" in btedp[7]["name"] - assert buildtool == btedp[7]["taskRef"]["name"] - assert "build" in btedp[8]["name"] - assert buildtool == btedp[8]["taskRef"]["name"] - assert "get-nexus-repository-url" in btedp[9]["name"] - assert "push" in btedp[10]["name"] - assert buildtool == btedp[10]["taskRef"]["name"] - assert "git-tag" in btedp[11]["name"] - assert "update-cbb" in r["pipeline"][github_build_pipeline_edp]["spec"]["finally"][0]["name"] - assert "push-to-jira" in r["pipeline"][github_build_pipeline_edp]["spec"]["finally"][1]["name"] - - -def test_java_maven_pipelines_gitlab(): - config = """ -global: - gitProvider: gitlab - dockerRegistry: - type: "ecr" - """ - - r = helm_template(config) - - # ensure pipelines have proper steps - for buildtool in ['maven']: - for framework in ['java8', 'java11', 'java17']: - for cbtype in ['app', 'lib']: - - gitlab_review_pipeline = f"gitlab-{buildtool}-{framework}-{cbtype}-review" - gitlab_build_pipeline_def = f"gitlab-{buildtool}-{framework}-{cbtype}-build-default" - gitlab_build_pipeline_edp = f"gitlab-{buildtool}-{framework}-{cbtype}-build-edp" - - assert gitlab_review_pipeline in r["pipeline"] - assert gitlab_build_pipeline_def in r["pipeline"] - assert gitlab_build_pipeline_edp in r["pipeline"] - - rt = r["pipeline"][gitlab_review_pipeline]["spec"]["tasks"] - if cbtype == "app": - assert "report-pipeline-start-to-gitlab" in rt[0]["name"] - assert "fetch-repository" in rt[1]["name"] - assert "init-values" in rt[2]["name"] - assert "helm-docs" in rt[3]["name"] - assert "get-maven-module" in rt[4]["name"] - assert "compile" in rt[5]["name"] - assert "test" in rt[6]["name"] - assert "sonar" in rt[7]["name"] - assert "build" in rt[8]["name"] - assert "dockerfile-lint" in rt[9]["name"] - assert "dockerbuild-verify" in rt[10]["name"] - assert "helm-lint" in rt[11]["name"] - if cbtype == "lib": - assert "report-pipeline-start-to-gitlab" in rt[0]["name"] - assert "fetch-repository" in rt[1]["name"] - assert "init-values" in rt[2]["name"] - assert "compile" in rt[3]["name"] - assert "test" in rt[4]["name"] - assert "sonar" in rt[5]["name"] - - assert "gitlab-set-success-status" in r["pipeline"][gitlab_review_pipeline]["spec"]["finally"][0]["name"] - assert "gitlab-set-failure-status" in r["pipeline"][gitlab_review_pipeline]["spec"]["finally"][1]["name"] - - # build with default versioning - btd = r["pipeline"][gitlab_build_pipeline_def]["spec"]["tasks"] - assert "fetch-repository" in btd[0]["name"] - assert "init-values" in btd[1]["name"] - assert "get-version" in btd[2]["name"] - assert f"get-version-default" == btd[2]["taskRef"]["name"] - assert "update-build-number" == btd[3]["name"] - if cbtype == "app": - assert "get-maven-module" in btd[4]["name"] - assert "sast" in btd[5]["name"] - assert "compile" in btd[6]["name"] - assert buildtool == btd[6]["taskRef"]["name"] - assert "test" in btd[7]["name"] - assert buildtool == btd[7]["taskRef"]["name"] - assert "sonar" in btd[8]["name"] - assert buildtool == btd[8]["taskRef"]["name"] - assert "build" in btd[9]["name"] - assert buildtool == btd[9]["taskRef"]["name"] - assert "get-nexus-repository-url" in btd[10]["name"] - assert "push" in btd[11]["name"] - assert buildtool == btd[11]["taskRef"]["name"] - assert "create-ecr-repository" in btd[12]["name"] - assert "kaniko-build" in btd[13]["name"] - assert "git-tag" in btd[14]["name"] - assert "update-cbis" in btd[15]["name"] - if cbtype == "lib": - assert "sast" in btd[4]["name"] - assert "compile" in btd[5]["name"] - assert buildtool == btd[5]["taskRef"]["name"] - assert "test" in btd[6]["name"] - assert buildtool == btd[6]["taskRef"]["name"] - assert "sonar" in btd[7]["name"] - assert buildtool == btd[7]["taskRef"]["name"] - assert "build" in btd[8]["name"] - assert buildtool == btd[8]["taskRef"]["name"] - assert "get-nexus-repository-url" in btd[9]["name"] - assert "push" in btd[10]["name"] - assert buildtool == btd[10]["taskRef"]["name"] - assert "git-tag" in btd[11]["name"] - assert "push-to-jira" in r["pipeline"][gitlab_build_pipeline_def]["spec"]["finally"][0]["name"] - - # build with edp versioning - btedp = r["pipeline"][gitlab_build_pipeline_edp]["spec"]["tasks"] - assert "fetch-repository" in btedp[0]["name"] - assert "init-values" in btedp[1]["name"] - assert "get-version" in btedp[2]["name"] - assert "get-version-edp" == btedp[2]["taskRef"]["name"] - assert "update-build-number" in btedp[3]["taskRef"]["name"] - assert f"update-build-number-{buildtool}" == btedp[3]["taskRef"]["name"] - if cbtype == "app": - assert "get-maven-module" in btedp[4]["name"] - assert "sast" in btedp[5]["name"] - assert "compile" in btedp[6]["name"] - assert buildtool == btedp[6]["taskRef"]["name"] - assert "test" in btedp[7]["name"] - assert buildtool == btedp[7]["taskRef"]["name"] - assert "sonar" in btedp[8]["name"] - assert buildtool == btedp[8]["taskRef"]["name"] - assert "build" in btedp[9]["name"] - assert buildtool == btedp[9]["taskRef"]["name"] - assert "get-nexus-repository-url" in btedp[10]["name"] - assert "push" in btedp[11]["name"] - assert buildtool == btedp[11]["taskRef"]["name"] - assert "create-ecr-repository" in btedp[12]["name"] - assert "kaniko-build" in btedp[13]["name"] - assert "git-tag" in btedp[14]["name"] - assert "update-cbis" in btedp[15]["name"] - if cbtype == "lib": - assert "sast" in btedp[4]["name"] - assert "compile" in btedp[5]["name"] - assert buildtool == btedp[5]["taskRef"]["name"] - assert "test" in btedp[6]["name"] - assert buildtool == btedp[6]["taskRef"]["name"] - assert "sonar" in btedp[7]["name"] - assert buildtool == btedp[7]["taskRef"]["name"] - assert "build" in btedp[8]["name"] - assert buildtool == btedp[8]["taskRef"]["name"] - assert "get-nexus-repository-url" in btedp[9]["name"] - assert "push" in btedp[10]["name"] - assert buildtool == btedp[10]["taskRef"]["name"] - assert "git-tag" in btedp[11]["name"] - assert "update-cbb" in r["pipeline"][gitlab_build_pipeline_edp]["spec"]["finally"][0]["name"] - assert "push-to-jira" in r["pipeline"][gitlab_build_pipeline_edp]["spec"]["finally"][1]["name"] - - def test_java_maven_pipelines_harbor_gerrit(): config = """ global: gitProvider: gerrit - dockerRegistry: - type: "harbor" """ r = helm_template(config) @@ -561,8 +147,6 @@ def test_java_maven_pipelines_harbor_github(): config = """ global: gitProvider: github - dockerRegistry: - type: "harbor" """ r = helm_template(config) @@ -692,8 +276,6 @@ def test_java_maven_pipelines_harbor_gitlab(): config = """ global: gitProvider: gitlab - dockerRegistry: - type: "harbor" """ r = helm_template(config) diff --git a/charts/pipelines-library/tests/test_javascript_antora_pipelines.py b/charts/pipelines-library/tests/test_javascript_antora_pipelines.py index dff3262e..050af0fe 100644 --- a/charts/pipelines-library/tests/test_javascript_antora_pipelines.py +++ b/charts/pipelines-library/tests/test_javascript_antora_pipelines.py @@ -1,220 +1,10 @@ from .helpers import helm_template -def test_javascript_antora_pipelines_gerrit(): - config = """ -global: - gitProvider: gerrit - dockerRegistry: - type: "ecr" - """ - - r = helm_template(config) - - # ensure pipelines have proper steps - for buildtool in ['npm']: - for framework in ['antora']: - for cbtype in ['app']: - - assert f"gerrit-{buildtool}-{framework}-{cbtype}-review" in r["pipeline"] - assert f"gerrit-{buildtool}-{framework}-{cbtype}-build-default" in r["pipeline"] - assert f"gerrit-{buildtool}-{framework}-{cbtype}-build-edp" in r["pipeline"] - - gerrit_review_pipeline = f"gerrit-{buildtool}-{framework}-{cbtype}-review" - gerrit_build_pipeline_def = f"gerrit-{buildtool}-{framework}-{cbtype}-build-default" - gerrit_build_pipeline_edp = f"gerrit-{buildtool}-{framework}-{cbtype}-build-edp" - - rt = r["pipeline"][gerrit_review_pipeline]["spec"]["tasks"] - assert "fetch-repository" in rt[0]["name"] - assert "gerrit-notify" in rt[1]["name"] - assert "helm-docs" in rt[2]["name"] - assert "build" in rt[3]["name"] - assert "dockerfile-lint" in rt[4]["name"] - assert "dockerbuild-verify" in rt[5]["name"] - assert "helm-lint" in rt[6]["name"] - assert "gerrit-vote-success" in r["pipeline"][gerrit_review_pipeline]["spec"]["finally"][0]["name"] - assert "gerrit-vote-failure" in r["pipeline"][gerrit_review_pipeline]["spec"]["finally"][1]["name"] - - # build with default versioning - btd = r["pipeline"][gerrit_build_pipeline_def]["spec"]["tasks"] - assert "fetch-repository" in btd[0]["name"] - assert "gerrit-notify" in btd[1]["name"] - assert "init-values" in btd[2]["name"] - assert "get-version" in btd[3]["name"] - assert f"get-version-default" == btd[3]["taskRef"]["name"] - assert "update-build-number" in btd[4]["name"] - assert "sast" in btd[5]["name"] - assert "build" in btd[6]["name"] - assert "create-ecr-repository" in btd[7]["name"] - assert "kaniko-build" in btd[8]["name"] - assert "git-tag" in btd[9]["name"] - assert "update-cbis" in btd[10]["name"] - assert "push-to-jira" in r["pipeline"][gerrit_build_pipeline_def]["spec"]["finally"][0]["name"] - - # build with edp versioning - btedp = r["pipeline"][gerrit_build_pipeline_edp]["spec"]["tasks"] - assert "fetch-repository" in btedp[0]["name"] - assert "gerrit-notify" in btedp[1]["name"] - assert "init-values" in btedp[2]["name"] - assert "get-version" in btedp[3]["name"] - assert "get-version-edp" == btedp[3]["taskRef"]["name"] - assert "update-build-number" in btedp[4]["taskRef"]["name"] - assert f"update-build-number-{buildtool}" == btedp[4]["taskRef"]["name"] - assert "sast" in btedp[5]["name"] - assert "build" in btedp[6]["name"] - assert buildtool == btedp[6]["taskRef"]["name"] - assert "create-ecr-repository" in btedp[7]["name"] - assert "kaniko-build" in btedp[8]["name"] - assert "git-tag" in btedp[9]["name"] - assert "update-cbis" in btedp[10]["name"] - assert "update-cbb" in r["pipeline"][gerrit_build_pipeline_edp]["spec"]["finally"][0]["name"] - assert "push-to-jira" in r["pipeline"][gerrit_build_pipeline_edp]["spec"]["finally"][1]["name"] - -def test_javascript_antora_pipelines_github(): - config = """ -global: - gitProvider: github - dockerRegistry: - type: "ecr" - """ - - r = helm_template(config) - vcs = "github" - - # ensure pipelines have proper steps - for buildtool in ['npm']: - for framework in ['antora']: - for cbtype in ['app']: - - github_review_pipeline = f"{vcs}-{buildtool}-{framework}-{cbtype}-review" - github_build_pipeline_def = f"{vcs}-{buildtool}-{framework}-{cbtype}-build-default" - github_build_pipeline_edp = f"{vcs}-{buildtool}-{framework}-{cbtype}-build-edp" - - assert github_review_pipeline in r["pipeline"] - assert github_build_pipeline_def in r["pipeline"] - assert github_build_pipeline_edp in r["pipeline"] - - rt = r["pipeline"][github_review_pipeline]["spec"]["tasks"] - assert "github-set-pending-status" in rt[0]["name"] - assert "fetch-repository" in rt[1]["name"] - assert "helm-docs" in rt[2]["name"] - assert "build" in rt[3]["name"] - assert "dockerfile-lint" in rt[4]["name"] - assert "dockerbuild-verify" in rt[5]["name"] - assert "helm-lint" in rt[6]["name"] - assert "github-set-success-status" in r["pipeline"][github_review_pipeline]["spec"]["finally"][0]["name"] - assert "github-set-failure-status" in r["pipeline"][github_review_pipeline]["spec"]["finally"][1]["name"] - - # build with default versioning - btd = r["pipeline"][github_build_pipeline_def]["spec"]["tasks"] - assert "fetch-repository" in btd[0]["name"] - assert "init-values" in btd[1]["name"] - assert "get-version" in btd[2]["name"] - assert f"get-version-default" == btd[2]["taskRef"]["name"] - assert "update-build-number" in btd[3]["name"] - assert "sast" in btd[4]["name"] - assert "build" in btd[5]["name"] - assert buildtool == btd[5]["taskRef"]["name"] - assert "create-ecr-repository" in btd[6]["name"] - assert "kaniko-build" in btd[7]["name"] - assert "git-tag" in btd[8]["name"] - assert "update-cbis" in btd[9]["name"] - assert "push-to-jira" in r["pipeline"][github_build_pipeline_def]["spec"]["finally"][0]["name"] - - btedp = r["pipeline"][github_build_pipeline_edp]["spec"]["tasks"] - assert "fetch-repository" in btedp[0]["name"] - assert "init-values" in btedp[1]["name"] - assert "get-version" in btedp[2]["name"] - assert "get-version-edp" == btedp[2]["taskRef"]["name"] - assert "update-build-number" in btedp[3]["taskRef"]["name"] - assert f"update-build-number-{buildtool}" == btedp[3]["taskRef"]["name"] - assert "sast" in btedp[4]["name"] - assert "build" in btedp[5]["name"] - assert buildtool == btedp[5]["taskRef"]["name"] - assert "create-ecr-repository" in btedp[6]["name"] - assert "kaniko-build" in btedp[7]["name"] - assert "git-tag" in btedp[8]["name"] - assert "update-cbis" in btedp[9]["name"] - assert "update-cbb" in r["pipeline"][github_build_pipeline_edp]["spec"]["finally"][0]["name"] - assert "push-to-jira" in r["pipeline"][github_build_pipeline_edp]["spec"]["finally"][1]["name"] - - -def test_javascript_antora_pipelines_gitlab(): - config = """ -global: - gitProvider: gitlab - dockerRegistry: - type: "ecr" - """ - - r = helm_template(config) - vcs = "gitlab" - - # ensure pipelines have proper steps - for buildtool in ['npm']: - for framework in ['antora']: - for cbtype in ['app']: - - gitlab_review_pipeline = f"{vcs}-{buildtool}-{framework}-{cbtype}-review" - gitlab_build_pipeline_def = f"{vcs}-{buildtool}-{framework}-{cbtype}-build-default" - gitlab_build_pipeline_edp = f"{vcs}-{buildtool}-{framework}-{cbtype}-build-edp" - - assert gitlab_review_pipeline in r["pipeline"] - assert gitlab_build_pipeline_def in r["pipeline"] - assert gitlab_build_pipeline_edp in r["pipeline"] - - rt = r["pipeline"][gitlab_review_pipeline]["spec"]["tasks"] - assert "report-pipeline-start-to-gitlab" in rt[0]["name"] - assert "fetch-repository" in rt[1]["name"] - assert "helm-docs" in rt[2]["name"] - assert "build" in rt[3]["name"] - assert "dockerfile-lint" in rt[4]["name"] - assert "dockerbuild-verify" in rt[5]["name"] - assert "helm-lint" in rt[6]["name"] - assert "gitlab-set-success-status" in r["pipeline"][gitlab_review_pipeline]["spec"]["finally"][0]["name"] - assert "gitlab-set-failure-status" in r["pipeline"][gitlab_review_pipeline]["spec"]["finally"][1]["name"] - - # build with default versioning - btd = r["pipeline"][gitlab_build_pipeline_def]["spec"]["tasks"] - assert "fetch-repository" in btd[0]["name"] - assert "init-values" in btd[1]["name"] - # ensure we have default versioning - assert "get-version" in btd[2]["name"] - assert f"get-version-default" == btd[2]["taskRef"]["name"] - assert "update-build-number" in btd[3]["name"] - assert "sast" in btd[4]["name"] - assert "build" in btd[5]["name"] - assert buildtool == btd[5]["taskRef"]["name"] - assert "create-ecr-repository" in btd[6]["name"] - assert "kaniko-build" in btd[7]["name"] - assert "git-tag" in btd[8]["name"] - assert "update-cbis" in btd[9]["name"] - assert "push-to-jira" in r["pipeline"][gitlab_build_pipeline_def]["spec"]["finally"][0]["name"] - - # build with edp versioning - btedp = r["pipeline"][gitlab_build_pipeline_edp]["spec"]["tasks"] - assert "fetch-repository" in btedp[0]["name"] - assert "init-values" in btedp[1]["name"] - assert "get-version" in btedp[2]["name"] - assert "get-version-edp" == btedp[2]["taskRef"]["name"] - assert "update-build-number" in btedp[3]["taskRef"]["name"] - assert f"update-build-number-{buildtool}" == btedp[3]["taskRef"]["name"] - assert "sast" in btedp[4]["name"] - assert "build" in btedp[5]["name"] - assert buildtool == btedp[5]["taskRef"]["name"] - assert "create-ecr-repository" in btedp[6]["name"] - assert "kaniko-build" in btedp[7]["name"] - assert "git-tag" in btedp[8]["name"] - assert "update-cbis" in btedp[9]["name"] - assert "update-cbb" in r["pipeline"][gitlab_build_pipeline_edp]["spec"]["finally"][0]["name"] - assert "push-to-jira" in r["pipeline"][gitlab_build_pipeline_edp]["spec"]["finally"][1]["name"] - def test_javascript_antora_pipelines_harbor_gerrit(): config = """ global: gitProvider: gerrit - dockerRegistry: - type: "harbor" """ r = helm_template(config) @@ -280,8 +70,6 @@ def test_javascript_antora_pipelines_harbor_github(): config = """ global: gitProvider: github - dockerRegistry: - type: "harbor" """ r = helm_template(config) @@ -347,8 +135,6 @@ def test_javascript_antora_pipelines_harbor_gitlab(): config = """ global: gitProvider: gitlab - dockerRegistry: - type: "harbor" """ r = helm_template(config) diff --git a/charts/pipelines-library/tests/test_javascript_pipelines.py b/charts/pipelines-library/tests/test_javascript_pipelines.py index e317f7a9..d85e2bc7 100644 --- a/charts/pipelines-library/tests/test_javascript_pipelines.py +++ b/charts/pipelines-library/tests/test_javascript_pipelines.py @@ -1,357 +1,10 @@ from .helpers import helm_template -def test_javascript_pipelines_gerrit(): - config = """ -global: - gitProvider: gerrit - dockerRegistry: - type: "ecr" - """ - - r = helm_template(config) - - # ensure pipelines have proper steps - for buildtool in ['npm']: - for framework in ['react', 'angular', 'vue', 'express', 'next']: - for cbtype in ['app', 'lib']: - - assert f"gerrit-{buildtool}-{framework}-{cbtype}-review" in r["pipeline"] - assert f"gerrit-{buildtool}-{framework}-{cbtype}-build-default" in r["pipeline"] - assert f"gerrit-{buildtool}-{framework}-{cbtype}-build-edp" in r["pipeline"] - - gerrit_review_pipeline = f"gerrit-{buildtool}-{framework}-{cbtype}-review" - gerrit_build_pipeline_def = f"gerrit-{buildtool}-{framework}-{cbtype}-build-default" - gerrit_build_pipeline_edp = f"gerrit-{buildtool}-{framework}-{cbtype}-build-edp" - - rt = r["pipeline"][gerrit_review_pipeline]["spec"]["tasks"] - if cbtype == "lib": - assert "fetch-repository" in rt[0]["name"] - assert "gerrit-notify" in rt[1]["name"] - assert "init-values" in rt[2]["name"] - assert "npm-init" in rt[3]["name"] - assert "build" in rt[4]["name"] - assert "test" in rt[5]["name"] - assert "fetch-target-branch" in rt[6]["name"] - assert "sonar-prepare-files" in rt[7]["name"] - assert "sonar-prepare-files-general" == rt[7]["taskRef"]["name"] - assert "sonar" in rt[8]["name"] - if cbtype == "app": - assert "fetch-repository" in rt[0]["name"] - assert "gerrit-notify" in rt[1]["name"] - assert "init-values" in rt[2]["name"] - assert "helm-docs" in rt[3]["name"] - assert "npm-init" in rt[4]["name"] - assert "build" in rt[5]["name"] - assert "test" in rt[6]["name"] - assert "fetch-target-branch" in rt[7]["name"] - assert "sonar-prepare-files" in rt[8]["name"] - assert "sonar-prepare-files-general" == rt[8]["taskRef"]["name"] - assert "sonar" in rt[9]["name"] - assert "dockerfile-lint" in rt[10]["name"] - assert "dockerbuild-verify" in rt[11]["name"] - assert "helm-lint" in rt[12]["name"] - - assert "gerrit-vote-success" in r["pipeline"][gerrit_review_pipeline]["spec"]["finally"][0]["name"] - assert "gerrit-vote-failure" in r["pipeline"][gerrit_review_pipeline]["spec"]["finally"][1]["name"] - - # build with default versioning - btd = r["pipeline"][gerrit_build_pipeline_def]["spec"]["tasks"] - assert "fetch-repository" in btd[0]["name"] - assert "gerrit-notify" in btd[1]["name"] - assert "init-values" in btd[2]["name"] - assert "get-version" in btd[3]["name"] - # ensure we have default versioning - assert f"get-version-default" == btd[3]["taskRef"]["name"] - assert "update-build-number" in btd[4]["name"] - assert "sonar-cleanup" in btd[5]["name"] - assert "sast" in btd[6]["name"] - assert "npm-init" in btd[7]["name"] - assert "compile" in btd[8]["name"] - assert "test" in btd[9]["name"] - assert buildtool == btd[9]["taskRef"]["name"] - assert "sonar" in btd[10]["name"] - assert "sonarqube-scanner" == btd[10]["taskRef"]["name"] - assert "build" in btd[11]["name"] - assert buildtool == btd[11]["taskRef"]["name"] - assert "get-nexus-repository-url" in btd[12]["name"] - assert "get-nexus-repository-url" == btd[12]["taskRef"]["name"] - assert "push" in btd[13]["name"] - assert "npm" == btd[13]["taskRef"]["name"] - if cbtype == "app": - assert "create-ecr-repository" in btd[14]["name"] - assert "kaniko-build" in btd[15]["name"] - assert "git-tag" in btd[16]["name"] - assert "update-cbis" in btd[17]["name"] - if cbtype == "lib": - assert "git-tag" in btd[14]["name"] - assert "push-to-jira" in r["pipeline"][gerrit_build_pipeline_def]["spec"]["finally"][0]["name"] - - # build with edp versioning - btedp = r["pipeline"][gerrit_build_pipeline_edp]["spec"]["tasks"] - assert "fetch-repository" in btedp[0]["name"] - assert "gerrit-notify" in btedp[1]["name"] - assert "init-values" in btedp[2]["name"] - assert "get-version" in btedp[3]["name"] - assert "get-version-edp" == btedp[3]["taskRef"]["name"] - assert "update-build-number" in btedp[4]["taskRef"]["name"] - assert f"update-build-number-{buildtool}" == btedp[4]["taskRef"]["name"] - assert "sonar-cleanup" in btedp[5]["name"] - assert "sast" in btedp[6]["name"] - assert "npm-init" in btedp[7]["name"] - assert "compile" in btedp[8]["name"] - assert buildtool == btedp[8]["taskRef"]["name"] - assert "test" in btedp[9]["name"] - assert buildtool == btedp[9]["taskRef"]["name"] - assert "sonar" in btedp[10]["name"] - assert "sonarqube-scanner" == btedp[10]["taskRef"]["name"] - assert "build" in btedp[11]["name"] - assert buildtool == btedp[11]["taskRef"]["name"] - assert "get-nexus-repository-url" in btedp[12]["name"] - assert "get-nexus-repository-url" == btedp[12]["taskRef"]["name"] - assert "push" in btedp[13]["name"] - assert "npm" == btedp[13]["taskRef"]["name"] - if cbtype == "app": - assert "create-ecr-repository" in btedp[14]["name"] - assert "kaniko-build" in btedp[15]["name"] - assert "git-tag" in btedp[16]["name"] - assert "update-cbis" in btedp[17]["name"] - if cbtype == "lib": - assert "git-tag" in btedp[14]["name"] - assert "update-cbb" in r["pipeline"][gerrit_build_pipeline_edp]["spec"]["finally"][0]["name"] - assert "push-to-jira" in r["pipeline"][gerrit_build_pipeline_edp]["spec"]["finally"][1]["name"] - - -def test_javascript_pipelines_github(): - config = """ -global: - gitProvider: github - dockerRegistry: - type: "ecr" - """ - - r = helm_template(config) - vcs = "github" - - # ensure pipelines have proper steps - for buildtool in ['npm']: - for framework in ['react', 'angular', 'vue', 'express', 'next']: - for cbtype in ['app', 'lib']: - - github_review_pipeline = f"{vcs}-{buildtool}-{framework}-{cbtype}-review" - github_build_pipeline_def = f"{vcs}-{buildtool}-{framework}-{cbtype}-build-default" - github_build_pipeline_edp = f"{vcs}-{buildtool}-{framework}-{cbtype}-build-edp" - - assert github_review_pipeline in r["pipeline"] - assert github_build_pipeline_def in r["pipeline"] - assert github_build_pipeline_edp in r["pipeline"] - - rt = r["pipeline"][github_review_pipeline]["spec"]["tasks"] - if cbtype == "lib": - assert "github-set-pending-status" in rt[0]["name"] - assert "fetch-repository" in rt[1]["name"] - assert "init-values" in rt[2]["name"] - assert "npm-init" in rt[3]["name"] - assert "build" in rt[4]["name"] - assert "test" in rt[5]["name"] - assert "sonar" in rt[6]["name"] - if cbtype == "app": - assert "github-set-pending-status" in rt[0]["name"] - assert "fetch-repository" in rt[1]["name"] - assert "init-values" in rt[2]["name"] - assert "helm-docs" in rt[3]["name"] - assert "npm-init" in rt[4]["name"] - assert "build" in rt[5]["name"] - assert "test" in rt[6]["name"] - assert "sonar" in rt[7]["name"] - assert "dockerfile-lint" in rt[8]["name"] - assert "dockerbuild-verify" in rt[9]["name"] - assert "helm-lint" in rt[10]["name"] - - assert "github-set-success-status" in r["pipeline"][github_review_pipeline]["spec"]["finally"][0]["name"] - assert "github-set-failure-status" in r["pipeline"][github_review_pipeline]["spec"]["finally"][1]["name"] - - # build with default versioning - btd = r["pipeline"][github_build_pipeline_def]["spec"]["tasks"] - assert "fetch-repository" in btd[0]["name"] - assert "init-values" in btd[1]["name"] - # ensure we have default versioning - assert "get-version" in btd[2]["name"] - assert f"get-version-default" == btd[2]["taskRef"]["name"] - assert "update-build-number" in btd[3]["name"] - assert "sast" in btd[4]["name"] - assert "npm-init" in btd[5]["name"] - assert "compile" in btd[6]["name"] - assert "test" in btd[7]["name"] - assert buildtool == btd[7]["taskRef"]["name"] - assert "sonar" in btd[8]["name"] - assert "sonarqube-scanner" == btd[8]["taskRef"]["name"] - assert "build" in btd[9]["name"] - assert buildtool == btd[9]["taskRef"]["name"] - assert "get-nexus-repository-url" in btd[10]["name"] - assert "get-nexus-repository-url" == btd[10]["taskRef"]["name"] - assert "push" in btd[11]["name"] - assert "npm" == btd[11]["taskRef"]["name"] - if cbtype == "app": - assert "create-ecr-repository" in btd[12]["name"] - assert "kaniko-build" in btd[13]["name"] - assert "git-tag" in btd[14]["name"] - assert "update-cbis" in btd[15]["name"] - if cbtype == "lib": - assert "git-tag" in btd[12]["name"] - assert "push-to-jira" in r["pipeline"][github_build_pipeline_def]["spec"]["finally"][0]["name"] - - # build with edp versioning - btedp = r["pipeline"][github_build_pipeline_edp]["spec"]["tasks"] - assert "fetch-repository" in btedp[0]["name"] - assert "init-values" in btedp[1]["name"] - assert "get-version" in btedp[2]["name"] - assert "get-version-edp" == btedp[2]["taskRef"]["name"] - assert "update-build-number" in btedp[3]["taskRef"]["name"] - assert f"update-build-number-{buildtool}" == btedp[3]["taskRef"]["name"] - assert "sast" in btedp[4]["name"] - assert "npm-init" in btedp[5]["name"] - assert "compile" in btedp[6]["name"] - assert buildtool == btedp[6]["taskRef"]["name"] - assert "test" in btedp[7]["name"] - assert buildtool == btedp[7]["taskRef"]["name"] - assert "sonar" in btedp[8]["name"] - assert "sonarqube-scanner" == btedp[8]["taskRef"]["name"] - assert "build" in btedp[9]["name"] - assert buildtool == btedp[9]["taskRef"]["name"] - assert "get-nexus-repository-url" in btedp[10]["name"] - assert "get-nexus-repository-url" == btedp[10]["taskRef"]["name"] - assert "push" in btedp[11]["name"] - assert "npm" == btedp[11]["taskRef"]["name"] - if cbtype == "app": - assert "create-ecr-repository" in btedp[12]["name"] - assert "kaniko-build" in btedp[13]["name"] - assert "git-tag" in btedp[14]["name"] - assert "update-cbis" in btedp[15]["name"] - if cbtype == "lib": - assert "git-tag" in btedp[12]["name"] - assert "update-cbb" in r["pipeline"][github_build_pipeline_edp]["spec"]["finally"][0]["name"] - assert "push-to-jira" in r["pipeline"][github_build_pipeline_edp]["spec"]["finally"][1]["name"] - - -def test_javascript_pipelines_gitlab(): - config = """ -global: - gitProvider: gitlab - dockerRegistry: - type: "ecr" - """ - - r = helm_template(config) - vcs = "gitlab" - - # ensure pipelines have proper steps - for buildtool in ['npm']: - for framework in ['react', 'angular', 'vue', 'express', 'next']: - for cbtype in ['app', 'lib']: - - gitlab_review_pipeline = f"{vcs}-{buildtool}-{framework}-{cbtype}-review" - gitlab_build_pipeline_def = f"{vcs}-{buildtool}-{framework}-{cbtype}-build-default" - gitlab_build_pipeline_edp = f"{vcs}-{buildtool}-{framework}-{cbtype}-build-edp" - - assert gitlab_review_pipeline in r["pipeline"] - assert gitlab_build_pipeline_def in r["pipeline"] - assert gitlab_build_pipeline_edp in r["pipeline"] - - rt = r["pipeline"][gitlab_review_pipeline]["spec"]["tasks"] - if cbtype == "lib": - assert "report-pipeline-start-to-gitlab" in rt[0]["name"] - assert "fetch-repository" in rt[1]["name"] - assert "init-values" in rt[2]["name"] - assert "npm-init" in rt[3]["name"] - assert "build" in rt[4]["name"] - assert "test" in rt[5]["name"] - assert "sonar" in rt[6]["name"] - if cbtype == "app": - assert "report-pipeline-start-to-gitlab" in rt[0]["name"] - assert "fetch-repository" in rt[1]["name"] - assert "init-values" in rt[2]["name"] - assert "helm-docs" in rt[3]["name"] - assert "npm-init" in rt[4]["name"] - assert "build" in rt[5]["name"] - assert "test" in rt[6]["name"] - assert "sonar" in rt[7]["name"] - assert "dockerfile-lint" in rt[8]["name"] - assert "dockerbuild-verify" in rt[9]["name"] - assert "helm-lint" in rt[10]["name"] - - assert "gitlab-set-success-status" in r["pipeline"][gitlab_review_pipeline]["spec"]["finally"][0]["name"] - assert "gitlab-set-failure-status" in r["pipeline"][gitlab_review_pipeline]["spec"]["finally"][1]["name"] - - # build with default versioning - btd = r["pipeline"][gitlab_build_pipeline_def]["spec"]["tasks"] - assert "fetch-repository" in btd[0]["name"] - assert "init-values" in btd[1]["name"] - # ensure we have default versioning - assert "get-version" in btd[2]["name"] - assert f"get-version-default" == btd[2]["taskRef"]["name"] - assert "update-build-number" in btd[3]["name"] - assert "sast" in btd[4]["name"] - assert "npm-init" in btd[5]["name"] - assert "compile" in btd[6]["name"] - assert "test" in btd[7]["name"] - assert buildtool == btd[7]["taskRef"]["name"] - assert "sonar" in btd[8]["name"] - assert "sonarqube-scanner" == btd[8]["taskRef"]["name"] - assert "build" in btd[9]["name"] - assert buildtool == btd[9]["taskRef"]["name"] - assert "get-nexus-repository-url" in btd[10]["name"] - assert "get-nexus-repository-url" == btd[10]["taskRef"]["name"] - assert "push" in btd[11]["name"] - assert "npm" == btd[11]["taskRef"]["name"] - if cbtype == "app": - assert "create-ecr-repository" in btd[12]["name"] - assert "kaniko-build" in btd[13]["name"] - assert "git-tag" in btd[14]["name"] - assert "update-cbis" in btd[15]["name"] - if cbtype == "lib": - assert "git-tag" in btd[12]["name"] - assert "push-to-jira" in r["pipeline"][gitlab_build_pipeline_def]["spec"]["finally"][0]["name"] - - # build with edp versioning - btedp = r["pipeline"][gitlab_build_pipeline_edp]["spec"]["tasks"] - assert "fetch-repository" in btedp[0]["name"] - assert "init-values" in btedp[1]["name"] - assert "get-version" in btedp[2]["name"] - assert "get-version-edp" == btedp[2]["taskRef"]["name"] - assert "update-build-number" in btedp[3]["taskRef"]["name"] - assert f"update-build-number-{buildtool}" == btedp[3]["taskRef"]["name"] - assert "sast" in btedp[4]["name"] - assert "npm-init" in btedp[5]["name"] - assert "compile" in btedp[6]["name"] - assert buildtool == btedp[6]["taskRef"]["name"] - assert "test" in btedp[7]["name"] - assert buildtool == btedp[7]["taskRef"]["name"] - assert "sonar" in btedp[8]["name"] - assert "sonarqube-scanner" == btedp[8]["taskRef"]["name"] - assert "build" in btedp[9]["name"] - assert buildtool == btedp[9]["taskRef"]["name"] - assert "get-nexus-repository-url" in btedp[10]["name"] - assert "get-nexus-repository-url" == btedp[10]["taskRef"]["name"] - assert "push" in btedp[11]["name"] - assert "npm" == btedp[11]["taskRef"]["name"] - if cbtype == "app": - assert "create-ecr-repository" in btedp[12]["name"] - assert "kaniko-build" in btedp[13]["name"] - assert "git-tag" in btedp[14]["name"] - assert "update-cbis" in btedp[15]["name"] - if cbtype == "lib": - assert "git-tag" in btedp[12]["name"] - assert "update-cbb" in r["pipeline"][gitlab_build_pipeline_edp]["spec"]["finally"][0]["name"] - assert "push-to-jira" in r["pipeline"][gitlab_build_pipeline_edp]["spec"]["finally"][1]["name"] - - def test_javascript_pipelines_harbor_gerrit(): config = """ global: gitProvider: gerrit - dockerRegistry: - type: "harbor" """ r = helm_template(config) @@ -469,8 +122,6 @@ def test_javascript_pipelines_harbor_github(): config = """ global: gitProvider: github - dockerRegistry: - type: "harbor" """ r = helm_template(config) @@ -581,8 +232,6 @@ def test_javascript_pipelines_harbor_gitlab(): config = """ global: gitProvider: gitlab - dockerRegistry: - type: "harbor" """ r = helm_template(config) diff --git a/charts/pipelines-library/tests/test_python_pipelines.py b/charts/pipelines-library/tests/test_python_pipelines.py index d2b0dbd1..f1fcd751 100644 --- a/charts/pipelines-library/tests/test_python_pipelines.py +++ b/charts/pipelines-library/tests/test_python_pipelines.py @@ -1,877 +1,10 @@ from .helpers import helm_template -def test_python_pipelines_gerrit(): - config = """ -global: - gitProvider: gerrit - dockerRegistry: - type: "ecr" - """ - - r = helm_template(config) - - # ensure pipelines have proper steps - for buildtool in ['python']: - for framework in ['python-3.8']: - for cbtype in ['app', 'lib']: - - assert f"gerrit-{buildtool}-{framework}-{cbtype}-review" in r["pipeline"] - assert f"gerrit-{buildtool}-{framework}-{cbtype}-build-default" in r["pipeline"] - assert f"gerrit-{buildtool}-{framework}-{cbtype}-build-edp" in r["pipeline"] - - gerrit_review_pipeline = f"gerrit-{buildtool}-{framework}-{cbtype}-review" - gerrit_build_pipeline_def = f"gerrit-{buildtool}-{framework}-{cbtype}-build-default" - gerrit_build_pipeline_edp = f"gerrit-{buildtool}-{framework}-{cbtype}-build-edp" - - rt = r["pipeline"][gerrit_review_pipeline]["spec"]["tasks"] - if cbtype == "lib": - assert "fetch-repository" in rt[0]["name"] - assert "gerrit-notify" in rt[1]["name"] - assert "init-values" in rt[2]["name"] - assert "compile" in rt[3]["name"] - assert "test" in rt[4]["name"] - assert "fetch-target-branch" in rt[5]["name"] - assert "sonar-prepare-files" in rt[6]["name"] - assert "sonar-prepare-files-general" == rt[6]["taskRef"]["name"] - assert "sonar" in rt[7]["name"] - if cbtype == "app": - assert "fetch-repository" in rt[0]["name"] - assert "gerrit-notify" in rt[1]["name"] - assert "init-values" in rt[2]["name"] - assert "helm-docs" in rt[3]["name"] - assert "compile" in rt[4]["name"] - assert "test" in rt[5]["name"] - assert "fetch-target-branch" in rt[6]["name"] - assert "sonar-prepare-files" in rt[7]["name"] - assert "sonar-prepare-files-general" == rt[7]["taskRef"]["name"] - assert "sonar" in rt[8]["name"] - assert "dockerfile-lint" in rt[9]["name"] - assert "dockerbuild-verify" in rt[10]["name"] - assert "helm-lint" in rt[11]["name"] - - assert "gerrit-vote-success" in r["pipeline"][gerrit_review_pipeline]["spec"]["finally"][0]["name"] - assert "gerrit-vote-failure" in r["pipeline"][gerrit_review_pipeline]["spec"]["finally"][1]["name"] - - # build with default versioning - btd = r["pipeline"][gerrit_build_pipeline_def]["spec"]["tasks"] - assert "fetch-repository" in btd[0]["name"] - assert "gerrit-notify" in btd[1]["name"] - assert "init-values" in btd[2]["name"] - assert "get-version" in btd[3]["name"] - # ensure we have default versioning - assert f"get-version-default" == btd[3]["taskRef"]["name"] - assert "update-build-number" in btd[4]["name"] - assert "sonar-cleanup" in btd[5]["name"] - assert "sast" in btd[6]["name"] - assert "compile" in btd[7]["name"] - assert "test" in btd[8]["name"] - assert buildtool == btd[8]["taskRef"]["name"] - assert "sonar" in btd[9]["name"] - assert "sonarqube-scanner" == btd[9]["taskRef"]["name"] - assert "get-nexus-repository-url" in btd[10]["name"] - assert "get-nexus-repository-url" == btd[10]["taskRef"]["name"] - assert "push" in btd[11]["name"] - assert buildtool == btd[11]["taskRef"]["name"] - if cbtype == "app": - assert "create-ecr-repository" in btd[12]["name"] - assert "kaniko-build" in btd[13]["name"] - assert "git-tag" in btd[14]["name"] - assert "update-cbis" in btd[15]["name"] - if cbtype == "lib": - assert "git-tag" in btd[12]["name"] - assert "push-to-jira" in r["pipeline"][gerrit_build_pipeline_def]["spec"]["finally"][0]["name"] - - # build with edp versioning - btedp = r["pipeline"][gerrit_build_pipeline_edp]["spec"]["tasks"] - assert "fetch-repository" in btedp[0]["name"] - assert "gerrit-notify" in btedp[1]["name"] - assert "init-values" in btedp[2]["name"] - assert "get-version" in btedp[3]["name"] - assert "get-version-edp" == btedp[3]["taskRef"]["name"] - assert "update-build-number" in btedp[4]["taskRef"]["name"] - assert f"update-build-number-{buildtool}" == btedp[4]["taskRef"]["name"] - assert "sonar-cleanup" in btedp[5]["name"] - assert "sast" in btedp[6]["name"] - assert "compile" in btedp[7]["name"] - assert buildtool == btedp[7]["taskRef"]["name"] - assert "test" in btedp[8]["name"] - assert buildtool == btedp[8]["taskRef"]["name"] - assert "sonar" in btedp[9]["name"] - assert "sonarqube-scanner" == btedp[9]["taskRef"]["name"] - assert "get-nexus-repository-url" in btedp[10]["name"] - assert "get-nexus-repository-url" == btedp[10]["taskRef"]["name"] - assert "push" in btedp[11]["name"] - assert buildtool == btedp[11]["taskRef"]["name"] - if cbtype == "app": - assert "create-ecr-repository" in btedp[12]["name"] - assert "kaniko-build" in btedp[13]["name"] - assert "git-tag" in btedp[14]["name"] - assert "update-cbis" in btedp[15]["name"] - if cbtype == "lib": - assert "git-tag" in btedp[12]["name"] - assert "update-cbb" in r["pipeline"][gerrit_build_pipeline_edp]["spec"]["finally"][0]["name"] - assert "push-to-jira" in r["pipeline"][gerrit_build_pipeline_edp]["spec"]["finally"][1]["name"] - - -def test_python_pipelines_github(): - config = """ -global: - gitProvider: github - dockerRegistry: - type: "ecr" - """ - - r = helm_template(config) - vcs = "github" - - # ensure pipelines have proper steps - for buildtool in ['python']: - for framework in ['python-3.8']: - for cbtype in ['app', 'lib']: - - github_review_pipeline = f"{vcs}-{buildtool}-{framework}-{cbtype}-review" - github_build_pipeline_def = f"{vcs}-{buildtool}-{framework}-{cbtype}-build-default" - github_build_pipeline_edp = f"{vcs}-{buildtool}-{framework}-{cbtype}-build-edp" - - assert github_review_pipeline in r["pipeline"] - assert github_build_pipeline_def in r["pipeline"] - assert github_build_pipeline_edp in r["pipeline"] - - rt = r["pipeline"][github_review_pipeline]["spec"]["tasks"] - if cbtype == "lib": - assert "github-set-pending-status" in rt[0]["name"] - assert "fetch-repository" in rt[1]["name"] - assert "init-values" in rt[2]["name"] - assert "compile" in rt[3]["name"] - assert "test" in rt[4]["name"] - assert "sonar" in rt[5]["name"] - if cbtype == "app": - assert "github-set-pending-status" in rt[0]["name"] - assert "fetch-repository" in rt[1]["name"] - assert "init-values" in rt[2]["name"] - assert "helm-docs" in rt[3]["name"] - assert "compile" in rt[4]["name"] - assert "test" in rt[5]["name"] - assert "sonar" in rt[6]["name"] - assert "dockerfile-lint" in rt[7]["name"] - assert "dockerbuild-verify" in rt[8]["name"] - assert "helm-lint" in rt[9]["name"] - - assert "github-set-success-status" in r["pipeline"][github_review_pipeline]["spec"]["finally"][0]["name"] - assert "github-set-failure-status" in r["pipeline"][github_review_pipeline]["spec"]["finally"][1]["name"] - - # build with default versioning - btd = r["pipeline"][github_build_pipeline_def]["spec"]["tasks"] - assert "fetch-repository" in btd[0]["name"] - assert "init-values" in btd[1]["name"] - assert "get-version" in btd[2]["name"] - assert f"get-version-default" == btd[2]["taskRef"]["name"] - assert "update-build-number" in btd[3]["name"] - assert "sast" in btd[4]["name"] - assert "compile" in btd[5]["name"] - assert "test" in btd[6]["name"] - assert buildtool == btd[6]["taskRef"]["name"] - assert "sonar" in btd[7]["name"] - assert "sonarqube-scanner" == btd[7]["taskRef"]["name"] - assert "get-nexus-repository-url" in btd[8]["name"] - assert "get-nexus-repository-url" == btd[8]["taskRef"]["name"] - assert "push" in btd[9]["name"] - assert buildtool == btd[9]["taskRef"]["name"] - if cbtype == "app": - assert "create-ecr-repository" in btd[10]["name"] - assert "kaniko-build" in btd[11]["name"] - assert "git-tag" in btd[12]["name"] - assert "update-cbis" in btd[13]["name"] - if cbtype == "lib": - assert "git-tag" in btd[10]["name"] - assert "push-to-jira" in r["pipeline"][github_build_pipeline_def]["spec"]["finally"][0]["name"] - - # build with edp versioning - btedp = r["pipeline"][github_build_pipeline_edp]["spec"]["tasks"] - assert "fetch-repository" in btedp[0]["name"] - assert "init-values" in btedp[1]["name"] - assert "get-version" in btedp[2]["name"] - assert "get-version-edp" == btedp[2]["taskRef"]["name"] - assert "update-build-number" in btedp[3]["taskRef"]["name"] - assert f"update-build-number-{buildtool}" == btedp[3]["taskRef"]["name"] - assert "sast" in btedp[4]["name"] - assert "compile" in btedp[5]["name"] - assert buildtool == btedp[5]["taskRef"]["name"] - assert "test" in btedp[6]["name"] - assert buildtool == btedp[6]["taskRef"]["name"] - assert "sonar" in btedp[7]["name"] - assert "sonarqube-scanner" == btedp[7]["taskRef"]["name"] - assert "get-nexus-repository-url" in btedp[8]["name"] - assert "get-nexus-repository-url" == btedp[8]["taskRef"]["name"] - assert "push" in btedp[9]["name"] - assert buildtool == btedp[9]["taskRef"]["name"] - if cbtype == "app": - assert "create-ecr-repository" in btedp[10]["name"] - assert "kaniko-build" in btedp[11]["name"] - assert "git-tag" in btedp[12]["name"] - assert "update-cbis" in btedp[13]["name"] - if cbtype == "lib": - assert "git-tag" in btedp[10]["name"] - assert "update-cbb" in r["pipeline"][github_build_pipeline_edp]["spec"]["finally"][0]["name"] - assert "push-to-jira" in r["pipeline"][github_build_pipeline_edp]["spec"]["finally"][1]["name"] - - -def test_python_pipelines_gitlab(): - config = """ -global: - gitProvider: gitlab - dockerRegistry: - type: "ecr" - """ - - r = helm_template(config) - vcs = "gitlab" - - # ensure pipelines have proper steps - for buildtool in ['python']: - for framework in ['python-3.8']: - for cbtype in ['app', 'lib']: - - gitlab_review_pipeline = f"{vcs}-{buildtool}-{framework}-{cbtype}-review" - gitlab_build_pipeline_def = f"{vcs}-{buildtool}-{framework}-{cbtype}-build-default" - gitlab_build_pipeline_edp = f"{vcs}-{buildtool}-{framework}-{cbtype}-build-edp" - - assert gitlab_review_pipeline in r["pipeline"] - assert gitlab_build_pipeline_def in r["pipeline"] - assert gitlab_build_pipeline_edp in r["pipeline"] - - rt = r["pipeline"][gitlab_review_pipeline]["spec"]["tasks"] - if cbtype == "lib": - assert "report-pipeline-start-to-gitlab" in rt[0]["name"] - assert "fetch-repository" in rt[1]["name"] - assert "init-values" in rt[2]["name"] - assert "compile" in rt[3]["name"] - assert "test" in rt[4]["name"] - assert "sonar" in rt[5]["name"] - if cbtype == "app": - assert "report-pipeline-start-to-gitlab" in rt[0]["name"] - assert "fetch-repository" in rt[1]["name"] - assert "init-values" in rt[2]["name"] - assert "helm-docs" in rt[3]["name"] - assert "compile" in rt[4]["name"] - assert "test" in rt[5]["name"] - assert "sonar" in rt[6]["name"] - assert "dockerfile-lint" in rt[7]["name"] - assert "dockerbuild-verify" in rt[8]["name"] - assert "helm-lint" in rt[9]["name"] - - assert "gitlab-set-success-status" in r["pipeline"][gitlab_review_pipeline]["spec"]["finally"][0]["name"] - assert "gitlab-set-failure-status" in r["pipeline"][gitlab_review_pipeline]["spec"]["finally"][1]["name"] - - # build with default versioning - btd = r["pipeline"][gitlab_build_pipeline_def]["spec"]["tasks"] - assert "fetch-repository" in btd[0]["name"] - assert "init-values" in btd[1]["name"] - assert "get-version" in btd[2]["name"] - assert f"get-version-default" == btd[2]["taskRef"]["name"] - assert "update-build-number" in btd[3]["name"] - assert "sast" in btd[4]["name"] - assert "compile" in btd[5]["name"] - assert "test" in btd[6]["name"] - assert buildtool == btd[6]["taskRef"]["name"] - assert "sonar" in btd[7]["name"] - assert "sonarqube-scanner" == btd[7]["taskRef"]["name"] - assert "get-nexus-repository-url" in btd[8]["name"] - assert "get-nexus-repository-url" == btd[8]["taskRef"]["name"] - assert "push" in btd[9]["name"] - assert buildtool == btd[9]["taskRef"]["name"] - if cbtype == "app": - assert "create-ecr-repository" in btd[10]["name"] - assert "kaniko-build" in btd[11]["name"] - assert "git-tag" in btd[12]["name"] - assert "update-cbis" in btd[13]["name"] - if cbtype == "lib": - assert "git-tag" in btd[10]["name"] - assert "push-to-jira" in r["pipeline"][gitlab_build_pipeline_def]["spec"]["finally"][0]["name"] - - # build with edp versioning - btedp = r["pipeline"][gitlab_build_pipeline_edp]["spec"]["tasks"] - assert "fetch-repository" in btedp[0]["name"] - assert "init-values" in btedp[1]["name"] - assert "get-version" in btedp[2]["name"] - assert "get-version-edp" == btedp[2]["taskRef"]["name"] - assert "update-build-number" in btedp[3]["taskRef"]["name"] - assert f"update-build-number-{buildtool}" == btedp[3]["taskRef"]["name"] - assert "sast" in btedp[4]["name"] - assert "compile" in btedp[5]["name"] - assert buildtool == btedp[5]["taskRef"]["name"] - assert "test" in btedp[6]["name"] - assert buildtool == btedp[6]["taskRef"]["name"] - assert "sonar" in btedp[7]["name"] - assert "sonarqube-scanner" == btedp[7]["taskRef"]["name"] - assert "get-nexus-repository-url" in btedp[8]["name"] - assert "get-nexus-repository-url" == btedp[8]["taskRef"]["name"] - assert "push" in btedp[9]["name"] - assert buildtool == btedp[9]["taskRef"]["name"] - if cbtype == "app": - assert "create-ecr-repository" in btedp[10]["name"] - assert "kaniko-build" in btedp[11]["name"] - assert "git-tag" in btedp[12]["name"] - assert "update-cbis" in btedp[13]["name"] - if cbtype == "lib": - assert "git-tag" in btedp[10]["name"] - assert "update-cbb" in r["pipeline"][gitlab_build_pipeline_edp]["spec"]["finally"][0]["name"] - assert "push-to-jira" in r["pipeline"][gitlab_build_pipeline_edp]["spec"]["finally"][1]["name"] - - -# FastApi -def test_python_fastapi_pipelines_gerrit(): - config = """ -global: - gitProvider: gerrit - dockerRegistry: - type: "ecr" - """ - - ht = helm_template(config) - - buildtool = "python" - framework = "fastapi" - - review = f"gerrit-{buildtool}-{framework}-app-review" - build_default = f"gerrit-{buildtool}-{framework}-app-build-default" - build_edp = f"gerrit-{buildtool}-{framework}-app-build-edp" - - assert review in ht["pipeline"] - assert build_default in ht["pipeline"] - assert build_edp in ht["pipeline"] - - r = ht["pipeline"][review]["spec"]["tasks"] - assert "fetch-repository" in r[0]["name"] - assert "gerrit-notify" in r[1]["name"] - assert "init-values" in r[2]["name"] - assert "helm-docs" in r[3]["name"] - assert "test" in r[4]["name"] - assert "lint" in r[5]["name"] - assert "fetch-target-branch" in r[6]["name"] - assert "sonar-prepare-files" in r[7]["name"] - assert "sonar-prepare-files-general" == r[7]["taskRef"]["name"] - assert "sonar" in r[8]["name"] - assert "dockerfile-lint" in r[9]["name"] - assert "dockerbuild-verify" in r[10]["name"] - assert "helm-lint" in r[11]["name"] - assert "gerrit-vote-success" in ht["pipeline"][review]["spec"]["finally"][0]["name"] - assert "gerrit-vote-failure" in ht["pipeline"][review]["spec"]["finally"][1]["name"] - - # build with default versioning - bd = ht["pipeline"][build_default]["spec"]["tasks"] - assert "fetch-repository" in bd[0]["name"] - assert "gerrit-notify" in bd[1]["name"] - assert "init-values" in bd[2]["name"] - assert "get-version" in bd[3]["name"] - assert f"get-version-default" == bd[3]["taskRef"]["name"] - assert "update-build-number" in bd[4]["name"] - assert "sonar-cleanup" in bd[5]["name"] - assert "test" in bd[6]["name"] - assert buildtool == bd[6]["taskRef"]["name"] - assert "lint" in bd[7]["name"] - assert buildtool == bd[7]["taskRef"]["name"] - assert "sast" in bd[8]["name"] - assert "compile" in bd[9]["name"] - assert buildtool == bd[9]["taskRef"]["name"] - assert "sonar" in bd[10]["name"] - assert "sonarqube-scanner" == bd[10]["taskRef"]["name"] - assert "get-nexus-repository-url" in bd[11]["name"] - assert "get-nexus-repository-url" == bd[11]["taskRef"]["name"] - assert "push" in bd[12]["name"] - assert buildtool == bd[12]["taskRef"]["name"] - assert "create-ecr-repository" in bd[13]["name"] - assert "kaniko-build" in bd[14]["name"] - assert "git-tag" in bd[15]["name"] - assert "update-cbis" in bd[16]["name"] - assert "push-to-jira" in ht["pipeline"][build_default]["spec"]["finally"][0]["name"] - - # build with edp versioning - bedp = ht["pipeline"][build_edp]["spec"]["tasks"] - assert "fetch-repository" in bedp[0]["name"] - assert "gerrit-notify" in bedp[1]["name"] - assert "init-values" in bedp[2]["name"] - assert "get-version" in bedp[3]["name"] - assert "get-version-edp" == bedp[3]["taskRef"]["name"] - assert "update-build-number" in bedp[4]["taskRef"]["name"] - assert f"update-build-number-{buildtool}" == bedp[4]["taskRef"]["name"] - assert "sonar-cleanup" in bedp[5]["name"] - assert "test" in bedp[6]["name"] - assert buildtool == bedp[6]["taskRef"]["name"] - assert "lint" in bedp[7]["name"] - assert buildtool == bedp[7]["taskRef"]["name"] - assert "sast" in bedp[8]["name"] - assert "compile" in bedp[9]["name"] - assert buildtool == bedp[9]["taskRef"]["name"] - assert "sonar" in bedp[10]["name"] - assert "sonarqube-scanner" == bedp[10]["taskRef"]["name"] - assert "get-nexus-repository-url" in bedp[11]["name"] - assert "get-nexus-repository-url" == bedp[11]["taskRef"]["name"] - assert "push" in bedp[12]["name"] - assert buildtool == bedp[12]["taskRef"]["name"] - assert "create-ecr-repository" in bedp[13]["name"] - assert "kaniko-build" in bedp[14]["name"] - assert "git-tag" in bedp[15]["name"] - assert "update-cbis" in bedp[16]["name"] - assert "update-cbb" in ht["pipeline"][build_edp]["spec"]["finally"][0]["name"] - assert "push-to-jira" in ht["pipeline"][build_edp]["spec"]["finally"][1]["name"] - - -# Flask -def test_python_flask_pipelines_gerrit(): - config = """ -global: - gitProvider: gerrit - dockerRegistry: - type: "ecr" - """ - - ht = helm_template(config) - - buildtool = "python" - framework = "flask" - - review = f"gerrit-{buildtool}-{framework}-app-review" - build_default = f"gerrit-{buildtool}-{framework}-app-build-default" - build_edp = f"gerrit-{buildtool}-{framework}-app-build-edp" - - assert review in ht["pipeline"] - assert build_default in ht["pipeline"] - assert build_edp in ht["pipeline"] - - r = ht["pipeline"][review]["spec"]["tasks"] - assert "fetch-repository" in r[0]["name"] - assert "gerrit-notify" in r[1]["name"] - assert "init-values" in r[2]["name"] - assert "helm-docs" in r[3]["name"] - assert "test" in r[4]["name"] - assert "lint" in r[5]["name"] - assert "fetch-target-branch" in r[6]["name"] - assert "sonar-prepare-files" in r[7]["name"] - assert "sonar-prepare-files-general" == r[7]["taskRef"]["name"] - assert "sonar" in r[8]["name"] - assert "dockerfile-lint" in r[9]["name"] - assert "dockerbuild-verify" in r[10]["name"] - assert "helm-lint" in r[11]["name"] - assert "gerrit-vote-success" in ht["pipeline"][review]["spec"]["finally"][0]["name"] - assert "gerrit-vote-failure" in ht["pipeline"][review]["spec"]["finally"][1]["name"] - - # build with default versioning - bd = ht["pipeline"][build_default]["spec"]["tasks"] - assert "fetch-repository" in bd[0]["name"] - assert "gerrit-notify" in bd[1]["name"] - assert "init-values" in bd[2]["name"] - assert "get-version" in bd[3]["name"] - assert f"get-version-default" == bd[3]["taskRef"]["name"] - assert "update-build-number" in bd[4]["name"] - assert "sonar-cleanup" in bd[5]["name"] - assert "test" in bd[6]["name"] - assert buildtool == bd[6]["taskRef"]["name"] - assert "lint" in bd[7]["name"] - assert buildtool == bd[7]["taskRef"]["name"] - assert "sast" in bd[8]["name"] - assert "compile" in bd[9]["name"] - assert buildtool == bd[9]["taskRef"]["name"] - assert "sonar" in bd[10]["name"] - assert "sonarqube-scanner" == bd[10]["taskRef"]["name"] - assert "get-nexus-repository-url" in bd[11]["name"] - assert "get-nexus-repository-url" == bd[11]["taskRef"]["name"] - assert "push" in bd[12]["name"] - assert buildtool == bd[12]["taskRef"]["name"] - assert "create-ecr-repository" in bd[13]["name"] - assert "kaniko-build" in bd[14]["name"] - assert "git-tag" in bd[15]["name"] - assert "update-cbis" in bd[16]["name"] - assert "push-to-jira" in ht["pipeline"][build_default]["spec"]["finally"][0]["name"] - - # build with edp versioning - bedp = ht["pipeline"][build_edp]["spec"]["tasks"] - assert "fetch-repository" in bedp[0]["name"] - assert "gerrit-notify" in bedp[1]["name"] - assert "init-values" in bedp[2]["name"] - assert "get-version" in bedp[3]["name"] - assert "get-version-edp" == bedp[3]["taskRef"]["name"] - assert "update-build-number" in bedp[4]["taskRef"]["name"] - assert f"update-build-number-{buildtool}" == bedp[4]["taskRef"]["name"] - assert "sonar-cleanup" in bedp[5]["name"] - assert "test" in bedp[6]["name"] - assert buildtool == bedp[6]["taskRef"]["name"] - assert "lint" in bedp[7]["name"] - assert buildtool == bedp[7]["taskRef"]["name"] - assert "sast" in bedp[8]["name"] - assert "compile" in bedp[9]["name"] - assert buildtool == bedp[9]["taskRef"]["name"] - assert "sonar" in bedp[10]["name"] - assert "sonarqube-scanner" == bedp[10]["taskRef"]["name"] - assert "get-nexus-repository-url" in bedp[11]["name"] - assert "get-nexus-repository-url" == bedp[11]["taskRef"]["name"] - assert "push" in bedp[12]["name"] - assert buildtool == bedp[12]["taskRef"]["name"] - assert "create-ecr-repository" in bedp[13]["name"] - assert "kaniko-build" in bedp[14]["name"] - assert "git-tag" in bedp[15]["name"] - assert "update-cbis" in bedp[16]["name"] - assert "update-cbb" in ht["pipeline"][build_edp]["spec"]["finally"][0]["name"] - assert "push-to-jira" in ht["pipeline"][build_edp]["spec"]["finally"][1]["name"] - - -def test_python_flask_pipelines_gitlab(): - config = """ -global: - gitProvider: gitlab - dockerRegistry: - type: "ecr" - """ - - ht = helm_template(config) - - buildtool = "python" - framework = "flask" - - review = f"gitlab-{buildtool}-{framework}-app-review" - build_default = f"gitlab-{buildtool}-{framework}-app-build-default" - build_edp = f"gitlab-{buildtool}-{framework}-app-build-edp" - - assert review in ht["pipeline"] - assert build_default in ht["pipeline"] - assert build_edp in ht["pipeline"] - - r = ht["pipeline"][review]["spec"]["tasks"] - assert "report-pipeline-start-to-gitlab" in r[0]["name"] - assert "fetch-repository" in r[1]["name"] - assert "init-values" in r[2]["name"] - assert "helm-docs" in r[3]["name"] - assert "test" in r[4]["name"] - assert "lint" in r[5]["name"] - assert "sonar" in r[6]["name"] - assert "dockerfile-lint" in r[7]["name"] - assert "dockerbuild-verify" in r[8]["name"] - assert "helm-lint" in r[9]["name"] - assert "gitlab-set-success-status" in ht["pipeline"][review]["spec"]["finally"][0]["name"] - assert "gitlab-set-failure-status" in ht["pipeline"][review]["spec"]["finally"][1]["name"] - - # build with default versioning - bd = ht["pipeline"][build_default]["spec"]["tasks"] - assert "fetch-repository" in bd[0]["name"] - assert "init-values" in bd[1]["name"] - assert "get-version" in bd[2]["name"] - assert f"get-version-default" == bd[2]["taskRef"]["name"] - assert "update-build-number" in bd[3]["name"] - assert "test" in bd[4]["name"] - assert buildtool == bd[4]["taskRef"]["name"] - assert "lint" in bd[5]["name"] - assert buildtool == bd[5]["taskRef"]["name"] - assert "sast" in bd[6]["name"] - assert "compile" in bd[7]["name"] - assert buildtool == bd[7]["taskRef"]["name"] - assert "sonar" in bd[8]["name"] - assert "sonarqube-scanner" == bd[8]["taskRef"]["name"] - assert "get-nexus-repository-url" in bd[9]["name"] - assert "get-nexus-repository-url" == bd[9]["taskRef"]["name"] - assert "push" in bd[10]["name"] - assert buildtool == bd[10]["taskRef"]["name"] - assert "create-ecr-repository" in bd[11]["name"] - assert "kaniko-build" in bd[12]["name"] - assert "git-tag" in bd[13]["name"] - assert "update-cbis" in bd[14]["name"] - assert "push-to-jira" in ht["pipeline"][build_default]["spec"]["finally"][0]["name"] - - # build with edp versioning - bedp = ht["pipeline"][build_edp]["spec"]["tasks"] - assert "fetch-repository" in bedp[0]["name"] - assert "init-values" in bedp[1]["name"] - assert "get-version" in bedp[2]["name"] - assert "get-version-edp" == bedp[2]["taskRef"]["name"] - assert "update-build-number" in bedp[3]["taskRef"]["name"] - assert f"update-build-number-{buildtool}" == bedp[3]["taskRef"]["name"] - assert "sast" in bedp[6]["name"] - assert "compile" in bedp[7]["name"] - assert buildtool == bedp[7]["taskRef"]["name"] - assert "sonar" in bedp[8]["name"] - assert "sonarqube-scanner" == bedp[8]["taskRef"]["name"] - assert "get-nexus-repository-url" in bedp[9]["name"] - assert "get-nexus-repository-url" == bedp[9]["taskRef"]["name"] - assert "push" in bedp[10]["name"] - assert buildtool == bedp[10]["taskRef"]["name"] - assert "create-ecr-repository" in bedp[11]["name"] - assert "kaniko-build" in bedp[12]["name"] - assert "git-tag" in bedp[13]["name"] - assert "update-cbis" in bedp[14]["name"] - assert "update-cbb" in ht["pipeline"][build_edp]["spec"]["finally"][0]["name"] - assert "push-to-jira" in ht["pipeline"][build_edp]["spec"]["finally"][1]["name"] - - -def test_python_fastapi_pipelines_gitlab(): - config = """ -global: - gitProvider: gitlab - dockerRegistry: - type: "ecr" - """ - - ht = helm_template(config) - - buildtool = "python" - framework = "fastapi" - - review = f"gitlab-{buildtool}-{framework}-app-review" - build_default = f"gitlab-{buildtool}-{framework}-app-build-default" - build_edp = f"gitlab-{buildtool}-{framework}-app-build-edp" - - assert review in ht["pipeline"] - assert build_default in ht["pipeline"] - assert build_edp in ht["pipeline"] - - r = ht["pipeline"][review]["spec"]["tasks"] - assert "report-pipeline-start-to-gitlab" in r[0]["name"] - assert "fetch-repository" in r[1]["name"] - assert "init-values" in r[2]["name"] - assert "helm-docs" in r[3]["name"] - assert "test" in r[4]["name"] - assert "lint" in r[5]["name"] - assert "sonar" in r[6]["name"] - assert "dockerfile-lint" in r[7]["name"] - assert "dockerbuild-verify" in r[8]["name"] - assert "helm-lint" in r[9]["name"] - assert "gitlab-set-success-status" in ht["pipeline"][review]["spec"]["finally"][0]["name"] - assert "gitlab-set-failure-status" in ht["pipeline"][review]["spec"]["finally"][1]["name"] - - # build with default versioning - bd = ht["pipeline"][build_default]["spec"]["tasks"] - assert "fetch-repository" in bd[0]["name"] - assert "init-values" in bd[1]["name"] - assert "get-version" in bd[2]["name"] - assert f"get-version-default" == bd[2]["taskRef"]["name"] - assert "update-build-number" in bd[3]["name"] - assert "test" in bd[4]["name"] - assert buildtool == bd[4]["taskRef"]["name"] - assert "lint" in bd[5]["name"] - assert buildtool == bd[5]["taskRef"]["name"] - assert "sast" in bd[6]["name"] - assert "compile" in bd[7]["name"] - assert buildtool == bd[7]["taskRef"]["name"] - assert "sonar" in bd[8]["name"] - assert "sonarqube-scanner" == bd[8]["taskRef"]["name"] - assert "get-nexus-repository-url" in bd[9]["name"] - assert "get-nexus-repository-url" == bd[9]["taskRef"]["name"] - assert "push" in bd[10]["name"] - assert buildtool == bd[10]["taskRef"]["name"] - assert "create-ecr-repository" in bd[11]["name"] - assert "kaniko-build" in bd[12]["name"] - assert "git-tag" in bd[13]["name"] - assert "update-cbis" in bd[14]["name"] - assert "push-to-jira" in ht["pipeline"][build_default]["spec"]["finally"][0]["name"] - - # build with edp versioning - bedp = ht["pipeline"][build_edp]["spec"]["tasks"] - assert "fetch-repository" in bedp[0]["name"] - assert "init-values" in bedp[1]["name"] - assert "get-version" in bedp[2]["name"] - assert "get-version-edp" == bedp[2]["taskRef"]["name"] - assert "update-build-number" in bedp[3]["taskRef"]["name"] - assert f"update-build-number-{buildtool}" == bedp[3]["taskRef"]["name"] - assert "test" in bedp[4]["name"] - assert "lint" in bedp[5]["name"] - assert buildtool == bedp[5]["taskRef"]["name"] - assert "sast" in bedp[6]["name"] - assert "compile" in bedp[7]["name"] - assert buildtool == bedp[7]["taskRef"]["name"] - assert "sonar" in bedp[8]["name"] - assert "sonarqube-scanner" == bedp[8]["taskRef"]["name"] - assert "get-nexus-repository-url" in bedp[9]["name"] - assert "get-nexus-repository-url" == bedp[9]["taskRef"]["name"] - assert "push" in bedp[10]["name"] - assert buildtool == bedp[10]["taskRef"]["name"] - assert "create-ecr-repository" in bedp[11]["name"] - assert "kaniko-build" in bedp[12]["name"] - assert "git-tag" in bedp[13]["name"] - assert "update-cbis" in bedp[14]["name"] - assert "update-cbb" in ht["pipeline"][build_edp]["spec"]["finally"][0]["name"] - assert "push-to-jira" in ht["pipeline"][build_edp]["spec"]["finally"][1]["name"] - - -def test_python_flask_pipelines_github(): - config = """ -global: - gitProvider: github - dockerRegistry: - type: "ecr" - """ - - ht = helm_template(config) - - buildtool = "python" - framework = "flask" - - review = f"github-{buildtool}-{framework}-app-review" - build_default = f"github-{buildtool}-{framework}-app-build-default" - build_edp = f"github-{buildtool}-{framework}-app-build-edp" - - assert review in ht["pipeline"] - assert build_default in ht["pipeline"] - assert build_edp in ht["pipeline"] - - r = ht["pipeline"][review]["spec"]["tasks"] - assert "github-set-pending-status" in r[0]["name"] - assert "fetch-repository" in r[1]["name"] - assert "init-values" in r[2]["name"] - assert "helm-docs" in r[3]["name"] - assert "test" in r[4]["name"] - assert "lint" in r[5]["name"] - assert "sonar" in r[6]["name"] - assert "dockerfile-lint" in r[7]["name"] - assert "dockerbuild-verify" in r[8]["name"] - assert "helm-lint" in r[9]["name"] - assert "github-set-success-status" in ht["pipeline"][review]["spec"]["finally"][0]["name"] - assert "github-set-failure-status" in ht["pipeline"][review]["spec"]["finally"][1]["name"] - - # build with default versioning - bd = ht["pipeline"][build_default]["spec"]["tasks"] - assert "fetch-repository" in bd[0]["name"] - assert "init-values" in bd[1]["name"] - assert "get-version" in bd[2]["name"] - assert f"get-version-default" == bd[2]["taskRef"]["name"] - assert "update-build-number" in bd[3]["name"] - assert "test" in bd[4]["name"] - assert buildtool == bd[4]["taskRef"]["name"] - assert "lint" in bd[5]["name"] - assert buildtool == bd[5]["taskRef"]["name"] - assert "sast" in bd[6]["name"] - assert "compile" in bd[7]["name"] - assert buildtool == bd[7]["taskRef"]["name"] - assert "sonar" in bd[8]["name"] - assert "sonarqube-scanner" == bd[8]["taskRef"]["name"] - assert "get-nexus-repository-url" in bd[9]["name"] - assert "get-nexus-repository-url" == bd[9]["taskRef"]["name"] - assert "push" in bd[10]["name"] - assert buildtool == bd[10]["taskRef"]["name"] - assert "create-ecr-repository" in bd[11]["name"] - assert "kaniko-build" in bd[12]["name"] - assert "git-tag" in bd[13]["name"] - assert "update-cbis" in bd[14]["name"] - assert "push-to-jira" in ht["pipeline"][build_default]["spec"]["finally"][0]["name"] - - # build with edp versioning - bedp = ht["pipeline"][build_edp]["spec"]["tasks"] - assert "fetch-repository" in bedp[0]["name"] - assert "init-values" in bedp[1]["name"] - assert "get-version" in bedp[2]["name"] - assert "get-version-edp" == bedp[2]["taskRef"]["name"] - assert "update-build-number" in bedp[3]["taskRef"]["name"] - assert f"update-build-number-{buildtool}" == bedp[3]["taskRef"]["name"] - assert "sast" in bedp[6]["name"] - assert "compile" in bedp[7]["name"] - assert buildtool == bedp[7]["taskRef"]["name"] - assert "sonar" in bedp[8]["name"] - assert "sonarqube-scanner" == bedp[8]["taskRef"]["name"] - assert "get-nexus-repository-url" in bedp[9]["name"] - assert "get-nexus-repository-url" == bedp[9]["taskRef"]["name"] - assert "push" in bedp[10]["name"] - assert buildtool == bedp[10]["taskRef"]["name"] - assert "create-ecr-repository" in bedp[11]["name"] - assert "kaniko-build" in bedp[12]["name"] - assert "git-tag" in bedp[13]["name"] - assert "update-cbis" in bedp[14]["name"] - assert "update-cbb" in ht["pipeline"][build_edp]["spec"]["finally"][0]["name"] - assert "push-to-jira" in ht["pipeline"][build_edp]["spec"]["finally"][1]["name"] - - -def test_python_fastapi_pipelines_github(): - config = """ -global: - gitProvider: github - dockerRegistry: - type: "ecr" - """ - - ht = helm_template(config) - - buildtool = "python" - framework = "fastapi" - - review = f"github-{buildtool}-{framework}-app-review" - build_default = f"github-{buildtool}-{framework}-app-build-default" - build_edp = f"github-{buildtool}-{framework}-app-build-edp" - - assert review in ht["pipeline"] - assert build_default in ht["pipeline"] - assert build_edp in ht["pipeline"] - - r = ht["pipeline"][review]["spec"]["tasks"] - assert "github-set-pending-status" in r[0]["name"] - assert "fetch-repository" in r[1]["name"] - assert "init-values" in r[2]["name"] - assert "helm-docs" in r[3]["name"] - assert "test" in r[4]["name"] - assert "lint" in r[5]["name"] - assert "sonar" in r[6]["name"] - assert "dockerfile-lint" in r[7]["name"] - assert "dockerbuild-verify" in r[8]["name"] - assert "helm-lint" in r[9]["name"] - assert "github-set-success-status" in ht["pipeline"][review]["spec"]["finally"][0]["name"] - assert "github-set-failure-status" in ht["pipeline"][review]["spec"]["finally"][1]["name"] - - # build with default versioning - bd = ht["pipeline"][build_default]["spec"]["tasks"] - assert "fetch-repository" in bd[0]["name"] - assert "init-values" in bd[1]["name"] - assert "get-version" in bd[2]["name"] - assert f"get-version-default" == bd[2]["taskRef"]["name"] - assert "update-build-number" in bd[3]["name"] - assert "test" in bd[4]["name"] - assert buildtool == bd[4]["taskRef"]["name"] - assert "lint" in bd[5]["name"] - assert buildtool == bd[5]["taskRef"]["name"] - assert "sast" in bd[6]["name"] - assert "compile" in bd[7]["name"] - assert buildtool == bd[7]["taskRef"]["name"] - assert "sonar" in bd[8]["name"] - assert "sonarqube-scanner" == bd[8]["taskRef"]["name"] - assert "get-nexus-repository-url" in bd[9]["name"] - assert "get-nexus-repository-url" == bd[9]["taskRef"]["name"] - assert "push" in bd[10]["name"] - assert buildtool == bd[10]["taskRef"]["name"] - assert "create-ecr-repository" in bd[11]["name"] - assert "kaniko-build" in bd[12]["name"] - assert "git-tag" in bd[13]["name"] - assert "update-cbis" in bd[14]["name"] - assert "push-to-jira" in ht["pipeline"][build_default]["spec"]["finally"][0]["name"] - - # build with edp versioning - bedp = ht["pipeline"][build_edp]["spec"]["tasks"] - assert "fetch-repository" in bedp[0]["name"] - assert "init-values" in bedp[1]["name"] - assert "get-version" in bedp[2]["name"] - assert "get-version-edp" == bedp[2]["taskRef"]["name"] - assert "update-build-number" in bedp[3]["taskRef"]["name"] - assert f"update-build-number-{buildtool}" == bedp[3]["taskRef"]["name"] - assert "test" in bedp[4]["name"] - assert "lint" in bedp[5]["name"] - assert buildtool == bedp[5]["taskRef"]["name"] - assert "sast" in bedp[6]["name"] - assert "compile" in bedp[7]["name"] - assert buildtool == bedp[7]["taskRef"]["name"] - assert "sonar" in bedp[8]["name"] - assert "sonarqube-scanner" == bedp[8]["taskRef"]["name"] - assert "get-nexus-repository-url" in bedp[9]["name"] - assert "get-nexus-repository-url" == bedp[9]["taskRef"]["name"] - assert "push" in bedp[10]["name"] - assert buildtool == bedp[10]["taskRef"]["name"] - assert "create-ecr-repository" in bedp[11]["name"] - assert "kaniko-build" in bedp[12]["name"] - assert "git-tag" in bedp[13]["name"] - assert "update-cbis" in bedp[14]["name"] - assert "update-cbb" in ht["pipeline"][build_edp]["spec"]["finally"][0]["name"] - assert "push-to-jira" in ht["pipeline"][build_edp]["spec"]["finally"][1]["name"] - - def test_python_pipelines_harbor_gerrit(): config = """ global: gitProvider: gerrit - dockerRegistry: - type: "harbor" """ r = helm_template(config) @@ -981,8 +114,6 @@ def test_python_pipelines_harbor_github(): config = """ global: gitProvider: github - dockerRegistry: - type: "harbor" """ r = helm_template(config) @@ -1082,8 +213,6 @@ def test_python_pipelines_harbor_gitlab(): config = """ global: gitProvider: gitlab - dockerRegistry: - type: "harbor" """ r = helm_template(config) @@ -1184,8 +313,6 @@ def test_python_fastapi_pipelines_harbor_gerrit(): config = """ global: gitProvider: gerrit - dockerRegistry: - type: "harbor" """ ht = helm_template(config) @@ -1280,8 +407,6 @@ def test_python_flask_pipelines_harbor_gerrit(): config = """ global: gitProvider: gerrit - dockerRegistry: - type: "harbor" """ ht = helm_template(config) @@ -1375,8 +500,6 @@ def test_python_flask_pipelines_harbor_gitlab(): config = """ global: gitProvider: gitlab - dockerRegistry: - type: "harbor" """ ht = helm_template(config) @@ -1459,8 +582,6 @@ def test_python_fastapi_pipelines_harbor_gitlab(): config = """ global: gitProvider: gitlab - dockerRegistry: - type: "harbor" """ ht = helm_template(config) @@ -1546,8 +667,6 @@ def test_python_flask_pipelines_harbor_github(): config = """ global: gitProvider: github - dockerRegistry: - type: "harbor" """ ht = helm_template(config) @@ -1630,8 +749,6 @@ def test_python_fastapi_pipelines_harbor_github(): config = """ global: gitProvider: github - dockerRegistry: - type: "harbor" """ ht = helm_template(config)