diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml new file mode 100644 index 0000000000000000000000000000000000000000..e1fdf1de3322e2f7e22c14435d8ee3d0d0d483c0 --- /dev/null +++ b/.github/workflows/ansible-test.yml @@ -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 diff --git a/tests/sanity/galaxy-importer.cfg b/tests/sanity/galaxy-importer.cfg new file mode 100644 index 0000000000000000000000000000000000000000..fae700c20b2370cd2ac74e30227ab5201381be48 --- /dev/null +++ b/tests/sanity/galaxy-importer.cfg @@ -0,0 +1,5 @@ +[galaxy-importer] +RUN_ANSIBLE_TEST = True +RUN_ANSIBLE_LINT = True +ANSIBLE_TEST_LOCAL_IMAGE = True +LOCAL_IMAGE_DOCKER = True diff --git a/tests/sanity/ignore-2.12.txt b/tests/sanity/ignore-2.12.txt index f1c7540586fd93e74b919823207945f96ccde9bb..ff9c9de04c33f36a7fe4f6523d71b736a19a6864 100644 --- a/tests/sanity/ignore-2.12.txt +++ b/tests/sanity/ignore-2.12.txt @@ -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 tests/external-signed-ca-with-automatic-copy/external-ca.sh shebang!skip tests/pytests/conftest.py pylint:ansible-format-automatic-specification +tests/sanity/sanity.sh shebang!skip tests/user/users.sh shebang!skip tests/user/users_absent.sh shebang!skip tests/utils.py pylint:ansible-format-automatic-specification diff --git a/tests/sanity/sanity.sh b/tests/sanity/sanity.sh new file mode 100644 index 0000000000000000000000000000000000000000..32784414e43ff5b88a4e9729d33f2f9b48f4c4cf --- /dev/null +++ b/tests/sanity/sanity.sh @@ -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"