@@ -66,12 +66,12 @@ jobs:
6666 with open(os.environ["GITHUB_OUTPUT"], "a") as file:
6767 file.write(output)
6868 - name : Generate Allure default test results
69- if : ${{ github.event_name == 'schedule ' && github.run_attempt == '1' }}
69+ if : ${{ github.event_name == 'workflow_dispatch ' && github.run_attempt == '1' }}
7070 run : tox run -e integration -- tests/integration --allure-default-dir=allure-default-results
7171 - name : Upload Allure default results
7272 # Default test results in case the integration tests time out or runner set up fails
7373 # (So that Allure report will show "unknown"/"failed" test result, instead of omitting the test)
74- if : ${{ github.event_name == 'schedule ' && github.run_attempt == '1' }}
74+ if : ${{ github.event_name == 'workflow_dispatch ' && github.run_attempt == '1' }}
7575 uses : actions/upload-artifact@v6
7676 with :
7777 name : allure-default-results-integration-test
@@ -125,7 +125,7 @@ jobs:
125125 # Only upload results from one spread system & one spread variant
126126 # Allure can only process one result per pytest test ID. If parameterization is done via
127127 # spread instead of pytest, there will be overlapping pytest test IDs.
128- if : ${{ (success() || (failure() && steps.spread.outcome == 'failure')) && startsWith(matrix.job.spread_job, 'github-ci:ubuntu-24.04:') && endsWith(matrix.job.spread_job, ':juju36') && github.event_name == 'schedule ' && github.run_attempt == '1' }}
128+ if : ${{ (success() || (failure() && steps.spread.outcome == 'failure')) && startsWith(matrix.job.spread_job, 'github-ci:ubuntu-24.04:') && endsWith(matrix.job.spread_job, ':juju36') && github.event_name == 'workflow_dispatch ' && github.run_attempt == '1' }}
129129 uses : actions/upload-artifact@v6
130130 with :
131131 name : allure-results-integration-test-${{ matrix.job.name_in_artifact }}
@@ -173,14 +173,30 @@ jobs:
173173 run : df --human-readable
174174
175175 allure-report :
176- # TODO future improvement: use concurrency group for job
177176 name : Publish Allure report
178- if : ${{ !cancelled() && github.event_name == 'schedule' && github.run_attempt == '1' }}
177+ if : ${{ !cancelled() && github.event_name == 'workflow_dispatch' && github.run_attempt == '1' }}
178+ concurrency :
179+ group : github-pages
180+ cancel-in-progress : false
179181 needs :
180182 - integration-test
181183 runs-on : ubuntu-latest
182184 timeout-minutes : 5
183185 steps :
186+ - name : Parse branch name
187+ id : branch
188+ shell : python
189+ run : |
190+ import os
191+
192+ if not "${{ github.ref }}".startswith("refs/heads/"):
193+ raise Exception(
194+ "Allure Report generation assumes `workflow_dispatch` is triggered on a branch"
195+ )
196+ output = f"branch={'${{ github.ref_name }}'.replace('/', '_')}"
197+ print(output)
198+ with open(os.environ["GITHUB_OUTPUT"], "a") as file:
199+ file.write(output)
184200 - name : Download Allure
185201 # Following instructions from https://allurereport.org/docs/install-for-linux/#install-from-a-deb-package
186202 run : gh release download --repo allure-framework/allure2 --pattern 'allure_*.deb'
@@ -260,10 +276,11 @@ jobs:
260276 default_result.path.rename(actual_results / default_result.path.name)
261277 - name : Load test report history
262278 run : |
263- if [[ -d repo/_latest/history/ ]]
279+ mkdir -p repo/${{ steps.branch.outputs.branch }}/
280+ if [[ -d repo/${{ steps.branch.outputs.branch }}/_latest/history/ ]]
264281 then
265282 echo 'Loading history'
266- cp -r repo/_latest/history/ allure-results/
283+ cp -r repo/${{ steps.branch.outputs.branch }}/ _latest/history/ allure-results/
267284 fi
268285 - name : Create executor.json
269286 shell : python
@@ -283,25 +300,56 @@ jobs:
283300 json.dump(DATA, file)
284301 - name : Generate Allure report
285302 run : allure generate
286- - name : Create index.html
303+ - name : Create top-level index.html
287304 shell : python
288305 run : |
289- DATA = f"""<!DOCTYPE html>
306+ DATA = """<!DOCTYPE html>
307+ <meta charset="utf-8">
308+ <ul id="branches"></ul>
309+ <style>
310+ ul {
311+ font-size: 2rem;
312+ }
313+ </style>
314+ <script type="module">
315+ const response = await fetch("https://api.github.com/repos/${{ github.repository }}/contents?ref=gh-pages-beta", {
316+ headers: {
317+ "Accept": "application/vnd.github.object+json",
318+ "X-GitHub-Api-Version": "2022-11-28",
319+ }
320+ });
321+ const result = await response.json();
322+ let branches = "";
323+ for (const entry of result["entries"]) {
324+ if (entry["type"] !== "dir") {
325+ continue;
326+ }
327+ branches += `<li><a href="${entry["path"]}/">${entry["path"]}</a></li>`;
328+ }
329+ document.getElementById("branches").innerHTML = branches;
330+ </script>
331+ """
332+ with open("repo/index.html", "w") as file:
333+ file.write(DATA)
334+ - name : Create branch index.html
335+ shell : python
336+ run : |
337+ DATA = """<!DOCTYPE html>
290338 <meta charset="utf-8">
291339 <meta http-equiv="cache-control" content="no-cache">
292340 <meta http-equiv="refresh" content="0; url=${{ github.run_number }}">
293341 """
294- with open("repo/index.html", "w") as file:
342+ with open("repo/${{ steps.branch.outputs.branch }}/ index.html", "w") as file:
295343 file.write(DATA)
296344 - name : Update GitHub pages branch
297- working-directory : repo/
345+ working-directory : repo/${{ steps.branch.outputs.branch }}/
298346 # TODO future improvement: commit message
299347 run : |
300348 mkdir '${{ github.run_number }}'
301349 rm -f _latest
302350 ln -s '${{ github.run_number }}' _latest
303- cp -r ../allure-report/. _latest/
304- git add .
351+ cp -r ../../ allure-report/. _latest/
352+ git add ..
305353 git config user.name "GitHub Actions"
306354 git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
307355 git commit -m "Allure report ${{ github.run_number }}"
0 commit comments