Skip to content

CI

CI #3854

Workflow file for this run

name: CI
on:
pull_request:
schedule:
- cron: "0 3 * * *"
env:
mongodb_version_file: "./tests/integration/targets/setup_mongodb/defaults/main.yml"
jobs:
sanity:
runs-on: ubuntu-20.04
defaults:
run:
working-directory: ansible_collections/community/mongodb
strategy:
matrix:
versions:
- python_version: "3.10"
ansible_version: "stable-2.15"
- python_version: "3.10"
ansible_version: "stable-2.16"
- python_version: "3.11"
ansible_version: "devel"
- python_version: "3.12"
ansible_version: "devel"
steps:
- name: Check out code
uses: actions/checkout@v4
with:
path: ansible_collections/community/mongodb
- name: Set up Python ${{ matrix.versions.python_version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.versions.python_version }}
- name: Install ansible-base (${{ matrix.versions.ansible_version }})
uses: nick-invision/retry@v3
with:
timeout_minutes: 3
max_attempts: 3
command: pip install https://github.com/ansible/ansible/archive/${{ matrix.versions.ansible_version }}.tar.gz --disable-pip-version-check
- name: Run sanity tests
run: ansible-test sanity --docker -v --color --python ${{ matrix.versions.python_version }} --exclude docs/* --exclude tests/ansible-operator/
units:
runs-on: ubuntu-20.04
defaults:
run:
working-directory: ansible_collections/community/mongodb
strategy:
matrix:
versions:
- python_version: "3.10"
ansible_version: "stable-2.15"
- python_version: "3.10"
ansible_version: "stable-2.16"
- python_version: "3.11"
ansible_version: "devel"
- python_version: "3.12"
ansible_version: "devel"
steps:
- name: Check out code
uses: actions/checkout@v4
with:
path: ansible_collections/community/mongodb
- name: Set up Python ${{ matrix.versions.python_version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.versions.python_version }}
- name: Install ansible-base (${{ matrix.versions.ansible_version }})
uses: nick-invision/retry@v3
with:
timeout_minutes: 3
max_attempts: 3
command: pip install https://github.com/ansible/ansible/archive/${{ matrix.versions.ansible_version }}.tar.gz --disable-pip-version-check
- name: Install mongodb
uses: nick-invision/retry@v3
with:
timeout_minutes: 3
max_attempts: 3
command: sudo apt-get install -y mongodb-org
- name: Install dateutil
uses: nick-invision/retry@v3
with:
timeout_minutes: 3
max_attempts: 3
command: pip install python-dateutil
- name: Install python libs
uses: nick-invision/retry@v3
with:
timeout_minutes: 3
max_attempts: 3
command: pip install mtools==1.7.2 pymongo psutil coverage pytest pytest-forked pytest-xdist pytest-mock
- name: Start a replicaset with mtools (3 nodes, starting from port 27017, auth enabled, rs name = replset)
run: mlaunch --replicaset --auth
working-directory: /home/runner/work/
- name: Launch a single instance (no auth)
run: mlaunch --single --port 27999
- name: Run unit tests
run: ansible-test units -v --color --python ${{ matrix.versions.python_version }} --coverage
- name: Generate coverage report.
run: ansible-test coverage xml -v --requirements --group-by command --group-by version
- uses: codecov/codecov-action@v4
with:
fail_ci_if_error: false
- name: Clean up mlaunch replicaset
run: mtools stop --auth-user user --auth-password password || true
integration_matrix:
runs-on: ubuntu-20.04
defaults:
run:
working-directory: ansible_collections/community/mongodb
outputs:
matrix: ${{ steps.json-list.outputs.modules-to-test }}
steps:
- name: Check out code
uses: actions/checkout@v4
with:
path: ansible_collections/community/mongodb
- name: Generate module list
run: |
find tests/integration/targets -type d -maxdepth 1 -not -name 'setup*' -not -name 'master_tasks' | cut -d '/' -f4 | sort | awk NF | jq -sRc 'split("\n") | map(select(length > 0))' > int_test_modules.json
- name: Set output variable
id: json-list
run: |
output=$(cat int_test_modules.json)
echo "modules-to-test=$output" >> $GITHUB_OUTPUT
echo "$output"
integration:
needs: integration_matrix
runs-on: ubuntu-20.04
defaults:
run:
working-directory: ansible_collections/community/mongodb
strategy:
matrix:
mongodb_version:
- "6.0"
- "7.0"
- "8.0"
mongodb_module: ${{ fromJson(needs.integration_matrix.outputs.matrix) }}
versions:
- python_version: "3.10"
ansible_version: "stable-2.15"
docker_image: "ubuntu2204"
- python_version: "3.10"
ansible_version: "stable-2.16"
docker_image: "ubuntu2204"
- python_version: "3.11"
ansible_version: "devel"
docker_image: "ubuntu2204"
- python_version: "3.12"
ansible_version: "devel"
docker_image: "ubuntu2204"
steps:
- name: Check out code
uses: actions/checkout@v4
with:
path: ansible_collections/community/mongodb
- name: Set up Python ${{ matrix.versions.python_version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.versions.python_version }}
- name: Install ansible-base (${{ matrix.versions.ansible_version }})
uses: nick-invision/retry@v3
with:
timeout_minutes: 3
max_attempts: 3
command: pip install https://github.com/ansible/ansible/archive/${{ matrix.versions.ansible_version }}.tar.gz --disable-pip-version-check
- name: Install community.general
uses: nick-invision/retry@v3
with:
timeout_minutes: 3
max_attempts: 3
command: ansible-galaxy collection install 'community.general' -p ansible_collections/
- name: Install community.crypto
uses: nick-invision/retry@v3
with:
timeout_minutes: 3
max_attempts: 3
command: ansible-galaxy collection install community.crypto -p ansible_collections/
- name: Ensure MongoDB version is set to ${{ matrix.mongodb_version }}
run: "sed -i 's/^mongodb_version:.*/mongodb_version: \"${{ matrix.mongodb_version }}\"/g' ${{ env.mongodb_version_file }}"
- name: Run integration tests on Python ${{ matrix.versions.python_version }} | ${{ matrix.versions.docker_image }} | ${{ matrix.versions.ansible_version }} | ${{ matrix.mongodb_version }}
run: ansible-test integration --docker ${{ matrix.versions.docker_image }} -v --color --retry-on-error --python 3.10 --continue-on-error --diff --coverage ${{ matrix.mongodb_module }}
- name: Upload Coverage data
run: tests/coverage.sh