Skip to content

Commit

Permalink
Add workflow to check if tests and examples are updated (#269)
Browse files Browse the repository at this point in the history
* Add workflow to check if tests and examples are updated

* update target

* fix hacking script

* set error output

* re-generate tests

* Use correct yq version

* Add link to CONTRIBUTING.md
  • Loading branch information
schurzi authored Nov 19, 2024
1 parent ba4b364 commit 7f5b8f3
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 2 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/test_gen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
name: Check generated testcases

on: # yamllint disable-line rule:truthy
pull_request:
branches: [main]
paths:
- 'plugins/modules/*.py'
- 'examples/**'
- 'hacking/**'
- 'tests/**'
- '.github/workflows/test_gen.yml'

concurrency:
group: >-
${{ github.workflow }}-${{
github.event.pull_request.number || github.sha
}}
cancel-in-progress: true

jobs:
test_gen:
name: re-generate tests
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0
- uses: chrisdickinson/[email protected]
with:
yq-version: 3.4.1
- run: |
./hacking/update_examples_and_tests.sh
if [[ -n $(git status --porcelain) ]]; then
echo "::error ::You need to re-generate tests with './hacking/update_examples_and_tests.sh' (see CONTRIBUTING.md)"
exit 1
fi
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ After making code changes, please run the linters and fix all errors:
If you add new features or arguments to the existing modules, please add them to the examples in the module itself.
The integration tests and examples in our documentation are then generated from the module-examples.

To trigger this generation, you need to run the script `hacking/update_examples_and_tests.sh` from the root of the repository. For this you need to have yq in version v3.2.1 installed (see https://mikefarah.gitbook.io/yq/v/v3.x/).
To trigger this generation, you need to run the script `hacking/update_examples_and_tests.sh` from the root of the repository. For this you need to have yq in version v3.4.1 installed (see https://mikefarah.gitbook.io/yq/v/v3.x/).

Download example:
```
Expand Down
3 changes: 3 additions & 0 deletions examples/icinga_user.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
- foousertemplate
groups:
- onCall
vars:
department: IT
role: CTO
- name: Update user
telekom_mms.icinga_director.icinga_user:
state: present
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
object_name: "foousertemplate"
enable_notifications: false
period: '24/7'
zone: "foozone"
vars:
department: IT
zone: "foozone"
- name: Update user template
telekom_mms.icinga_director.icinga_user_template:
state: present
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
- foousertemplate
groups:
- onCall
vars:
department: IT
role: CTO
ignore_errors: true
register: result
- assert:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
object_name: "foousertemplate"
enable_notifications: false
period: '24/7'
vars:
department: IT
zone: "foozone"
ignore_errors: true
register: result
Expand Down

0 comments on commit 7f5b8f3

Please sign in to comment.