CI #671
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
# Run CI against all pushes (direct commits, also merged PRs), Pull Requests | |
push: | |
branches: | |
- main | |
- ci | |
pull_request: | |
# Run CI once per day (at 06:00 UTC) | |
# This ensures that even if there haven't been commits that we are still testing against latest version of ansible-test for each ansible-core version | |
schedule: | |
- cron: '0 6 * * *' | |
env: | |
NAMESPACE: daniel_lynch | |
COLLECTION_NAME: passbolt | |
jobs: | |
### | |
# Sanity tests (REQUIRED) | |
# | |
# https://docs.ansible.com/ansible/latest/dev_guide/testing_sanity.html | |
sanity: | |
name: Sanity (Ⓐ${{ matrix.ansible }}) | |
strategy: | |
matrix: | |
ansible: | |
# It's important that Sanity is tested against all stable-X.Y branches | |
# Testing against `devel` may fail as new tests are added. | |
- stable-2.9 | |
- stable-2.10 | |
- stable-2.11 | |
- devel | |
runs-on: ubuntu-latest | |
steps: | |
# ansible-test requires the collection to be in a directory in the form | |
# .../ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/ | |
- name: Check out code | |
uses: actions/checkout@v2 | |
with: | |
path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
# it is just required to run that once as "ansible-test sanity" in the docker image | |
# will run on all python versions it supports. | |
python-version: 3.9 | |
# Install the head of the given branch (devel, stable-2.10) | |
- name: Install ansible-core (${{ matrix.ansible }}) | |
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check | |
# run ansible-test sanity inside of Docker. | |
# The docker container has all the pinned dependencies that are required | |
# and all python versions ansible supports. | |
- name: Run sanity tests | |
run: ansible-test sanity --docker -v --color | |
working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} | |
### | |
# Unit tests (OPTIONAL) | |
# | |
# https://docs.ansible.com/ansible/latest/dev_guide/testing_units.html | |
units: | |
runs-on: ubuntu-latest | |
name: Units (Ⓐ${{ matrix.ansible }}) | |
strategy: | |
# As soon as the first unit test fails, cancel the others to free up the CI queue | |
fail-fast: true | |
matrix: | |
ansible: | |
- stable-2.9 | |
- stable-2.10 | |
- stable-2.11 | |
- devel | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v2 | |
with: | |
path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
# it is just required to run that once as "ansible-test units" in the docker image | |
# will run on all python versions it supports. | |
python-version: 3.9 | |
- name: Install ansible-core (${{ matrix.ansible }}) | |
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check | |
# OPTIONAL If your unit test requires Python libraries from other collections | |
# Install them like this | |
- name: Install collection dependencies | |
run: git clone --depth=1 --single-branch https://github.com/ansible-collections/community.internal_test_tools.git ./ansible_collections/community/internal_test_tools | |
# NOTE: we're installing with git to work around Galaxy being a huge PITA (https://github.com/ansible/galaxy/issues/2429) | |
# run: ansible-galaxy collection install community.internal_test_tools -p . | |
# Run the unit tests | |
- name: Run unit test | |
run: ansible-test units -v --color --docker --coverage | |
working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} | |
# ansible-test support producing code coverage date | |
- name: Generate coverage report | |
run: ansible-test coverage xml -v --requirements --group-by command --group-by version | |
working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} | |
# See the reports at https://codecov.io/gh/ansible-collections/community.dns | |
- uses: codecov/codecov-action@v1 | |
with: | |
fail_ci_if_error: false | |
### | |
# Integration tests (RECOMMENDED) | |
# | |
# https://docs.ansible.com/ansible/latest/dev_guide/testing_integration.html | |
# If the application you are testing is available as a docker container and you want to test | |
# multiple versions see the following for an example: | |
# https://github.com/ansible-collections/community.zabbix/tree/master/.github/workflows | |
integration: | |
runs-on: ubuntu-latest | |
name: I (Ⓐ${{ matrix.ansible }}+py${{ matrix.python }}) | |
strategy: | |
fail-fast: false | |
matrix: | |
ansible: | |
- stable-2.9 | |
- stable-2.10 | |
- stable-2.11 | |
- stable-2.12 | |
- devel | |
python: | |
- 3.6 | |
- 3.7 | |
- 3.8 | |
- 3.9 | |
- "3.10" | |
exclude: | |
# Because ansible-test doesn't support python3.9 for Ansible 2.9 | |
- ansible: stable-2.9 | |
python: 3.9 | |
# Because ansible-test doesn't support python3.10 for Ansible 2.9 | |
- ansible: stable-2.9 | |
python: "3.10" | |
# Because ansible-test doesn't support python3.10 for ansible-base 2.10 | |
- ansible: stable-2.10 | |
python: "3.10" | |
# Because ansible-test doesn't support python3.10 for ansible-core 2.11 | |
- ansible: stable-2.11 | |
python: "3.10" | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v2 | |
with: | |
path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
# it is just required to run that once as "ansible-test integration" in the docker image | |
# will run on all python versions it supports. | |
python-version: 3.9 | |
- name: Install ansible-core (${{ matrix.ansible }}) | |
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check | |
# OPTIONAL If your integration test requires Python libraries or modules from other collections | |
# Install them like this | |
# - name: Install collection dependencies | |
# run: git clone --depth=1 --single-branch https://github.com/ansible-collections/community.general.git ./ansible_collections/community/general | |
# NOTE: we're installing with git to work around Galaxy being a huge PITA (https://github.com/ansible/galaxy/issues/2429) | |
# run: ansible-galaxy collection install community.general -p . | |
- name: Install passbolt python module | |
run: | | |
python -m pip install --upgrade pip | |
pip install passbolt | |
# https://docs.github.com/en/actions/reference/encrypted-secrets | |
# This seems to be the only way to get Secrets to ansible-test | |
- name: Create integration_config.yml and pipe in webhook secret | |
env: | |
ADMIN: ${{ secrets.ADMIN }} | |
ADMIN2: ${{ secrets.ADMIN2 }} | |
GPGKEY: ${{ secrets.GPGKEY }} | |
PASSBOLT_URI: ${{ secrets.PASSBOLT_URI }} | |
PASSPHRASE: ${{ secrets.PASSPHRASE }} | |
USER1: ${{ secrets.USER }} | |
USER2: ${{ secrets.USER2 }} | |
run: | | |
echo "admin: $ADMIN" > ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/tests/integration/integration_config.yml | |
echo "admin2: $ADMIN2" >> ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/tests/integration/integration_config.yml | |
echo -e "gpgkey: |\n$GPGKEY\n" >> ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/tests/integration/integration_config.yml | |
echo "passbolt_uri: $PASSBOLT_URI" >> ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/tests/integration/integration_config.yml | |
echo "passphrase: $PASSPHRASE" >> ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/tests/integration/integration_config.yml | |
echo "user: $USER1" >> ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/tests/integration/integration_config.yml | |
echo "user2: $USER2" >> ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/tests/integration/integration_config.yml | |
# Run the integration tests | |
- name: Run integration test | |
run: ansible-test integration -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --docker --coverage | |
working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} | |
# ansible-test support producing code coverage date | |
- name: Generate coverage report | |
run: ansible-test coverage xml -v --requirements --group-by command --group-by version | |
working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} | |
# See the reports at https://codecov.io/gh/ansible-collections/community.dns | |
- uses: codecov/codecov-action@v1 | |
with: | |
fail_ci_if_error: false | |
- name: Remove integration_config.yml | |
run: | | |
rm ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}/tests/integration/integration_config.yml |