-
Notifications
You must be signed in to change notification settings - Fork 214
145 lines (117 loc) · 5.13 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
---
name: All CI related tasks
# Run this workflow every time a new commit pushed to your repository
on: [push, pull_request]
jobs:
linting:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Run black
uses: psf/black@stable
- name: 'Yamllint'
uses: karancode/yamllint-github-action@master
#- name: Run isort
# uses: jamescurtin/isort-action@master
#- name: Run ruff
# uses: chartboost/ruff-action@v1
unit_testing:
runs-on: ubuntu-latest
needs: linting
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: false
- name: Install Python packages
run: poetry install
- name: Build and install collection
run: |
ansible-galaxy collection build .
ansible-galaxy collection install netbox*.tar.gz -p /home/runner/.ansible/collections
- name: Run Ansible Sanity tests
run: poetry run ansible-test sanity -v --requirements --python ${{ matrix.python-version }} --skip-test pep8 plugins/
working-directory: /home/runner/.ansible/collections/ansible_collections/netbox/netbox
- name: Run Ansible Unit tests
run: poetry run ansible-test units -vvv --coverage --python ${{ matrix.python-version }}
working-directory: /home/runner/.ansible/collections/ansible_collections/netbox/netbox
- name: Run Ansible Coverage
run: poetry run ansible-test coverage report --all --omit "tests/*,hacking/*,docs/*" --show-missing
working-directory: /home/runner/.ansible/collections/ansible_collections/netbox/netbox
integration_testing:
runs-on: ubuntu-latest
needs: unit_testing
env:
python-version: "3.9"
strategy:
fail-fast: false
matrix:
include:
- VERSION: "v3.3"
NETBOX_DOCKER_VERSION: 2.3.0
- VERSION: "v3.4"
NETBOX_DOCKER_VERSION: 2.5.3
- VERSION: "v3.5"
NETBOX_DOCKER_VERSION: 2.6.1
- VERSION: "v3.6"
NETBOX_DOCKER_VERSION: 2.7.0
# If we want to integration test wiht all supported Python:
#python-version: ["3.9", "3.10", "3.11"]
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Clone & Start netbox-docker containers - ${{ matrix.VERSION }}
run: |
cd ..
git clone https://github.com/netbox-community/netbox-docker.git
cd netbox-docker
git checkout ${{ matrix.NETBOX_DOCKER_VERSION }}
cp $GITHUB_WORKSPACE/tests/netbox-docker/${{ matrix.VERSION }}/docker-compose.override.yml docker-compose.override.yml
docker-compose up -d --quiet-pull netbox netbox-worker postgres redis redis-cache
docker container ls
cd ..
- name: Set up Python ${{ env.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.python-version }}
- name: Install and configure Poetry
uses: snok/install-poetry@v1.3.3
with:
virtualenvs-create: false
- name: Install Python packages
run: poetry install
- name: Build and install collection
run: |
ansible-galaxy collection install community.general -p /home/runner/.ansible/collections
ansible-galaxy collection build .
ansible-galaxy collection install netbox*.tar.gz -p /home/runner/.ansible/collections
- name: Wait for NetBox to be available
run: |
docker container ls
docker logs netbox-docker_netbox_1
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
working-directory: /home/runner/.ansible/collections/ansible_collections/netbox/netbox
#if: matrix.VERSION == 'v3.3'
- name: Pre-populate NetBox
run: ./tests/integration/netbox-deploy.py
working-directory: /home/runner/.ansible/collections/ansible_collections/netbox/netbox
- name: Run integration tests
# Run regression and integration tests
# Run the inventory test first, in case any of the other tests modify the data.
run: |
ansible-test integration -v --color --coverage --python ${{ env.python-version }} inventory-${{ matrix.VERSION }}
ansible-test integration -v --color --coverage --python ${{ env.python-version }} regression-${{ matrix.VERSION }}
ansible-test integration -v --color --coverage --python ${{ env.python-version }} ${{ matrix.VERSION }}
ansible-test coverage report --all --omit "tests/*,hacking/*,docs/*" --show-missing
working-directory: /home/runner/.ansible/collections/ansible_collections/netbox/netbox