Skip to content

Commit 379a71d

Browse files
committed
CI: add ansible-lint and ansible sanity jobs
1 parent efe552d commit 379a71d

File tree

4 files changed

+94
-0
lines changed

4 files changed

+94
-0
lines changed

.ansible-lint

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
exclude_paths:
3+
- .cache/
4+
- .github/
5+
use_default_rules: true

.github/workflows/pull_request.yml

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
name: Tests
3+
4+
# Controls when the action will run.
5+
on:
6+
pull_request:
7+
push:
8+
branches:
9+
- master
10+
11+
jobs:
12+
lint:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
ansible:
18+
- "2.10"
19+
- "2.12"
20+
- "2.14"
21+
steps:
22+
# Checks-out the repository under $GITHUB_WORKSPACE, so it's accessible to the job
23+
- uses: actions/checkout@v2
24+
25+
- uses: actions/setup-python@v2
26+
with:
27+
python-version: 3.x
28+
29+
- name: Install dependencies
30+
run: |
31+
python -m pip install --upgrade pip
32+
if [[ "${{ matrix.ansible }}" = "2.10" ]]; then
33+
ansible_package=ansible-base
34+
else
35+
ansible_package=ansible-core
36+
fi
37+
pip install $ansible_package==${{ matrix.ansible }}.* 'ansible-lint==5.*'
38+
39+
- name: Linting code
40+
run: |
41+
ansible-lint -v --force-color
42+
43+
sanity:
44+
runs-on: ubuntu-latest
45+
strategy:
46+
fail-fast: false
47+
matrix:
48+
ansible:
49+
- "2.10"
50+
- "2.12"
51+
steps:
52+
# Checks-out the repository under $GITHUB_WORKSPACE, so it's accessible to the job
53+
- uses: actions/checkout@v2
54+
55+
- uses: actions/setup-python@v2
56+
with:
57+
# Ansible 2.10 supports up to Python 3.8.
58+
python-version: 3.8
59+
60+
- name: Install dependencies
61+
run: |
62+
python -m pip install --upgrade pip
63+
if [[ "${{ matrix.ansible }}" = "2.10" ]]; then
64+
ansible_package=ansible-base
65+
else
66+
ansible_package=ansible-core
67+
fi
68+
pip install $ansible_package==${{ matrix.ansible }}.*
69+
70+
- name: Running sanity tests
71+
run: |
72+
.github/workflows/sanity.sh

.github/workflows/sanity.sh

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
3+
# Run Ansible collection sanity tests.
4+
5+
set -e
6+
7+
ANSIBLE_COLLECTIONS_PATH=$(mktemp -d)
8+
mkdir -p "${ANSIBLE_COLLECTIONS_PATH}/ansible_collections/stackhpc/openstack_ops"
9+
trap 'rm -rf ${ANSIBLE_COLLECTIONS_PATH}' err exit
10+
ansible-galaxy collection build --force
11+
ansible-galaxy collection install stackhpc-openstack_ops-*.tar.gz --collections-path "${ANSIBLE_COLLECTIONS_PATH}" --force
12+
PY_VER=$(python3 -c "from platform import python_version;print(python_version())" | cut -f 1,2 -d".")
13+
cd "${ANSIBLE_COLLECTIONS_PATH}/ansible_collections/stackhpc/openstack_ops"
14+
ansible-test sanity -v --venv --python "${PY_VER}"

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ cover/
2020
# Others
2121
.DS_Store
2222
.vimrc
23+
24+
# Collection builds
25+
*.tar.gz

0 commit comments

Comments
 (0)