|
| 1 | +--- |
1 | 2 | name: All CI related tasks
|
2 | 3 |
|
3 | 4 | # Run this workflow every time a new commit pushed to your repository
|
4 | 5 | on: [push, pull_request]
|
5 | 6 |
|
6 | 7 | jobs:
|
7 |
| - linting_unit_testing: |
| 8 | + linting: |
8 | 9 | runs-on: ubuntu-latest
|
| 10 | + steps: |
| 11 | + |
| 12 | + - name: Checkout repo |
| 13 | + uses: actions/checkout@v3 |
| 14 | + |
| 15 | + - name: Run black |
| 16 | + uses: psf/black@stable |
| 17 | + |
| 18 | + - name: 'Yamllint' |
| 19 | + uses: karancode/yamllint-github-action@master |
| 20 | + |
| 21 | + #- name: Run isort |
| 22 | + # uses: jamescurtin/isort-action@master |
| 23 | + |
| 24 | + #- name: Run ruff |
| 25 | + # uses: chartboost/ruff-action@v1 |
| 26 | + |
| 27 | + unit_testing: |
| 28 | + runs-on: ubuntu-latest |
| 29 | + needs: linting |
9 | 30 | strategy:
|
10 | 31 | fail-fast: false
|
11 | 32 | matrix:
|
12 |
| - python-version: ["3.8", "3.9", "3.10"] |
| 33 | + python-version: ["3.9", "3.10", "3.11"] |
| 34 | + |
13 | 35 | steps:
|
| 36 | + |
14 | 37 | - name: Checkout repo
|
15 |
| - uses: actions/checkout@v2 |
| 38 | + uses: actions/checkout@v3 |
| 39 | + |
16 | 40 | - name: Set up Python ${{ matrix.python-version }}
|
17 |
| - uses: actions/setup-python@v2 |
| 41 | + uses: actions/setup-python@v4 |
18 | 42 | with:
|
19 | 43 | python-version: ${{ matrix.python-version }}
|
| 44 | + |
20 | 45 | - name: Install and configure Poetry
|
21 | 46 | uses: snok/install-poetry@v1
|
22 | 47 | with:
|
23 | 48 | virtualenvs-create: false
|
| 49 | + |
24 | 50 | - name: Install Python packages
|
25 | 51 | run: poetry install
|
| 52 | + |
26 | 53 | - name: Build and install collection
|
27 | 54 | run: |
|
28 | 55 | ansible-galaxy collection build .
|
29 | 56 | ansible-galaxy collection install netbox*.tar.gz -p /home/runner/.ansible/collections
|
30 |
| - - name: Run Black |
31 |
| - run: poetry run black . --check --diff |
| 57 | +
|
32 | 58 | - name: Run Ansible Sanity tests
|
33 | 59 | run: poetry run ansible-test sanity -v --requirements --python ${{ matrix.python-version }} --skip-test pep8 plugins/
|
34 | 60 | working-directory: /home/runner/.ansible/collections/ansible_collections/netbox/netbox
|
| 61 | + |
35 | 62 | - name: Run Ansible Unit tests
|
36 | 63 | run: poetry run ansible-test units -vvv --coverage --python ${{ matrix.python-version }}
|
37 | 64 | working-directory: /home/runner/.ansible/collections/ansible_collections/netbox/netbox
|
| 65 | + |
38 | 66 | - name: Run Ansible Coverage
|
39 | 67 | run: poetry run ansible-test coverage report --all --omit "tests/*,hacking/*,docs/*" --show-missing
|
40 | 68 | working-directory: /home/runner/.ansible/collections/ansible_collections/netbox/netbox
|
41 |
| - integration: |
| 69 | + |
| 70 | + integration_testing: |
42 | 71 | runs-on: ubuntu-latest
|
43 |
| - needs: linting_unit_testing |
| 72 | + needs: unit_testing |
| 73 | + env: |
| 74 | + python-version: "3.9" |
44 | 75 | strategy:
|
45 | 76 | fail-fast: false
|
46 | 77 | matrix:
|
47 |
| - include: |
48 |
| - - python-version: 3.8 |
49 |
| - VERSION: "v3.2" |
50 |
| - INTEGRATION_TESTS: "v3.2" |
51 |
| - - python-version: 3.8 |
52 |
| - VERSION: "v3.3" |
53 |
| - INTEGRATION_TESTS: "v3.3" |
54 |
| - - python-version: 3.8 |
55 |
| - VERSION: "v3.4" |
56 |
| - INTEGRATION_TESTS: "v3.4" |
| 78 | + include: |
| 79 | + - VERSION: "v3.3" |
| 80 | + NETBOX_DOCKER_VERSION: 2.3.0 |
| 81 | + - VERSION: "v3.4" |
| 82 | + NETBOX_DOCKER_VERSION: 2.5.3 |
| 83 | + - VERSION: "v3.5" |
| 84 | + NETBOX_DOCKER_VERSION: 2.6.1 |
| 85 | + # If we want to integration test wiht all supported Python: |
| 86 | + #python-version: ["3.9", "3.10", "3.11"] |
| 87 | + |
57 | 88 | steps:
|
| 89 | + |
58 | 90 | - name: Checkout repo
|
59 |
| - uses: actions/checkout@v2 |
60 |
| - - name: Set up Python ${{ matrix.python-version }} |
61 |
| - uses: actions/setup-python@v2 |
62 |
| - with: |
63 |
| - python-version: ${{ matrix.python-version }} |
64 |
| - - name: Clone & Start netbox-docker containers - 3.2 |
65 |
| - env: |
66 |
| - VERSION: ${{ matrix.VERSION }} |
67 |
| - run: | |
68 |
| - cd .. |
69 |
| - git clone https://github.com/netbox-community/netbox-docker.git |
70 |
| - cd netbox-docker |
71 |
| - git checkout 1.6.1 |
72 |
| - tee docker-compose.override.yml <<EOF |
73 |
| - version: '3.4' |
74 |
| - services: |
75 |
| - netbox: |
76 |
| - image: netboxcommunity/netbox:v3.2 |
77 |
| - ports: |
78 |
| - - 32768:8080 |
79 |
| - EOF |
80 |
| - docker-compose up -d --quiet-pull |
81 |
| - docker container ls |
82 |
| - cd .. |
83 |
| - if: matrix.VERSION == 'v3.2' |
84 |
| - - name: Clone & Start netbox-docker containers - 3.3 |
85 |
| - env: |
86 |
| - VERSION: ${{ matrix.VERSION }} |
87 |
| - run: | |
88 |
| - cd .. |
89 |
| - git clone https://github.com/netbox-community/netbox-docker.git |
90 |
| - cd netbox-docker |
91 |
| - git checkout 2.2.0 |
92 |
| - tee docker-compose.override.yml <<EOF |
93 |
| - version: '3.4' |
94 |
| - services: |
95 |
| - netbox: |
96 |
| - image: netboxcommunity/netbox:v3.3 |
97 |
| - ports: |
98 |
| - - 32768:8080 |
99 |
| - EOF |
100 |
| - docker-compose up -d --quiet-pull |
101 |
| - docker container ls |
102 |
| - cd .. |
103 |
| - if: matrix.VERSION == 'v3.3' |
104 |
| - - name: Clone & Start netbox-docker containers - 3.4 |
105 |
| - env: |
106 |
| - VERSION: ${{ matrix.VERSION }} |
| 91 | + uses: actions/checkout@v3 |
| 92 | + |
| 93 | + - name: Clone & Start netbox-docker containers - ${{ matrix.VERSION }} |
107 | 94 | run: |
|
108 | 95 | cd ..
|
109 | 96 | git clone https://github.com/netbox-community/netbox-docker.git
|
110 | 97 | cd netbox-docker
|
111 |
| - git checkout 2.3.0 |
112 |
| - tee docker-compose.override.yml <<EOF |
113 |
| - version: '3.4' |
114 |
| - services: |
115 |
| - netbox: |
116 |
| - image: netboxcommunity/netbox:v3.4 |
117 |
| - ports: |
118 |
| - - 32768:8080 |
119 |
| - EOF |
120 |
| - docker-compose up -d --quiet-pull |
| 98 | + git checkout ${{ matrix.NETBOX_DOCKER_VERSION }} |
| 99 | + cp $GITHUB_WORKSPACE/tests/netbox-docker/${{ matrix.VERSION }}/docker-compose.override.yml docker-compose.override.yml |
| 100 | + docker-compose up -d --quiet-pull netbox netbox-worker postgres redis redis-cache |
121 | 101 | docker container ls
|
122 | 102 | cd ..
|
123 |
| - if: matrix.VERSION == 'v3.4' |
| 103 | +
|
| 104 | + - name: Set up Python ${{ env.python-version }} |
| 105 | + uses: actions/setup-python@v4 |
| 106 | + with: |
| 107 | + python-version: ${{ env.python-version }} |
| 108 | + |
124 | 109 | - name: Install and configure Poetry
|
125 | 110 | uses: snok/install-poetry@v1.3.3
|
126 | 111 | with:
|
127 | 112 | virtualenvs-create: false
|
| 113 | + |
128 | 114 | - name: Install Python packages
|
129 | 115 | run: poetry install
|
| 116 | + |
130 | 117 | - name: Build and install collection
|
131 | 118 | run: |
|
132 | 119 | ansible-galaxy collection install community.general -p /home/runner/.ansible/collections
|
133 | 120 | ansible-galaxy collection build .
|
134 | 121 | ansible-galaxy collection install netbox*.tar.gz -p /home/runner/.ansible/collections
|
| 122 | +
|
135 | 123 | - name: Wait for NetBox to be available
|
136 | 124 | run: |
|
137 | 125 | docker container ls
|
138 | 126 | docker logs netbox-docker_netbox_1
|
139 | 127 | timeout 300 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:32768)" != "200" ]]; do echo "waiting for NetBox"; sleep 5; done' || false
|
140 | 128 | working-directory: /home/runner/.ansible/collections/ansible_collections/netbox/netbox
|
| 129 | + #if: matrix.VERSION == 'v3.3' |
| 130 | + |
141 | 131 | - name: Pre-populate NetBox
|
142 | 132 | run: ./tests/integration/netbox-deploy.py
|
143 | 133 | working-directory: /home/runner/.ansible/collections/ansible_collections/netbox/netbox
|
144 |
| - - name: Allow scripts to be executed |
145 |
| - # Set runme.sh execute permissions stripped by ansible-galaxy. Should be fixed in Ansible 2.10 |
146 |
| - # https://github.com/ansible/ansible/issues/68415 |
147 |
| - # Run render_config.sh to pass environment variables to integration tests |
148 |
| - # https://www.ansible.com/blog/adding-integration-tests-to-ansible-content-collections |
149 |
| - run: | |
150 |
| - chmod +x tests/integration/targets/inventory-${{ matrix.INTEGRATION_TESTS }}/runme.sh |
151 |
| - chmod +x tests/integration/targets/inventory-${{ matrix.INTEGRATION_TESTS }}/compare_inventory_json.py |
152 |
| - chmod +x tests/integration/render_config.sh |
153 |
| - tests/integration/render_config.sh tests/integration/targets/inventory/runme_config.template > tests/integration/targets/inventory-${{ matrix.INTEGRATION_TESTS }}/runme_config |
154 |
| - working-directory: /home/runner/.ansible/collections/ansible_collections/netbox/netbox |
| 134 | + |
155 | 135 | - name: Run integration tests
|
156 | 136 | # Run regression and integration tests
|
157 | 137 | # Run the inventory test first, in case any of the other tests modify the data.
|
158 | 138 | run: |
|
159 |
| - ansible-test integration -v --color --coverage --python ${{ matrix.python-version }} inventory-${{ matrix.INTEGRATION_TESTS }} |
160 |
| - ansible-test integration -v --color --coverage --python ${{ matrix.python-version }} regression-${{ matrix.INTEGRATION_TESTS }} |
161 |
| - ansible-test integration -v --color --coverage --python ${{ matrix.python-version }} ${{ matrix.INTEGRATION_TESTS }} |
| 139 | + ansible-test integration -v --color --coverage --python ${{ env.python-version }} inventory-${{ matrix.VERSION }} |
| 140 | + ansible-test integration -v --color --coverage --python ${{ env.python-version }} regression-${{ matrix.VERSION }} |
| 141 | + ansible-test integration -v --color --coverage --python ${{ env.python-version }} ${{ matrix.VERSION }} |
162 | 142 | ansible-test coverage report --all --omit "tests/*,hacking/*,docs/*" --show-missing
|
163 | 143 | working-directory: /home/runner/.ansible/collections/ansible_collections/netbox/netbox
|
0 commit comments