-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(workflow): Adding a GitHub workflow for test docstrings validation
- Introduced a new GitHub Actions workflow (`docstring_validation.yml`) to validate docstrings using Betelgeuse. This workflow triggers on pull requests affecting the `integration-tests/` directory and performs a dry run with Betelgeuse. - Added a `README.md` to the `integration-tests/` directory, documenting how to run Betelgeuse for generating and importing test-case and test-run XML files. - Created a custom Betelgeuse configuration (`custom_betelgeuse_config.py`) to define additional fields for test cases, ensuring proper parsing of docstrings in the `integration-tests/` directory.
- Loading branch information
Showing
3 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
name: Test Docstrings Validation | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- "integration-tests/**" | ||
|
||
jobs: | ||
betelgeuse: | ||
name: "betelgeuse dry-run" | ||
runs-on: ubuntu-latest | ||
container: | ||
image: fedora:latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Base setup for Betelgeuse | ||
run: | | ||
dnf --setopt install_weak_deps=False install -y \ | ||
python3-pip | ||
python3 -m pip install betelgeuse | ||
- name: Run Betelgeuse | ||
run: | | ||
PYTHONPATH=integration-tests/ betelgeuse --config-module \ | ||
custom_betelgeuse_config test-case --dry-run \ | ||
integration-tests/ dryrun_project ./test_case.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Running Betelgeuse | ||
|
||
### Docs: | ||
https://betelgeuse.readthedocs.io/en/stable/ | ||
https://betelgeuse.readthedocs.io/en/stable/config.html | ||
|
||
## Test-case command | ||
Command generates an XML file suited to be imported by the **Test Case XML Importer**. It reads the Python test suite source code and generated XML file with all the information necessary. | ||
|
||
The `test-case` requires: | ||
|
||
- The path to the Python test suite source code | ||
- The Polarion project ID | ||
- The output XML file path (will be overwritten if exists) | ||
|
||
|
||
There shoud also be a custom config file specified for pythonpath for Betelgeuse to correctly read all the custom fields in the docstrings. The file is saved in integration-tests/custom_betelgeuse_config.py | ||
|
||
Example: | ||
|
||
```console | ||
$ PYTHONPATH=integration-tests/ \ | ||
betelgeuse --config-module \ | ||
custom_betelgeuse_config test-case \ | ||
integration-tests/ PROJECT ./test_case.xml | ||
``` | ||
|
||
This will create a test_case.xml file in integration-tests/ | ||
|
||
## Test-run command | ||
Command generates an XML file suited to be imported by the **Test Run XML Importer**. | ||
|
||
It takes: | ||
|
||
- A valid xUnit XML file | ||
- A Python test suite where test case IDs can be found | ||
|
||
And generates a resulting XML file with all the information necessary. | ||
|
||
It requires: | ||
|
||
- The path to the xUnit XML file | ||
- The path to the Python test suite source code | ||
- The Polarion user ID | ||
- The Polarion project ID | ||
- The output XML file path (will be overwritten if exists) | ||
|
||
It is also highly recommended to use `--response-property` as it will then be easier to monitor the importer messages | ||
|
||
Example: | ||
|
||
```console | ||
$ PYTHONPATH=integration-tests/ \ | ||
betelgeuse test-run \ | ||
--response-property property_key=property_value \ | ||
junit.xml \ | ||
insights-client/integration-tests \ | ||
testuser \ | ||
betelgeuse-test-run.xml | ||
``` | ||
|
||
NOTE: | ||
|
||
`--dry-run` can be used with `test-run` command when testing the functionality. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from betelgeuse import default_config | ||
|
||
TESTCASE_CUSTOM_FIELDS = default_config.TESTCASE_CUSTOM_FIELDS + ( | ||
"casecomponent", | ||
"requirement", | ||
"subsystemteam", | ||
"tier", | ||
"reference", | ||
) | ||
|
||
DEFAULT_CASECOMPONENT_VALUE = "" | ||
DEFAULT_REQUIREMENT_VALUE = "" | ||
DEFAULT_SUBSYSTEMTEAM_VALUE = "" | ||
DEFAULT_TIER_VALUE = "" | ||
DEFAULT_REFERENCE_VALUE = "" |