]> git.apps.os.sepia.ceph.com Git - ceph-cm-ansible.git/commitdiff
github: add syntax and lint checks
authorKen Dreyer <kdreyer@redhat.com>
Thu, 20 Apr 2023 21:04:55 +0000 (17:04 -0400)
committerKen Dreyer <kdreyer@redhat.com>
Mon, 24 Apr 2023 19:13:56 +0000 (15:13 -0400)
Run Ansible's syntax checks and ansible-lint on every PR and Git push.

Ignore some common ansible-lint errors so we can get to green quickly.
We can re-evaluate this list later and perhaps fix some of them down the
road.

.ansible-lint [new file with mode: 0644]
.github/workflows/tests.yml [new file with mode: 0644]

diff --git a/.ansible-lint b/.ansible-lint
new file mode 100644 (file)
index 0000000..6c90202
--- /dev/null
@@ -0,0 +1,26 @@
+---
+skip_list:
+  - command-instead-of-module
+  - command-instead-of-shell
+  - deprecated-command-syntax
+  - deprecated-local-action
+  - empty-string-compare
+  - experimental
+  - fqcn[action-core]
+  - fqcn[action]
+  - git-latest
+  - jinja
+  - literal-compare
+  - load-failure
+  - meta-no-info
+  - name[casing]
+  - no-changed-when
+  - no-handler
+  - no-jinja-when
+  - no-relative-paths
+  - no-tabs
+  - package-latest
+  - risky-file-permissions
+  - risky-shell-pipe
+  - role-name
+  - unnamed-task
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
new file mode 100644 (file)
index 0000000..e334a5a
--- /dev/null
@@ -0,0 +1,38 @@
+name: tests
+
+on: [push, pull_request]
+
+jobs:
+  syntax-check:
+    runs-on: ubuntu-latest
+    steps:
+    - uses: actions/checkout@v3
+    - name: Install ansible
+      run: |
+        sudo apt-get update
+        sudo apt-get purge ansible
+        sudo apt-get install python3-setuptools
+        pip3 install ansible --user
+    - name: ansible-playbook syntax check
+      run: |
+        export PATH=$PATH:$HOME/.local/bin
+        sed -i /^vault_password_file/d ansible.cfg
+        ansible-playbook -i localhost, cephlab.yml --syntax-check
+  ansible-lint:
+    runs-on: ubuntu-latest
+    steps:
+    - uses: actions/checkout@v3
+    - name: Install ansible-lint
+      run: |
+        sudo apt-get update
+        sudo apt-get purge ansible
+        sudo apt-get install python3-setuptools
+        # This pinned ansible version should match teuthology's
+        # requirements.txt.
+        # And we choose an ansible-lint version to be compatible with this
+        # Ansible version.
+        pip3 install ansible==2.10.7 ansible-lint[core]==5.4.0 --user
+    - name: Run ansible-lint
+      run: |
+        export PATH=$PATH:$HOME/.local/bin
+        ansible-lint -v roles/*