|
10 | 10 | COLLECTION_NAME: dnac
|
11 | 11 |
|
12 | 12 | 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 | + |
15 | 19 | steps:
|
16 | 20 | - name: Check out code
|
17 | 21 | 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}} |
27 | 22 |
|
28 |
| - - name: Set up Python |
| 23 | + - name: Set up Python ${{ matrix.python-version }} |
29 | 24 | uses: actions/setup-python@v5
|
30 | 25 | with:
|
31 |
| - python-version: '3.11' |
| 26 | + python-version: ${{ matrix.python-version }} |
32 | 27 |
|
33 | 28 | - name: Install dependencies
|
34 |
| - working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} |
35 | 29 | 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 |
43 | 40 |
|
44 | 41 | - name: Run tests
|
45 |
| - working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}} |
| 42 | + shell: bash |
46 | 43 | 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" |
49 | 47 |
|
50 | 48 | echo "::group::filtered_files"
|
51 | 49 | filtered_files=$(git diff --name-only "origin/$base_ref" HEAD | grep '^plugins/modules/.*workflow_manager\.py$' || true)
|
|
80 | 78 | echo "::error::Tests failed."
|
81 | 79 | exit 1 # Exit with 1 if any test failed
|
82 | 80 | else
|
83 |
| - echo "All tests passed successfully :) |
84 |
| - echo "::notice::Tests passed |
| 81 | + echo "All tests passed successfully :)" |
| 82 | + echo "::notice::Tests passed" |
85 | 83 | fi
|
0 commit comments