Skip to content

Commit

Permalink
feat(workflow): Adding a GitHub workflow for test docstrings validation
Browse files Browse the repository at this point in the history
- 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
zpetrace committed Aug 30, 2024
1 parent f60e50b commit 23949fb
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/docstring_validation.yml
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
64 changes: 64 additions & 0 deletions integration-tests/README.md
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.
15 changes: 15 additions & 0 deletions integration-tests/custom_betelgeuse_config.py
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 = ""

0 comments on commit 23949fb

Please sign in to comment.