CI: Add Github action workflow to test roles 10/72510/2
authorAnil Belur <abelur@linuxfoundation.org>
Mon, 8 Jan 2024 22:57:20 +0000 (08:57 +1000)
committerAnil Belur <abelur@linuxfoundation.org>
Mon, 8 Jan 2024 23:24:53 +0000 (09:24 +1000)
- Ensure that the roles name matches what is in the path.
- Make add repository resilient to runtime failures retries.

Change-Id: Id6e5ee1ce411a862e17fc965d00d9653cafecdde
Signed-off-by: Anil Belur <abelur@linuxfoundation.org>
.github/workflows/CI.yaml [new file with mode: 0644]
tasks/Debian.yml

diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml
new file mode 100644 (file)
index 0000000..acac776
--- /dev/null
@@ -0,0 +1,61 @@
+---
+name: CI Verify Ansible roles with molecule
+"on":
+  pull_request:
+  push:
+    branches:
+      - master
+  schedule:
+    - cron: "0 7 * * 0"
+
+jobs:
+  lint:
+    name: Lint
+    runs-on: ubuntu-latest
+    steps:
+      - name: Check out the codebase.
+        uses: actions/checkout@v4
+
+      - name: Set up Python 3.
+        uses: actions/setup-python@v4
+        with:
+          python-version: "3.x"
+
+      - name: Install lint dependencies.
+        run: pip3 install yamllint
+
+      - name: Lint code.
+        run: |
+          yamllint .
+
+  molecule:
+    name: Molecule
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        distro:
+          - geerlingguy/docker-centos7-ansible:latest
+          - geerlingguy/docker-centos8-ansible:latest
+          - ubuntu1804
+          - ubuntu2004
+          - ubuntu2204
+      fail-fast: false
+
+    steps:
+      - name: Check out the codebase.
+        uses: actions/checkout@v4
+
+      - name: Set up Python 3.x
+        uses: actions/setup-python@v4
+        with:
+          python-version: "3.x"
+
+      - name: Install test dependencies.
+        run: pip3 install ansible ansible-lint molecule-plugins[docker] docker
+
+      - name: Run Molecule tests.
+        run: molecule test
+        env:
+          PY_COLORS: "1"
+          ANSIBLE_FORCE_COLOR: "1"
+          MOLECULE_DISTRO: ${{ matrix.distro }}
index 097439b..094c606 100644 (file)
   apt_repository:
     repo: 'ppa:openjdk-r/ppa'
   become: true
+  register: task_result
+  until: task_result is success
+  retries: 3
+  delay: 10
 
 - name: Install OpenJDK 1.8.0, 11 and 12
   apt: