Debian Codegraph @

ansible_collections/community/mongodb/.github/workflows/ansible-test.yml

raw
1 name: CI
2 on:
3 pull_request:
4 schedule:
5 - cron: "0 3 * * *"
6
7 env:
8 mongodb_version_file: "./tests/integration/targets/setup_mongodb/defaults/main.yml"
9
10 jobs:
11 sanity:
12 runs-on: ubuntu-24.04
13 defaults:
14 run:
15 working-directory: ansible_collections/community/mongodb
16 strategy:
17 matrix:
18 versions:
19 - python_version: "3.10"
20 ansible_version: "stable-2.16"
21 - python_version: "3.10"
22 ansible_version: "stable-2.17"
23 - python_version: "3.11"
24 ansible_version: "stable-2.18"
25 - python_version: "3.12"
26 ansible_version: "stable-2.19"
27 - python_version: "3.12"
28 ansible_version: "devel"
29 steps:
30
31 - name: Check out code
32 uses: actions/checkout@v4
33 with:
34 path: ansible_collections/community/mongodb
35
36 - name: Set up Python ${{ matrix.versions.python_version }}
37 uses: actions/setup-python@v5
38 with:
39 python-version: ${{ matrix.versions.python_version }}
40
41 - name: Install ansible-base (${{ matrix.versions.ansible_version }})
42 uses: nick-invision/retry@v3
43 with:
44 timeout_minutes: 3
45 max_attempts: 3
46 command: pip install https://github.com/ansible/ansible/archive/${{ matrix.versions.ansible_version }}.tar.gz --disable-pip-version-check
47
48 - name: Run sanity tests
49 run: ansible-test sanity --docker -v --color --python ${{ matrix.versions.python_version }} --exclude docs/* --exclude tests/ansible-operator/
50
51 units:
52 runs-on: ubuntu-24.04
53 defaults:
54 run:
55 working-directory: ansible_collections/community/mongodb
56 strategy:
57 matrix:
58 versions:
59 - python_version: "3.10"
60 ansible_version: "stable-2.15"
61 - python_version: "3.10"
62 ansible_version: "stable-2.16"
63 - python_version: "3.13"
64 ansible_version: "devel"
65 - python_version: "3.13"
66 ansible_version: "devel"
67 steps:
68 - name: Check out code
69 uses: actions/checkout@v4
70 with:
71 path: ansible_collections/community/mongodb
72
73 - name: Set up Python ${{ matrix.versions.python_version }}
74 uses: actions/setup-python@v5
75 with:
76 python-version: ${{ matrix.versions.python_version }}
77
78 - name: Install ansible-base (${{ matrix.versions.ansible_version }})
79 uses: nick-invision/retry@v3
80 with:
81 timeout_minutes: 3
82 max_attempts: 3
83 command: pip install https://github.com/ansible/ansible/archive/${{ matrix.versions.ansible_version }}.tar.gz --disable-pip-version-check
84
85 - name: Install mongodb
86 uses: nick-invision/retry@v3
87 with:
88 timeout_minutes: 3
89 max_attempts: 3
90 command: |
91 sudo apt-get install -y gnupg curl
92 curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | \
93 sudo gpg -o /usr/share/keyrings/mongodb-server-8.0.gpg \
94 --dearmor
95 echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/ubuntu noble/mongodb-org/8.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-8.0.list
96 sudo apt-get update
97 sudo apt-get install -y mongodb-org
98
99 - name: Install dateutil
100 uses: nick-invision/retry@v3
101 with:
102 timeout_minutes: 3
103 max_attempts: 3
104 command: pip install python-dateutil
105
106 - name: Install python libs
107 uses: nick-invision/retry@v3
108 with:
109 timeout_minutes: 3
110 max_attempts: 3
111 command: pip install mtools==1.7.2 pymongo psutil coverage pytest pytest-forked pytest-xdist pytest-mock
112
113 - name: Start a replicaset with mtools (3 nodes, starting from port 27017, auth enabled, rs name = replset)
114 run: mlaunch --replicaset --auth
115 working-directory: /home/runner/work/
116
117 - name: Launch a single instance (no auth)
118 run: mlaunch --single --port 27999
119
120 - name: Run unit tests
121 run: ansible-test units -v --color --python ${{ matrix.versions.python_version }} --coverage
122
123 - name: Generate coverage report.
124 run: ansible-test coverage xml -v --requirements --group-by command --group-by version
125
126 - uses: codecov/codecov-action@v4
127 with:
128 fail_ci_if_error: false
129
130 - name: Clean up mlaunch replicaset
131 run: mtools stop --auth-user user --auth-password password || true
132
133 integration_matrix:
134 runs-on: ubuntu-24.04
135 defaults:
136 run:
137 working-directory: ansible_collections/community/mongodb
138 outputs:
139 matrix: ${{ steps.json-list.outputs.modules-to-test }}
140
141 steps:
142
143 - name: Check out code
144 uses: actions/checkout@v4
145 with:
146 path: ansible_collections/community/mongodb
147
148 - name: Generate module list
149 run: |
150 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
151
152 - name: Set output variable
153 id: json-list
154 run: |
155 output=$(cat int_test_modules.json)
156 echo "modules-to-test=$output" >> $GITHUB_OUTPUT
157 echo "$output"
158
159 integration:
160 needs: integration_matrix
161 runs-on: ubuntu-24.04
162 defaults:
163 run:
164 working-directory: ansible_collections/community/mongodb
165 strategy:
166 matrix:
167 mongodb_version:
168 - "6.0"
169 - "7.0"
170 #- "8.0". tmp remove MongoDB 8 - Bug? Invalid access at address: 0x20
171 # https://github.com/ansible-collections/community.mongodb/actions/runs/17740301799/job/50412355202?pr=718
172 mongodb_module: ${{ fromJson(needs.integration_matrix.outputs.matrix) }}
173 versions:
174 - python_version: "3.10"
175 ansible_version: "stable-2.15"
176 docker_image: "ubuntu2204"
177 - python_version: "3.10"
178 ansible_version: "stable-2.16"
179 docker_image: "ubuntu2204"
180 - python_version: "3.12"
181 ansible_version: "devel"
182 docker_image: "ubuntu2204"
183 - python_version: "3.13"
184 ansible_version: "devel"
185 docker_image: "ubuntu2204"
186 steps:
187
188 - name: Check out code
189 uses: actions/checkout@v4
190 with:
191 path: ansible_collections/community/mongodb
192
193 - name: Set up Python ${{ matrix.versions.python_version }}
194 uses: actions/setup-python@v5
195 with:
196 python-version: ${{ matrix.versions.python_version }}
197
198 - name: Install ansible-base (${{ matrix.versions.ansible_version }})
199 uses: nick-invision/retry@v3
200 with:
201 timeout_minutes: 3
202 max_attempts: 3
203 command: pip install https://github.com/ansible/ansible/archive/${{ matrix.versions.ansible_version }}.tar.gz --disable-pip-version-check
204
205 - name: Install community.general
206 uses: nick-invision/retry@v3
207 with:
208 timeout_minutes: 3
209 max_attempts: 3
210 command: ansible-galaxy collection install 'community.general' -p ansible_collections/
211
212 - name: Install community.crypto
213 uses: nick-invision/retry@v3
214 with:
215 timeout_minutes: 3
216 max_attempts: 3
217 command: ansible-galaxy collection install community.crypto -p ansible_collections/
218
219 - name: Ensure MongoDB version is set to ${{ matrix.mongodb_version }}
220 run: "sed -i 's/^mongodb_version:.*/mongodb_version: \"${{ matrix.mongodb_version }}\"/g' ${{ env.mongodb_version_file }}"
221
222 - name: Run integration tests on Python ${{ matrix.versions.python_version }} | ${{ matrix.versions.docker_image }} | ${{ matrix.versions.ansible_version }} | ${{ matrix.mongodb_version }}
223 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 }}
224
225 - name: Upload Coverage data
226 run: tests/coverage.sh