mirror of
https://github.com/ansible-collections/hetzner.hcloud
synced 2024-11-10 06:34:13 +00:00
ci: add unit tests to azure pipelines (#325)
##### SUMMARY Enable unit testing in the CI. We started to write some unit tests for the inventory, but they were not enforced in the CI.
This commit is contained in:
parent
94190ae6cb
commit
9a44bc260f
6 changed files with 125 additions and 62 deletions
|
@ -36,7 +36,7 @@ pool: Standard
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
### Sanity
|
### Sanity
|
||||||
- stage: Ansible_devel
|
- stage: Sanity_devel
|
||||||
displayName: Sanity devel
|
displayName: Sanity devel
|
||||||
dependsOn: []
|
dependsOn: []
|
||||||
jobs:
|
jobs:
|
||||||
|
@ -44,9 +44,9 @@ stages:
|
||||||
parameters:
|
parameters:
|
||||||
targets:
|
targets:
|
||||||
- name: Sanity
|
- name: Sanity
|
||||||
test: "devel/sanity/1"
|
test: devel/sanity/1
|
||||||
|
|
||||||
- stage: Ansible_2_16
|
- stage: Sanity_2_16
|
||||||
displayName: Sanity 2.16
|
displayName: Sanity 2.16
|
||||||
dependsOn: []
|
dependsOn: []
|
||||||
jobs:
|
jobs:
|
||||||
|
@ -54,8 +54,9 @@ stages:
|
||||||
parameters:
|
parameters:
|
||||||
targets:
|
targets:
|
||||||
- name: Sanity
|
- name: Sanity
|
||||||
test: "2.16/sanity/1"
|
test: 2.16/sanity/1
|
||||||
- stage: Ansible_2_15
|
|
||||||
|
- stage: Sanity_2_15
|
||||||
displayName: Sanity 2.15
|
displayName: Sanity 2.15
|
||||||
dependsOn: []
|
dependsOn: []
|
||||||
jobs:
|
jobs:
|
||||||
|
@ -63,8 +64,9 @@ stages:
|
||||||
parameters:
|
parameters:
|
||||||
targets:
|
targets:
|
||||||
- name: Sanity
|
- name: Sanity
|
||||||
test: "2.15/sanity/1"
|
test: 2.15/sanity/1
|
||||||
- stage: Ansible_2_14
|
|
||||||
|
- stage: Sanity_2_14
|
||||||
displayName: Sanity 2.14
|
displayName: Sanity 2.14
|
||||||
dependsOn: []
|
dependsOn: []
|
||||||
jobs:
|
jobs:
|
||||||
|
@ -72,8 +74,9 @@ stages:
|
||||||
parameters:
|
parameters:
|
||||||
targets:
|
targets:
|
||||||
- name: Sanity
|
- name: Sanity
|
||||||
test: "2.14/sanity/1"
|
test: 2.14/sanity/1
|
||||||
- stage: Ansible_2_13
|
|
||||||
|
- stage: Sanity_2_13
|
||||||
displayName: Sanity 2.13
|
displayName: Sanity 2.13
|
||||||
dependsOn: []
|
dependsOn: []
|
||||||
jobs:
|
jobs:
|
||||||
|
@ -81,92 +84,133 @@ stages:
|
||||||
parameters:
|
parameters:
|
||||||
targets:
|
targets:
|
||||||
- name: Sanity
|
- name: Sanity
|
||||||
test: "2.13/sanity/1"
|
test: 2.13/sanity/1
|
||||||
|
|
||||||
## Integration tests (remote)
|
### Units
|
||||||
- stage: Hetzner_devel
|
- stage: Units_devel
|
||||||
displayName: Hetzner devel
|
displayName: Units devel
|
||||||
dependsOn: []
|
dependsOn: []
|
||||||
jobs:
|
jobs:
|
||||||
- template: templates/matrix.yml
|
- template: templates/matrix.yml
|
||||||
parameters:
|
parameters:
|
||||||
groups:
|
|
||||||
- 1
|
|
||||||
- 2
|
|
||||||
- 3
|
|
||||||
targets:
|
targets:
|
||||||
- name: hcloud
|
- name: (py3.10)
|
||||||
test: "devel/hcloud/3.10"
|
test: devel/units/3.10
|
||||||
|
|
||||||
- stage: Hetzner_2_16
|
- stage: Units_2_16
|
||||||
displayName: Hetzner 2.16
|
displayName: Units 2.16
|
||||||
dependsOn: []
|
dependsOn: []
|
||||||
jobs:
|
jobs:
|
||||||
- template: templates/matrix.yml
|
- template: templates/matrix.yml
|
||||||
parameters:
|
parameters:
|
||||||
groups:
|
|
||||||
- 1
|
|
||||||
- 2
|
|
||||||
- 3
|
|
||||||
targets:
|
targets:
|
||||||
- name: hcloud
|
- name: (py3.10)
|
||||||
test: "2.16/hcloud/3.10"
|
test: 2.16/units/3.10
|
||||||
|
|
||||||
- stage: Hetzner_2_15
|
- stage: Units_2_15
|
||||||
displayName: Hetzner 2.15
|
displayName: Units 2.15
|
||||||
dependsOn: []
|
dependsOn: []
|
||||||
jobs:
|
jobs:
|
||||||
- template: templates/matrix.yml
|
- template: templates/matrix.yml
|
||||||
parameters:
|
parameters:
|
||||||
groups:
|
|
||||||
- 1
|
|
||||||
- 2
|
|
||||||
- 3
|
|
||||||
targets:
|
targets:
|
||||||
- name: hcloud
|
- name: (py3.9)
|
||||||
test: "2.15/hcloud/3.9"
|
test: 2.15/units/3.9
|
||||||
|
|
||||||
- stage: Hetzner_2_14
|
- stage: Units_2_14
|
||||||
displayName: Hetzner 2.14
|
displayName: Units 2.14
|
||||||
dependsOn: []
|
dependsOn: []
|
||||||
jobs:
|
jobs:
|
||||||
- template: templates/matrix.yml
|
- template: templates/matrix.yml
|
||||||
parameters:
|
parameters:
|
||||||
groups:
|
|
||||||
- 1
|
|
||||||
- 2
|
|
||||||
- 3
|
|
||||||
targets:
|
targets:
|
||||||
- name: hcloud
|
- name: (py3.9)
|
||||||
test: "2.14/hcloud/3.9"
|
test: 2.14/units/3.9
|
||||||
|
|
||||||
- stage: Hetzner_2_13
|
- stage: Units_2_13
|
||||||
displayName: Hetzner 2.13
|
displayName: Units 2.13
|
||||||
dependsOn: []
|
dependsOn: []
|
||||||
jobs:
|
jobs:
|
||||||
- template: templates/matrix.yml
|
- template: templates/matrix.yml
|
||||||
parameters:
|
parameters:
|
||||||
groups:
|
|
||||||
- 1
|
|
||||||
- 2
|
|
||||||
- 3
|
|
||||||
targets:
|
targets:
|
||||||
- name: hcloud
|
- name: (py3.8)
|
||||||
test: "2.13/hcloud/3.9"
|
test: 2.13/units/3.8
|
||||||
|
|
||||||
|
## Integration
|
||||||
|
- stage: Integration_devel
|
||||||
|
displayName: Integration devel
|
||||||
|
dependsOn: []
|
||||||
|
jobs:
|
||||||
|
- template: templates/matrix.yml
|
||||||
|
parameters:
|
||||||
|
groups: [1, 2, 3]
|
||||||
|
targets:
|
||||||
|
- name: (py3.10)
|
||||||
|
test: devel/integration/3.10
|
||||||
|
|
||||||
|
- stage: Integration_2_16
|
||||||
|
displayName: Integration 2.16
|
||||||
|
dependsOn: []
|
||||||
|
jobs:
|
||||||
|
- template: templates/matrix.yml
|
||||||
|
parameters:
|
||||||
|
groups: [1, 2, 3]
|
||||||
|
targets:
|
||||||
|
- name: (py3.10)
|
||||||
|
test: 2.16/integration/3.10
|
||||||
|
|
||||||
|
- stage: Integration_2_15
|
||||||
|
displayName: Integration 2.15
|
||||||
|
dependsOn: []
|
||||||
|
jobs:
|
||||||
|
- template: templates/matrix.yml
|
||||||
|
parameters:
|
||||||
|
groups: [1, 2, 3]
|
||||||
|
targets:
|
||||||
|
- name: (py3.9)
|
||||||
|
test: 2.15/integration/3.9
|
||||||
|
|
||||||
|
- stage: Integration_2_14
|
||||||
|
displayName: Integration 2.14
|
||||||
|
dependsOn: []
|
||||||
|
jobs:
|
||||||
|
- template: templates/matrix.yml
|
||||||
|
parameters:
|
||||||
|
groups: [1, 2, 3]
|
||||||
|
targets:
|
||||||
|
- name: (py3.9)
|
||||||
|
test: 2.14/integration/3.9
|
||||||
|
|
||||||
|
- stage: Integration_2_13
|
||||||
|
displayName: Integration 2.13
|
||||||
|
dependsOn: []
|
||||||
|
jobs:
|
||||||
|
- template: templates/matrix.yml
|
||||||
|
parameters:
|
||||||
|
groups: [1, 2, 3]
|
||||||
|
targets:
|
||||||
|
- name: (py3.8)
|
||||||
|
test: 2.13/integration/3.8
|
||||||
|
|
||||||
### Finally
|
### Finally
|
||||||
- stage: Summary
|
- stage: Summary
|
||||||
condition: succeededOrFailed()
|
condition: succeededOrFailed()
|
||||||
dependsOn:
|
dependsOn:
|
||||||
- Ansible_devel
|
- Sanity_devel
|
||||||
- Ansible_2_16
|
- Sanity_2_16
|
||||||
- Ansible_2_15
|
- Sanity_2_15
|
||||||
- Ansible_2_14
|
- Sanity_2_14
|
||||||
- Ansible_2_13
|
- Sanity_2_13
|
||||||
- Hetzner_devel
|
- Units_devel
|
||||||
- Hetzner_2_16
|
- Units_2_16
|
||||||
- Hetzner_2_15
|
- Units_2_15
|
||||||
- Hetzner_2_14
|
- Units_2_14
|
||||||
- Hetzner_2_13
|
- Units_2_13
|
||||||
|
- Integration_devel
|
||||||
|
- Integration_2_16
|
||||||
|
- Integration_2_15
|
||||||
|
- Integration_2_14
|
||||||
|
- Integration_2_13
|
||||||
jobs:
|
jobs:
|
||||||
- template: templates/coverage.yml
|
- template: templates/coverage.yml
|
||||||
|
|
2
tests/unit/requirements.txt
Normal file
2
tests/unit/requirements.txt
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
python-dateutil
|
||||||
|
requests
|
|
@ -74,7 +74,7 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# STAR: HACK install dependencies
|
# STAR: HACK install dependencies
|
||||||
retry pip install -r tests/integration/requirements.txt -c tests/integration/constraints.txt
|
retry pip install -r tests/integration/requirements.txt -c tests/constraints.txt
|
||||||
retry ansible-galaxy -vvv collection install -r tests/requirements.yml
|
retry ansible-galaxy -vvv collection install -r tests/requirements.yml
|
||||||
|
|
||||||
retry pip install rstcheck
|
retry pip install rstcheck
|
||||||
|
|
17
tests/utils/shippable/units.sh
Executable file
17
tests/utils/shippable/units.sh
Executable file
|
@ -0,0 +1,17 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -o pipefail -eux
|
||||||
|
|
||||||
|
declare -a args
|
||||||
|
IFS='/:' read -ra args <<< "$1"
|
||||||
|
|
||||||
|
python_version="${args[1]}"
|
||||||
|
|
||||||
|
ansible-test env --timeout 30 --color -v
|
||||||
|
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
ansible-test units --color -v \
|
||||||
|
--docker default \
|
||||||
|
--python "$python_version" \
|
||||||
|
${COVERAGE:+"$COVERAGE"} \
|
||||||
|
${CHANGED:+"$CHANGED"}
|
Loading…
Reference in a new issue