From b768252537392fc4f877cd42763eddcbdb178bf0 Mon Sep 17 00:00:00 2001 From: emo Date: Sat, 2 Mar 2024 02:14:49 +0100 Subject: [PATCH 1/4] Added task for linting yml --- README.md | 2 +- Taskfile.yml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 013b25b..260965d 100644 --- a/README.md +++ b/README.md @@ -170,7 +170,7 @@ cd test_linux_containers Lint all YAML documents. ``` -yamllint . +task lint-yml ``` Use `ansible-lint` to verify good practices relevant to Ansible. diff --git a/Taskfile.yml b/Taskfile.yml index a97c0ed..a25c23b 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -3,3 +3,5 @@ version: '3' tasks: format-yml: cmds: [yamlfix .] + lint-yml: + cmds: [yamllint .] -- 2.39.5 From 1c1ca2759daad4fd069f76881aa137d8720fbb02 Mon Sep 17 00:00:00 2001 From: emo Date: Sat, 2 Mar 2024 02:20:18 +0100 Subject: [PATCH 2/4] Added task for linting Ansible code bases --- README.md | 2 +- Taskfile.yml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 260965d..de66db5 100644 --- a/README.md +++ b/README.md @@ -176,7 +176,7 @@ task lint-yml Use `ansible-lint` to verify good practices relevant to Ansible. ``` -LC_ALL=C.UTF-8 ansible-lint . +task lint-ansible ``` ## YAML code formatting diff --git a/Taskfile.yml b/Taskfile.yml index a25c23b..a9a8aec 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -5,3 +5,5 @@ tasks: cmds: [yamlfix .] lint-yml: cmds: [yamllint .] + lint-ansible: + cmds: [LC_ALL=C.UTF-8 ansible-lint .] -- 2.39.5 From 84200615bf92319939e126f74506db92278e98ef Mon Sep 17 00:00:00 2001 From: emo Date: Sat, 2 Mar 2024 02:30:05 +0100 Subject: [PATCH 3/4] Set up proper task dependency for linters --- README.md | 4 ++++ Taskfile.yml | 1 + 2 files changed, 5 insertions(+) diff --git a/README.md b/README.md index de66db5..4193fb8 100644 --- a/README.md +++ b/README.md @@ -179,6 +179,10 @@ Use `ansible-lint` to verify good practices relevant to Ansible. task lint-ansible ``` +Note that this task depends on `lint-yml`, which means that linting YML will +happen before linting the Ansible code base. Linting the Ansible code base will +only be triggered when linting all YML documents in the repository has been successful. + ## YAML code formatting Navigate to the root folder of the local copy of this git repository. diff --git a/Taskfile.yml b/Taskfile.yml index a9a8aec..1f15e45 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -6,4 +6,5 @@ tasks: lint-yml: cmds: [yamllint .] lint-ansible: + deps: [lint-yml] cmds: [LC_ALL=C.UTF-8 ansible-lint .] -- 2.39.5 From df7c944fa4d69e0d879a920b583001a074e9dde1 Mon Sep 17 00:00:00 2001 From: emo Date: Sat, 2 Mar 2024 02:34:02 +0100 Subject: [PATCH 4/4] Set up proper task dependency for linters --- README.md | 3 +++ Taskfile.yml | 1 + 2 files changed, 4 insertions(+) diff --git a/README.md b/README.md index 4193fb8..8447005 100644 --- a/README.md +++ b/README.md @@ -173,6 +173,9 @@ Lint all YAML documents. task lint-yml ``` +Note that this task will trigger formatting of all YAML documents +in the repository as a prerequisite to linting. + Use `ansible-lint` to verify good practices relevant to Ansible. ``` diff --git a/Taskfile.yml b/Taskfile.yml index 1f15e45..12e2671 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -4,6 +4,7 @@ tasks: format-yml: cmds: [yamlfix .] lint-yml: + deps: [format-yml] cmds: [yamllint .] lint-ansible: deps: [lint-yml] -- 2.39.5