mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-07-30 19:34:45 +00:00
Enable ansible-test in github workflow
This test is using the galaxy_importer from ansible project. The
configuration file galaxy-importer.cfg is copied from linux-system-roles
https://github.com/linux-system-roles/auto-maintenance/blob/master/\
lsr_role2collection/galaxy-importer.cfg
The tests script has extra code to parse the output of the importer to
highlight errors and to exit with a proper error code.
The test can be used locally also with "sh tests/sanity/sanity.sh"
New files:
- .github/workflows/ansible-test.yml
- tests/sanity/galaxy-importer.cfg
- tests/sanity/sanity.sh
This commit is contained in:
17
.github/workflows/ansible-test.yml
vendored
Normal file
17
.github/workflows/ansible-test.yml
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
name: ansible-test sanity
|
||||||
|
on:
|
||||||
|
- push
|
||||||
|
- pull_request
|
||||||
|
jobs:
|
||||||
|
ansible_test:
|
||||||
|
name: Verify ansible-test sanity
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: Install virtualenv using pip
|
||||||
|
run: pip install virtualenv
|
||||||
|
- name: Run ansible-test
|
||||||
|
run: bash tests/sanity/sanity.sh
|
||||||
5
tests/sanity/galaxy-importer.cfg
Normal file
5
tests/sanity/galaxy-importer.cfg
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
[galaxy-importer]
|
||||||
|
RUN_ANSIBLE_TEST = True
|
||||||
|
RUN_ANSIBLE_LINT = True
|
||||||
|
ANSIBLE_TEST_LOCAL_IMAGE = True
|
||||||
|
LOCAL_IMAGE_DOCKER = True
|
||||||
@@ -35,6 +35,7 @@ roles/ipaserver/library/ipaserver_test.py pylint:ansible-format-automatic-specif
|
|||||||
roles/ipareplica/module_utils/ansible_ipa_replica.py pylint:ansible-format-automatic-specification
|
roles/ipareplica/module_utils/ansible_ipa_replica.py pylint:ansible-format-automatic-specification
|
||||||
tests/external-signed-ca-with-automatic-copy/external-ca.sh shebang!skip
|
tests/external-signed-ca-with-automatic-copy/external-ca.sh shebang!skip
|
||||||
tests/pytests/conftest.py pylint:ansible-format-automatic-specification
|
tests/pytests/conftest.py pylint:ansible-format-automatic-specification
|
||||||
|
tests/sanity/sanity.sh shebang!skip
|
||||||
tests/user/users.sh shebang!skip
|
tests/user/users.sh shebang!skip
|
||||||
tests/user/users_absent.sh shebang!skip
|
tests/user/users_absent.sh shebang!skip
|
||||||
tests/utils.py pylint:ansible-format-automatic-specification
|
tests/utils.py pylint:ansible-format-automatic-specification
|
||||||
|
|||||||
36
tests/sanity/sanity.sh
Normal file
36
tests/sanity/sanity.sh
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
VENV=/tmp/ansible-test-venv
|
||||||
|
ANSIBLE_COLLECTION=freeipa-ansible_freeipa
|
||||||
|
|
||||||
|
virtualenv "$VENV"
|
||||||
|
# shellcheck disable=SC1091
|
||||||
|
source "$VENV"/bin/activate
|
||||||
|
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install galaxy_importer
|
||||||
|
|
||||||
|
rm -f "$ANSIBLE_COLLECTION"-*.tar.gz
|
||||||
|
rm -f importer_result.json
|
||||||
|
|
||||||
|
utils/build-galaxy-release.sh
|
||||||
|
|
||||||
|
export GALAXY_IMPORTER_CONFIG=tests/sanity/galaxy-importer.cfg
|
||||||
|
|
||||||
|
collection=$(ls -1 "$ANSIBLE_COLLECTION"-*.tar.gz)
|
||||||
|
echo "Running: python -m galaxy_importer.main $collection"
|
||||||
|
|
||||||
|
error=0
|
||||||
|
while read -r line;
|
||||||
|
do
|
||||||
|
if [[ $line == ERROR* ]]; then
|
||||||
|
((error++))
|
||||||
|
echo -e "\033[31;1m${line}\033[0m"
|
||||||
|
else
|
||||||
|
echo "$line"
|
||||||
|
fi
|
||||||
|
done < <(python -m galaxy_importer.main "$collection")
|
||||||
|
|
||||||
|
rm -rf "$VENV"
|
||||||
|
|
||||||
|
exit "$error"
|
||||||
Reference in New Issue
Block a user