diff --git a/share/gitea-tekton-org/auto-ci-detector.py b/share/gitea-tekton-org/auto-ci-detector.py index 73aa251..d225a64 100644 --- a/share/gitea-tekton-org/auto-ci-detector.py +++ b/share/gitea-tekton-org/auto-ci-detector.py @@ -45,7 +45,7 @@ def load_config(root_dir, ci_root_dir): ret = { "files": [], "languages": ["markdown", "docker", "rust", "shell", "python", "yaml", "js", "make"], - "markdown": {"extentions": ["md"]}, + "markdown": {"extentions": ["md"], "mdl-args": ["."]}, "docker": {"extentions": ["Dockerfile"]}, "rust": {"extentions": ["rs"]}, "shell": {"extentions": ["sh", "ksh"], "shellcheck-args": []}, @@ -58,7 +58,7 @@ def load_config(root_dir, ci_root_dir): "extentions": ["yaml", "yml"], "detect": True, "ansible": {"enable": False}, - "kube": {"enable": False}, + "kube": {"enable": False, "kubelint-args":[""]}, }, "js": { "extentions": ["ts", "js"], @@ -235,6 +235,12 @@ def get_results(config, files, root_dir): if "checkmake-args" in config["make"] else [] ), + "kubelint-args": ( + config["yaml"]["kube"]["kubelint-args"] if "kube" in config["yaml"] and "kubelint-args" in config["yaml"]["kube"] else [] + ), + "mdl-args": ( + config["markdown"]["mdl-args"] if "mdl-args" in config["markdown"] else ["."] + ), "black-args": ( config["python"]["black-args"] if "black-args" in config["python"] else [] ), @@ -260,6 +266,8 @@ def get_results(config, files, root_dir): if "Makefile" in files: append_stage(stages, "lint", "lint-make", config["files"]) args["checkmake-args"].extend(files["Makefile"]) + if "md" in files: + append_stage(stages, "lint", "lint-md", config["files"]) if "rs" in files: append_stage(stages, "lint", "lint-clippy", config["files"]) if "py" in files: @@ -300,3 +308,5 @@ save_json("$(results.shellcheck-args.path)", args["shellcheck-args"]) save_json("$(results.checkmake-args.path)", args["checkmake-args"]) save_json("$(results.black-args.path)", args["black-args"]) save_json("$(results.pylint-args.path)", args["pylint-args"]) +save_json("$(results.kubelint-args.path)", args["kubelint-args"]) +save_json("$(results.mdl-args.path)", args["mdl-args"]) diff --git a/share/gitea-tekton-org/auto-ci.tf b/share/gitea-tekton-org/auto-ci.tf index 4749258..2fa57e8 100644 --- a/share/gitea-tekton-org/auto-ci.tf +++ b/share/gitea-tekton-org/auto-ci.tf @@ -47,6 +47,12 @@ resource "kubectl_manifest" "auto-ci-detector" { - name: checkmake-args description: Arguments for checkmake type: array + - name: mdl-args + description: Arguments for mdl (Markdown linter) + type: array + - name: kubelinter-args + description: Arguments for kubelinter + type: array - name: black-args description: Arguments for black type: array diff --git a/share/gitea-tekton-org/tekton.dev_v1_Pipeline_auto-ci-push.yaml b/share/gitea-tekton-org/tekton.dev_v1_Pipeline_auto-ci-push.yaml index 37b19ed..0eda537 100644 --- a/share/gitea-tekton-org/tekton.dev_v1_Pipeline_auto-ci-push.yaml +++ b/share/gitea-tekton-org/tekton.dev_v1_Pipeline_auto-ci-push.yaml @@ -145,6 +145,7 @@ spec: workspaces: - name: source - name: lint-shell + runAfter: ["detect-stages"] onError: continue when: - input: "lint-shell" @@ -160,6 +161,7 @@ spec: workspace: source - name: lint-docker onError: continue + runAfter: ["detect-stages"] when: - input: "lint-docker" operator: in @@ -174,6 +176,7 @@ spec: - name: source - name: lint-yaml onError: continue + runAfter: ["detect-stages"] when: - input: "lint-yaml" operator: in @@ -188,6 +191,7 @@ spec: workspace: source - name: lint-black onError: continue + runAfter: ["detect-stages"] when: - input: "lint-black" operator: in @@ -202,6 +206,7 @@ spec: workspace: source - name: lint-python onError: continue + runAfter: ["detect-stages"] when: - input: "lint-python" operator: in @@ -214,27 +219,60 @@ spec: workspaces: - name: shared-workspace workspace: source - - name: lint-python + - name: lint-make onError: continue + runAfter: ["detect-stages"] when: - - input: "lint-python" + - input: "lint-make" operator: in values: ["$(tasks.detect-stages.results.stages-lint[*])"] params: - name: args - value: $(tasks.detect-stages.results.pylint-args) + value: $(tasks.detect-stages.results.checkmake-args) taskRef: - name: pylint + name: check-make + workspaces: + - name: shared-workspace + workspace: source + - name: lint-md + onError: continue + runAfter: ["detect-stages"] + when: + - input: "lint-md" + operator: in + values: ["$(tasks.detect-stages.results.stages-lint[*])"] + params: + - name: args + value: $(tasks.detect-stages.results.mdl-args) + taskRef: + name: markdown-lint + workspaces: + - name: shared-workspace + workspace: source + - name: lint-kube + onError: continue + runAfter: ["detect-stages"] + when: + - input: "lint-kube" + operator: in + values: ["$(tasks.detect-stages.results.stages-lint[*])"] + params: + - name: args + value: $(tasks.detect-stages.results.kubelinter-args) + taskRef: + name: kube-linter workspaces: - name: shared-workspace workspace: source - name: publish-docker - runAfter: ["lint-shell","lint-docker","lint-yaml","lint-black","lint-python"] + runAfter: ["lint-make","lint-shell","lint-docker","lint-yaml","lint-black","lint-python"] when: - input: "publish-docker" operator: in values: ["$(tasks.detect-stages.results.stages-publish[*])"] - - cel: "'$(params.branch-name)' == '$(params.git-default-branch)'" + - input: "$(params.branch-name)" + operator: in + values: ["$(params.git-default-branch)"] taskRef: name: buildah matrix: diff --git a/share/gitea-tekton-org/tekton.dev_v1_Pipeline_auto-ci-tag.yaml b/share/gitea-tekton-org/tekton.dev_v1_Pipeline_auto-ci-tag.yaml index 4f6a1bd..57fa4c2 100644 --- a/share/gitea-tekton-org/tekton.dev_v1_Pipeline_auto-ci-tag.yaml +++ b/share/gitea-tekton-org/tekton.dev_v1_Pipeline_auto-ci-tag.yaml @@ -129,6 +129,7 @@ spec: workspaces: - name: source - name: lint-shell + runAfter: ["detect-stages"] onError: stopAndFail when: - input: "lint-shell" @@ -143,6 +144,7 @@ spec: - name: shared-workspace workspace: source - name: lint-docker + runAfter: ["detect-stages"] onError: stopAndFail when: - input: "lint-docker" @@ -157,6 +159,7 @@ spec: workspaces: - name: source - name: lint-yaml + runAfter: ["detect-stages"] onError: stopAndFail when: - input: "lint-yaml" @@ -171,6 +174,7 @@ spec: - name: shared-workspace workspace: source - name: lint-black + runAfter: ["detect-stages"] onError: stopAndFail when: - input: "lint-black" @@ -185,6 +189,7 @@ spec: - name: shared-workspace workspace: source - name: lint-python + runAfter: ["detect-stages"] onError: stopAndFail when: - input: "lint-python" @@ -198,6 +203,51 @@ spec: workspaces: - name: shared-workspace workspace: source + - name: lint-make + onError: stopAndFail + runAfter: ["detect-stages"] + when: + - input: "lint-make" + operator: in + values: ["$(tasks.detect-stages.results.stages-lint[*])"] + params: + - name: args + value: $(tasks.detect-stages.results.checkmake-args) + taskRef: + name: check-make + workspaces: + - name: shared-workspace + workspace: source + - name: lint-md + onError: stopAndFail + runAfter: ["detect-stages"] + when: + - input: "lint-md" + operator: in + values: ["$(tasks.detect-stages.results.stages-lint[*])"] + params: + - name: args + value: $(tasks.detect-stages.results.mdl-args) + taskRef: + name: markdown-lint + workspaces: + - name: shared-workspace + workspace: source + - name: lint-kube + onError: stopAndFail + runAfter: ["detect-stages"] + when: + - input: "lint-kube" + operator: in + values: ["$(tasks.detect-stages.results.stages-lint[*])"] + params: + - name: args + value: $(tasks.detect-stages.results.kubelinter-args) + taskRef: + name: kube-linter + workspaces: + - name: shared-workspace + workspace: source - name: publish-docker runAfter: ["lint-shell","lint-docker","lint-yaml","lint-black","lint-python"] when: