This commit is contained in:
2024-04-24 13:36:07 +02:00
parent baf721c4e8
commit 1f6c75e9f5
4 changed files with 154 additions and 11 deletions

View File

@@ -233,7 +233,7 @@ def get_results(config, files, root_dir):
),
}
if "on-$(params.pipeline-type).yaml" in config["files"]:
append_stage(stages, "global", "$(params.pipeline-type)", config["files"])
append_key(stages, "global", "$(params.pipeline-type)")
return stages, args
if "Dockerfile" in files:
@@ -258,6 +258,8 @@ def get_results(config, files, root_dir):
for stage in ["prepare", "lint", "build", "test", "publish"]:
if "on-{stage}.yaml" in config["files"]:
stages[stage] = ["custom"]
if len(stages[stage])>0:
append_stage(stages, "global", "on-{stage}".format(stage = stage), config["files"])
return stages, args

View File

@@ -16,22 +16,14 @@ const sources=[
#{url: "https://github.com/tektoncd/catalog/raw/main/task/markdown-lint/0.1/markdown-lint.yaml", name: "markdown-lint.yaml"},
#{url: "https://github.com/tektoncd/catalog/raw/main/task/npm/0.1/npm.yaml", name: "npm.yaml"},
#{url: "https://github.com/tektoncd/catalog/raw/main/task/pylint/0.3/pylint.yaml", name: "pylint.yaml"},
#{url: "https://github.com/tektoncd/catalog/raw/main/task/curl/0.1/curl.yaml", name: "curl.yaml"},
#{url: "https://github.com/tektoncd/catalog/raw/main/task/buildah/0.7/buildah.yaml", name: "buildah.yaml"},
#{url: "https://github.com/tektoncd/catalog/raw/main/task/pytest/0.2/pytest.yaml", name: "pytest.yaml"},
#{url: "https://github.com/tektoncd/catalog/raw/main/task/python-coverage/0.1/python-coverage.yaml", name: "python-coverage.yaml"},
#{url: "https://github.com/tektoncd/catalog/raw/main/task/shellcheck/0.1/shellcheck.yaml", name: "shellcheck.yaml"},
#{url: "https://github.com/tektoncd/catalog/raw/main/task/sonarqube-scanner/0.4/sonarqube-scanner.yaml", name: "sonarqube-scanner.yaml"},
#{url: "https://github.com/tektoncd/catalog/raw/main/task/ts-lint/0.1/ts-lint.yaml", name: "ts-lint.yaml"},
#{url: "https://github.com/tektoncd/catalog/raw/main/task/write-file/0.1/write-file.yaml", name: "write-file.yaml"},
#{url: "https://github.com/tektoncd/catalog/raw/main/task/yaml-lint/0.1/yaml-lint.yaml", name: "yaml-lint.yaml"},
#{url: "https://github.com/tektoncd/catalog/raw/main/task/skopeo-copy/0.3/skopeo-copy.yaml", name: "skopeo-copy.yaml"},
#{url: "https://github.com/tektoncd/catalog/raw/main/task/prometheus-gate/0.1/prometheus-gate.yaml", name: "prometheus-gate.yaml"},
#{url: "https://github.com/tektoncd/catalog/raw/main/task/ansible-builder/0.1/ansible-builder.yaml", name: "ansible-builder.yaml"},
#{url: "https://github.com/tektoncd/catalog/raw/main/task/ansible-runner/0.2/ansible-runner.yaml", name: "ansible-runner.yaml"},
#{url: "https://github.com/tektoncd/catalog/raw/main/task/yq/0.4/yq.yaml", name: "yq.yaml"},
];
fn pre_pack() {
for file in global::sources {
//shell(`curl -sL ${file.url} > ${global::SRC}/${file.name}`);

View File

@@ -23,6 +23,10 @@ spec:
- name: pylint-args
type: array
default: []
- name: git-url
type: string
- name: git-revision
type: string
tasks:
- name: lint-shell
onError: $(params.on-error)
@@ -38,6 +42,27 @@ spec:
workspaces:
- name: shared-workspace
workspace: source
- name: lint-shell-custom
onError: $(params.on-error)
when:
- input: "lint-shell-custom"
operator: in
values: ["$(params.stages[*])"]
params:
- name: args
value: $(params.shellcheck-args)
taskRef:
resolver: git
params:
- name: url
value: $(params.git-url)
- name: revision
value: $(params.git-revision)
- name: pathInRepo
value: ".tekton/lint-shell.yaml"
workspaces:
- name: shared-workspace
workspace: source
- name: lint-docker
onError: $(params.on-error)
when:
@@ -52,6 +77,27 @@ spec:
value: $(tasks.detect-stages.results.file-docker)
workspaces:
- name: source
- name: lint-docker-custom
onError: $(params.on-error)
when:
- input: "lint-docker-custom"
operator: in
values: ["$(params.stages[*])"]
taskRef:
resolver: git
params:
- name: url
value: $(params.git-url)
- name: revision
value: $(params.git-revision)
- name: pathInRepo
value: ".tekton/lint-docker.yaml"
matrix:
params:
- name: dockerfile-path
value: $(tasks.detect-stages.results.file-docker)
workspaces:
- name: source
- name: lint-yaml
onError: $(params.on-error)
when:
@@ -66,6 +112,27 @@ spec:
workspaces:
- name: shared-workspace
workspace: source
- name: lint-yaml-custom
onError: $(params.on-error)
when:
- input: "lint-yaml-custom"
operator: in
values: ["$(params.stages[*])"]
params:
- name: args
value: ["."]
taskRef:
resolver: git
params:
- name: url
value: $(params.git-url)
- name: revision
value: $(params.git-revision)
- name: pathInRepo
value: ".tekton/lint-yaml.yaml"
workspaces:
- name: shared-workspace
workspace: source
- name: lint-black
onError: $(params.on-error)
when:
@@ -80,6 +147,27 @@ spec:
workspaces:
- name: shared-workspace
workspace: source
- name: lint-black-custom
onError: $(params.on-error)
when:
- input: "lint-black-custom"
operator: in
values: ["$(params.stages[*])"]
params:
- name: args
value: $(params.black-args)
taskRef:
resolver: git
params:
- name: url
value: $(params.git-url)
- name: revision
value: $(params.git-revision)
- name: pathInRepo
value: ".tekton/lint-black.yaml"
workspaces:
- name: shared-workspace
workspace: source
- name: lint-python
onError: $(params.on-error)
when:
@@ -92,5 +180,26 @@ spec:
taskRef:
name: pylint
workspaces:
- name: shared-workspace
workspace: source
- name: lint-python-custom
onError: $(params.on-error)
when:
- input: "lint-python-custom"
operator: in
values: ["$(params.stages[*])"]
params:
- name: args
value: ["$(tasks.detect-stages.results.file-python[*])"]
taskRef:
resolver: git
params:
- name: url
value: $(params.git-url)
- name: revision
value: $(params.git-revision)
- name: pathInRepo
value: ".tekton/lint-python.yaml"
workspaces:
- name: shared-workspace
workspace: source

View File

@@ -147,8 +147,14 @@ spec:
- name: lint
runAfter: [detect-stages]
when:
- cel: "tasks.detect-stages.results.stages-lint.size()>0"
- input: "on-lint"
operator: in
values: ["$(tasks.detect-stages.results.stages-global[*])"]
params:
- name: git-url
value: $(params.git-url)
- name: git-revision
value: $(params.git-revision)
- name: on-error
value: stopAndFail
- name: stages
@@ -165,8 +171,42 @@ spec:
name: auto-ci-lint
workspaces:
- name: source
- name: lint-custom
runAfter: [detect-stages]
when:
- input: "on-lint-custom"
operator: in
values: ["$(tasks.detect-stages.results.stages-global[*])"]
params:
- name: git-url
value: $(params.git-url)
- name: git-revision
value: $(params.git-revision)
- name: on-error
value: stopAndFail
- name: stages
value: $(tasks.detect-stages.results.stages-lint)
- name: dockerfiles
value: $(tasks.detect-stages.results.file-docker)
- name: shellcheck-args
value: $(tasks.detect-stages.results.shellcheck-args)
- name: black-args
value: $(tasks.detect-stages.results.black-args)
- name: pylint-args
value: $(tasks.detect-stages.results.pylint-args)
pipelineRef:
resolver: git
params:
- name: url
value: $(params.git-url)
- name: revision
value: $(params.git-revision)
- name: pathInRepo
value: ".tekton/on-lint.yaml"
workspaces:
- name: source
- name: publish-docker
runAfter: ["lint"]
runAfter: ["lint","lint-custom"]
when:
- input: "publish-docker"
operator: in