Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add jUnit test reporter and upload results #707

Merged
merged 7 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion .github/actions/all-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,37 @@ description: run all tests for ansible-rulebook (unit, integration, e2e)
runs:
using: composite
steps:
- name: Setup jUnit reporter
shell: bash
run: |
echo "GIT_SHA=$(git rev-parse "$GITHUB_SHA")" >> "$GITHUB_ENV"

- name: Common tests
env:
PDE_ORG_RESULTS_AGGREGATOR_UPLOAD_USER: ${{ env.PDE_ORG_RESULTS_AGGREGATOR_UPLOAD_USER }}
PDE_ORG_RESULTS_UPLOAD_PASSWORD: ${{ env.PDE_ORG_RESULTS_UPLOAD_PASSWORD }}
PDE_ORG_RESULTS_AGGREGATOR_UPLOAD_URL: ${{ env.PDE_ORG_RESULTS_AGGREGATOR_UPLOAD_URL }}
uses: ./.github/actions/common-tests

- name: Long-running tests
shell: bash
run: pytest -m "long_run" -vv -n auto --cov=./ --cov-report=xml --cov-append
run: pytest -m "long_run" -vv -n auto --cov=./ --cov-report=xml --cov-append --junit-xml=long-running-test-results.xml

- name: Upload jUnit test results (APDE CI)
shell: bash
if: ${{ env.PDE_ORG_RESULTS_AGGREGATOR_UPLOAD_URL != '' }}
run: >-
http --check-status --ignore-stdin
--auth "${{ env.PDE_ORG_RESULTS_AGGREGATOR_UPLOAD_USER }}:${{ env.PDE_ORG_RESULTS_UPLOAD_PASSWORD }}"
-f POST "${{ env.PDE_ORG_RESULTS_AGGREGATOR_UPLOAD_URL }}/api/results/upload/"
[email protected]
component_name=eda
git_commit_sha=${{ env.GIT_SHA }}
git_repository_url="https://github.com/${{ github.repository }}"

- name: e2e tests
env:
PDE_ORG_RESULTS_AGGREGATOR_UPLOAD_USER: ${{ env.PDE_ORG_RESULTS_AGGREGATOR_UPLOAD_USER }}
PDE_ORG_RESULTS_UPLOAD_PASSWORD: ${{ env.PDE_ORG_RESULTS_UPLOAD_PASSWORD }}
PDE_ORG_RESULTS_AGGREGATOR_UPLOAD_URL: ${{ env.PDE_ORG_RESULTS_AGGREGATOR_UPLOAD_URL }}
uses: ./.github/actions/e2e-tests
19 changes: 18 additions & 1 deletion .github/actions/common-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@ description: run common tests for ansible-rulebook (unit and integration)
runs:
using: composite
steps:
- name: Setup jUnit reporter
shell: bash
run: |
echo "GIT_SHA=$(git rev-parse "$GITHUB_SHA")" >> "$GITHUB_ENV"

- name: Run common tests
shell: bash
run: pytest -m "not e2e and not long_run" -vv -n auto --cov=./ --cov-report=xml
run: pytest -m "not e2e and not long_run" -vv -n auto --cov=./ --cov-report=xml --junit-xml=common-test-results.xml

- name: Upload jUnit test results (APDE CI)
shell: bash
if: ${{ env.PDE_ORG_RESULTS_AGGREGATOR_UPLOAD_URL != '' }}
run: >-
http --check-status --ignore-stdin
--auth "${{ env.PDE_ORG_RESULTS_AGGREGATOR_UPLOAD_USER }}:${{ env.PDE_ORG_RESULTS_UPLOAD_PASSWORD }}"
-f POST "${{ env.PDE_ORG_RESULTS_AGGREGATOR_UPLOAD_URL }}/api/results/upload/"
[email protected]
component_name=eda
git_commit_sha=${{ env.GIT_SHA }}
git_repository_url="https://github.com/${{ github.repository }}"
19 changes: 18 additions & 1 deletion .github/actions/e2e-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@ description: run e2e tests for ansible-rulebook
runs:
using: composite
steps:
- name: Setup jUnit reporter
shell: bash
run: |
echo "GIT_SHA=$(git rev-parse "$GITHUB_SHA")" >> "$GITHUB_ENV"

- name: Run e2e tests
shell: bash
run: pytest -m "e2e" -n auto --cov=./ --cov-report=xml --cov-append
run: pytest -m "e2e" -n auto --cov=./ --cov-report=xml --cov-append --junit-xml=e2e-test-results.xml

- name: Upload jUnit test results (APDE CI)
shell: bash
if: ${{ env.PDE_ORG_RESULTS_AGGREGATOR_UPLOAD_URL != '' }}
run: >-
http --check-status --ignore-stdin
--auth "${{ env.PDE_ORG_RESULTS_AGGREGATOR_UPLOAD_USER }}:${{ env.PDE_ORG_RESULTS_UPLOAD_PASSWORD }}"
-f POST "${{ env.PDE_ORG_RESULTS_AGGREGATOR_UPLOAD_URL }}/api/results/upload/"
[email protected]
component_name=eda
git_commit_sha=${{ env.GIT_SHA }}
git_repository_url="https://github.com/${{ github.repository }}"
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: All tests
env:
PDE_ORG_RESULTS_AGGREGATOR_UPLOAD_USER: ${{ vars.PDE_ORG_RESULTS_AGGREGATOR_UPLOAD_USER }}
Alex-Izquierdo marked this conversation as resolved.
Show resolved Hide resolved
PDE_ORG_RESULTS_UPLOAD_PASSWORD: ${{ secrets.PDE_ORG_RESULTS_UPLOAD_PASSWORD }}
PDE_ORG_RESULTS_AGGREGATOR_UPLOAD_URL: ${{ vars.PDE_ORG_RESULTS_AGGREGATOR_UPLOAD_URL }}
uses: ./.github/actions/all-tests

- name: Upload coverage to Codecov
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ coverage.xml
*.cover
.hypothesis/
.pytest_cache/
*-test-results.xml

# Translations
*.mo
Expand Down
1 change: 1 addition & 0 deletions requirements_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ oauthlib>=3.2.0
kubernetes
urllib3<2
aioresponses
httpie
Loading