CI_roles #2627
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_roles | |
on: | |
pull_request: | |
schedule: | |
- cron: "0 6 * * *" | |
jobs: | |
# TODO - Consider adding ansible-lint and pylint steps as molecule removed these | |
roles_matrix: | |
runs-on: ubuntu-20.04 | |
defaults: | |
run: | |
working-directory: ansible_collections/community/mongodb | |
outputs: | |
matrix: ${{ steps.json-list.outputs.roles-to-test }} | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
with: | |
path: ansible_collections/community/mongodb | |
- name: Generate module list | |
run: | | |
find roles -type d -maxdepth 1 -mindepth 1 | cut -d '/' -f2 | awk NF | jq -sRc 'split("\n") | map(select(length > 0))' > int_test_roles.json | |
- name: Set output variable | |
id: json-list | |
run: | | |
output=$(cat int_test_roles.json) | |
echo "roles-to-test=$output" >> $GITHUB_OUTPUT | |
echo "$output" | |
roles: | |
runs-on: ubuntu-20.04 | |
needs: roles_matrix | |
defaults: | |
run: | |
working-directory: ansible_collections/community/mongodb | |
strategy: | |
matrix: | |
python_version: | |
- "3.11" | |
- "3.12" | |
mongodb_role: ${{ fromJson(needs.roles_matrix.outputs.matrix) }} | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
with: | |
path: ansible_collections/community/mongodb | |
- name: Set up Python ${{ matrix.test_scenario.python_version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.test_scenario.python_version }} | |
- name: Uninstall existing ansible | |
run: sudo apt remove ansible | |
- name: Ensure wheel is installed | |
run: pip install wheel | |
- name: Install requirements | |
run: | | |
pip install molecule molecule-docker pytest-testinfra | |
- name: Add molecule location to path | |
run: echo "${HOME}/.local/bin" >> $GITHUB_PATH | |
- name: Build the collection | |
run: ansible-galaxy collection build | |
- name: Rename the build artifact | |
run: mv community-mongodb-*.tar.gz community-mongodb-latest.tar.gz | |
- name: Install collection | |
run: ansible-galaxy collection install community-mongodb-*.tar.gz | |
- name: Run molecule test for ${{ matrix.mongodb_role }} | |
run: molecule test | |
working-directory: ansible_collections/community/mongodb/roles/${{ matrix.mongodb_role }} | |
# I don't like this | |
- name: Run molecule tests for a few extra mongodb_install role scenarios | |
run: | | |
molecule test --scenario-name specific_mongodb_version && \ | |
molecule test --scenario-name mongodb_hold_packages && \ | |
molecule test --scenario-name mongodb_nohold_packages | |
if: ${{ matrix.mongodb_role == 'mongodb_install' }} | |
working-directory: ansible_collections/community/mongodb/roles/mongodb_install | |
# TODO - This step is hanging, probably on the first molecule test scenario... check why | |
#- name: Run molecule tests for extra mongodb_mongod scenarios | |
# run: | | |
# molecule test --scenario-name custom_db_path && molecule test --scenario-name multiple_bind_ip | |
# if: ${{ matrix.mongodb_role == 'mongodb_mongod' }} | |
# working-directory: ansible_collections/community/mongodb/roles/mongodb_mongod | |
- name: Run molecule tests for an extra mongodb_config scenario | |
run: | | |
molecule test --scenario-name custom_db_path | |
if: ${{ matrix.mongodb_role == 'mongodb_config' }} | |
working-directory: ansible_collections/community/mongodb/roles/mongodb_config |