Skip to content

Commit c4b7fd5

Browse files
authored
Tempest QOL improvments (run previous failed and detailed reporting) (#24)
* feat: add support for running only failed tests from previous runs * feat: add support for detailed test report in `GitHub` * fix: use `double quotes` for `loadlist` * feat: pin `mikepenz/action-junit-report`
1 parent feb3e88 commit c4b7fd5

File tree

3 files changed

+54
-3
lines changed

3 files changed

+54
-3
lines changed

roles/github/templates/run-tempest.yml.j2

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ jobs:
1919
%% format_file_name(workflow.file_name) %%:
2020
runs-on: %% github_runs_on %%
2121
permissions:
22+
actions: read
2223
contents: read
2324
packages: %% 'read' if (github_registry.url | default(github_default_registry.url)) == 'ghcr.io' else 'none' %%
25+
checks: write
2426
container:
2527
image: %% github_registry.url | default(github_default_registry.url) %%/%% github_image_name %%:%% github_image_tag %%
2628
credentials:
@@ -44,10 +46,43 @@ jobs:
4446
- name: Symlink source checkout to expected location
4547
run: sudo ln -s $PWD/kayobe-config /src
4648

49+
- name: Get Previous Workflow Run
50+
uses: actions/github-script@v6
51+
id: get_previous_run
52+
if: ${{ inputs.run_previous_failed }}
53+
with:
54+
script: |
55+
let result = ${{ inputs.previous_workflow_id || 0 }};
56+
const workflow_id = 'run-tempest.yml';
57+
if (result <= 0) {
58+
const { data: response } = await github.rest.actions.listWorkflowRuns({
59+
owner: context.repo.owner,
60+
repo: context.repo.repo,
61+
workflow_id,
62+
per_page: 2,
63+
});
64+
result = response.workflow_runs[1].id;
65+
}
66+
return result;
67+
result-encoding: string
68+
69+
- name: Download previous Tempest test artifacts
70+
uses: actions/download-artifact@v4
71+
id: previous_artifacts
72+
if: ${{ inputs.run_previous_failed }}
73+
with:
74+
name: tempest-artifacts
75+
github-token: ${{ secrets.GITHUB_TOKEN }}
76+
run-id: ${{ steps.get_previous_run.outputs.result }}
77+
78+
- name: Symlink failed tests
79+
if: ${{ inputs.run_previous_failed }}
80+
run: sudo ln -s ${{ steps.previous_artifacts.outputs.download-path }}/failed-tests /src/.automation.conf/tempest/load-lists/previous-failed-tests
81+
4782
<% if github_kayobe_hook | length >= 1 %>
4883
%% github_kayobe_hook | indent(width=6, first=false) %%
4984
<% endif %>
50-
- name: Run ${{ github.event.inputs.test_suite }} tempest testsuite
85+
- name: Run ${{ inputs.run_previous_failed == false && github.event.inputs.test_suite || 'previous failed tests' }} tempest testsuite
5186
run: |
5287
/src/.automation/pipeline/tempest.sh -e ansible_user=stack
5388
env:
@@ -56,7 +91,7 @@ jobs:
5691
<% endif %>
5792
KAYOBE_VAULT_PASSWORD: "%% github_kayobe_arguments.KAYOBE_VAULT_PASSWORD | default(github_default_kayobe_arguments.KAYOBE_VAULT_PASSWORD) %%"
5893
KAYOBE_AUTOMATION_SSH_PRIVATE_KEY: "%% github_kayobe_arguments.KAYOBE_AUTOMATION_SSH_PRIVATE_KEY | default(github_default_kayobe_arguments.KAYOBE_AUTOMATION_SSH_PRIVATE_KEY) %%"
59-
KAYOBE_AUTOMATION_TEMPEST_LOADLIST: '%% github_kayobe_arguments.KAYOBE_AUTOMATION_TEMPEST_LOADLIST | default(github_default_kayobe_arguments.KAYOBE_AUTOMATION_TEMPEST_LOADLIST) %%'
94+
KAYOBE_AUTOMATION_TEMPEST_LOADLIST: "%% github_kayobe_arguments.KAYOBE_AUTOMATION_TEMPEST_LOADLIST | default(github_default_kayobe_arguments.KAYOBE_AUTOMATION_TEMPEST_LOADLIST) %%"
6095
TEMPEST_PATTERN: '%% github_kayobe_arguments.TEMPEST_PATTERN | default(github_default_kayobe_arguments.TEMPEST_PATTERN) %%'
6196
TEMPEST_OPENRC: "%% github_kayobe_arguments.TEMPEST_OPENRC | default(github_default_kayobe_arguments.TEMPEST_OPENRC) %%"
6297
HOME: '%% github_kayobe_arguments.HOME | default(github_default_kayobe_arguments.HOME) %%'
@@ -79,3 +114,10 @@ jobs:
79114
<% if github_final_hook | length >= 1 +%>
80115
%% github_final_hook | indent(width=6, first=false) -%%
81116
<% endif %>
117+
118+
- name: Publish Test Report
119+
uses: mikepenz/action-junit-report@db71d41eb79864e25ab0337e395c352e84523afe # v4.3.1
120+
if: success() || failure()
121+
with:
122+
report_paths: /stack/tempest-artifacts/rally-junit.xml
123+
check_name: Tempest Test Report ${{ github.run_id }} @ ${{ github.run_attempt }}

roles/github/templates/tempest-header.yml.j2

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ on:
2626
tempest_pattern:
2727
description: |
2828
Limit tests to this regex. Takes precedence over testSuite.
29+
run_previous_failed:
30+
description: |
31+
Only run the tests from the previous failed Tempest run.
32+
type: boolean
33+
previous_workflow_id:
34+
description: |
35+
Specify the previous Tempest workflow to extract failed tests from,
36+
will default to last available workflow if unset.
37+
type: number
2938
{%- if github_environment_selector == 'input' +%}
3039
{{ github_kayobe_environment_input | flatten | join('') | indent(6) | trim }}
3140
{%- endif +%}

roles/github/vars/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ github_default_kayobe_arguments:
1919
KAYOBE_AUTOMATION_PR_TYPE: github
2020
KAYOBE_AUTOMATION_PR_TITLE: !unsafe "[kayobe-automation] ${{ github.workflow }} #${{ github.run_id }}"
2121
KAYOBE_AUTOMATION_PR_URL: !unsafe https://api.github.com/repos/${{ github.repository }}/pulls
22-
KAYOBE_AUTOMATION_TEMPEST_LOADLIST: !unsafe "${{ github.event.inputs.test_suite }}"
22+
KAYOBE_AUTOMATION_TEMPEST_LOADLIST: !unsafe "${{ inputs.run_previous_failed == false && github.event.inputs.test_suite || 'previous-failed-tests' }}"
2323
TEMPEST_PATTERN: !unsafe "${{ github.event.inputs.tempest_pattern }}"
2424
TEMPEST_OPENRC: !unsafe "${{ secrets.TEMPEST_OPENRC }}"
2525
HOME: /stack

0 commit comments

Comments
 (0)