@@ -77,141 +77,3 @@ jobs:
7777 with :
7878 artifact-prefix : ${{ needs.build.outputs.artifact-prefix }}
7979 secrets : inherit
80-
81- # TODO: Remove before merging
82- allure-report :
83- name : Publish Allure report
84- if : ${{ !cancelled() && github.run_attempt == '1' }}
85- needs :
86- - integration-test
87- runs-on : ubuntu-latest
88- timeout-minutes : 5
89- permissions :
90- contents : write
91- steps :
92- - name : Download Allure
93- # Following instructions from https://allurereport.org/docs/install-for-linux/#install-from-a-deb-package
94- run : gh release download --repo allure-framework/allure2 --pattern 'allure_*.deb'
95- env :
96- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
97- - name : Install Allure
98- run : |
99- sudo apt-get update
100- sudo apt-get install ./allure_*.deb -y
101- # For first run, manually create branch with no history
102- # (e.g.
103- # git checkout --orphan gh-pages-beta
104- # git rm -rf .
105- # touch .nojekyll
106- # git add .nojekyll
107- # git commit -m "Initial commit"
108- # git push origin gh-pages-beta
109- # )
110- - name : Checkout GitHub pages branch
111- uses : actions/checkout@v5
112- with :
113- ref : gh-pages-beta
114- path : repo/
115- - name : Download default test results
116- # Default test results in case the integration tests time out or runner set up fails
117- # (So that Allure report will show "unknown"/"failed" test result, instead of omitting the test)
118- uses : actions/download-artifact@v5
119- with :
120- path : allure-default-results/
121- name : allure-default-results-integration-test
122- - name : Download test results
123- uses : actions/download-artifact@v5
124- with :
125- path : allure-results/
126- pattern : allure-results-integration-test-*
127- merge-multiple : true
128- - name : Combine Allure default results & actual results
129- # For every test: if actual result available, use that. Otherwise, use default result
130- # So that, if actual result not available, Allure report will show "unknown"/"failed" test result
131- # instead of omitting the test
132- shell : python
133- run : |
134- import dataclasses
135- import json
136- import pathlib
137-
138-
139- @dataclasses.dataclass(frozen=True)
140- class Result:
141- test_case_id: str
142- path: pathlib.Path
143-
144- def __eq__(self, other):
145- if not isinstance(other, type(self)):
146- return False
147- return self.test_case_id == other.test_case_id
148-
149-
150- actual_results = pathlib.Path("allure-results")
151- default_results = pathlib.Path("allure-default-results")
152-
153- results: dict[pathlib.Path, set[Result]] = {
154- actual_results: set(),
155- default_results: set(),
156- }
157- for directory, results_ in results.items():
158- for path in directory.glob("*-result.json"):
159- with path.open("r") as file:
160- id_ = json.load(file)["testCaseId"]
161- results_.add(Result(id_, path))
162-
163- actual_results.mkdir(exist_ok=True)
164-
165- missing_results = results[default_results] - results[actual_results]
166- for default_result in missing_results:
167- # Move to `actual_results` directory
168- default_result.path.rename(actual_results / default_result.path.name)
169- - name : Load test report history
170- run : |
171- if [[ -d repo/_latest/history/ ]]
172- then
173- echo 'Loading history'
174- cp -r repo/_latest/history/ allure-results/
175- fi
176- - name : Create executor.json
177- shell : python
178- run : |
179- # Reverse engineered from https://github.com/simple-elf/allure-report-action/blob/eca283b643d577c69b8e4f048dd6cd8eb8457cfd/entrypoint.sh
180- import json
181-
182- DATA = {
183- "name": "GitHub Actions",
184- "type": "github",
185- "buildOrder": ${{ github.run_number }}, # TODO future improvement: use run ID
186- "buildName": "Run ${{ github.run_id }}",
187- "buildUrl": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
188- "reportUrl": "../${{ github.run_number }}/",
189- }
190- with open("allure-results/executor.json", "w") as file:
191- json.dump(DATA, file)
192- - name : Generate Allure report
193- run : allure generate
194- - name : Create index.html
195- shell : python
196- run : |
197- DATA = f"""<!DOCTYPE html>
198- <meta charset="utf-8">
199- <meta http-equiv="cache-control" content="no-cache">
200- <meta http-equiv="refresh" content="0; url=${{ github.run_number }}">
201- """
202- with open("repo/index.html", "w") as file:
203- file.write(DATA)
204- - name : Update GitHub pages branch
205- working-directory : repo/
206- # TODO future improvement: commit message
207- run : |
208- mkdir '${{ github.run_number }}'
209- rm -f _latest
210- ln -s '${{ github.run_number }}' _latest
211- cp -r ../allure-report/. _latest/
212- git add .
213- git config user.name "GitHub Actions"
214- git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
215- git commit -m "Allure report ${{ github.run_number }}"
216- # Uses token set in checkout step
217- git push origin gh-pages-beta
0 commit comments