Skip to content

Commit 16efbfd

Browse files
Merge pull request #249 from cisco-en-programmability/main
Changes in unit test file
2 parents ce6cbc0 + 0e116e8 commit 16efbfd

File tree

2 files changed

+34
-33
lines changed

2 files changed

+34
-33
lines changed

.github/workflows/unit_tests.yml

+24-26
Original file line numberDiff line numberDiff line change
@@ -10,42 +10,40 @@ env:
1010
COLLECTION_NAME: dnac
1111

1212
jobs:
13-
Module-unittest:
14-
runs-on: ubuntu-22.04
13+
Unittests:
14+
runs-on: ubuntu-24.04
15+
strategy:
16+
matrix:
17+
python-version: ['3.10', '3.11', '3.12', '3.13']
18+
1519
steps:
1620
- name: Check out code
1721
uses: actions/checkout@v4
18-
with:
19-
path: repo
20-
fetch-depth: 0
21-
22-
- name: Create collections directory
23-
run: mkdir -p ./ansible_collections/${{env.NAMESPACE}}
24-
25-
- name: Move repository
26-
run: mv ./repo ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
2722

28-
- name: Set up Python
23+
- name: Set up Python ${{ matrix.python-version }}
2924
uses: actions/setup-python@v5
3025
with:
31-
python-version: '3.11'
26+
python-version: ${{ matrix.python-version }}
3227

3328
- name: Install dependencies
34-
working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
3529
run: |
36-
if [ -f "test-requirements.txt" ]; then
37-
pip install -r test-requirements.txt
38-
else
39-
echo "test-requirements.txt not found. Skipping dependency installation."
40-
exit 1
41-
fi
42-
ansible-galaxy collection install -f ansible.netcommon -p ./ansible_collections
30+
python -m venv venv
31+
source venv/bin/activate
32+
pip install ansible
33+
34+
ANSIBLE_COLLECTIONS_PATH=$(python -c "import site; print(site.getsitepackages()[0])")/ansible_collections
35+
pip install -r test-requirements.txt || (echo "test-requirements.txt not found. Skipping dependency installation." && exit 1)
36+
ansible-galaxy collection install -f ansible.netcommon -p $ANSIBLE_COLLECTIONS_PATH
37+
38+
ansible-galaxy collection build
39+
ansible-galaxy collection install -f cisco-dnac* -p $ANSIBLE_COLLECTIONS_PATH
4340
4441
- name: Run tests
45-
working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
42+
shell: bash
4643
run: |
47-
base_ref=${{ github.base_ref || github.ref }}
48-
git fetch origin "$base_ref" # Fetch the base branch
44+
source venv/bin/activate
45+
base_ref="${{ github.base_ref || github.ref }}"
46+
git fetch origin "$base_ref"
4947
5048
echo "::group::filtered_files"
5149
filtered_files=$(git diff --name-only "origin/$base_ref" HEAD | grep '^plugins/modules/.*workflow_manager\.py$' || true)
@@ -80,6 +78,6 @@ jobs:
8078
echo "::error::Tests failed."
8179
exit 1 # Exit with 1 if any test failed
8280
else
83-
echo "All tests passed successfully :)
84-
echo "::notice::Tests passed
81+
echo "All tests passed successfully :)"
82+
echo "::notice::Tests passed"
8583
fi

test-requirements.txt

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
dnacentersdk >= 2.6.0
2-
Jinja2==3.1.4
3-
PyYAML==6.0.1
4-
cryptography==42.0.7
5-
paramiko==3.4.0
6-
pyzipper==0.3.6
7-
ansible==6.7.0
1+
dnacentersdk
2+
Jinja2
3+
PyYAML
4+
cryptography
5+
paramiko
6+
pyzipper
7+
ansible
8+
ansible-runner
9+
requests
10+
yamale

0 commit comments

Comments
 (0)