Skip to content

Commit 3366c88

Browse files
committed
setup testops
1 parent d420cff commit 3366c88

2 files changed

Lines changed: 89 additions & 2 deletions

File tree

.allurerc.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export default {
2+
name: "Allure Python",
3+
output: "./out/allure-report",
4+
plugins: {
5+
testops: {
6+
options: {
7+
launchName: `Allure Python GitHub actions run (${new Date().toISOString()})`,
8+
},
9+
},
10+
},
11+
};

.github/workflows/build.yaml

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ jobs:
3131
runs-on: ubuntu-latest
3232
outputs:
3333
packages: ${{ steps.filter.outputs.changes }}
34+
matrix: ${{ steps.matrix.outputs.matrix }}
35+
count: ${{ steps.matrix.outputs.count }}
3436
steps:
3537
- uses: dorny/paths-filter@v3
3638
id: filter
@@ -108,6 +110,7 @@ jobs:
108110
env:
109111
TEST_TMP: /tmp
110112
ALLURE_INDENT_OUTPUT: yep
113+
ALLURE_TEST_DUMP_NAME: allure-results-test-${{ matrix.python-version }}-pytest-${{ matrix.pytest-version }}
111114
steps:
112115
- uses: actions/checkout@v4
113116

@@ -116,6 +119,16 @@ jobs:
116119
with:
117120
python-version: ${{ matrix.python-version }}
118121

122+
- uses: actions/setup-node@v6
123+
with:
124+
node-version: '20.x'
125+
126+
- name: Normalize ALLURE_MATRIX_ENV
127+
run: |
128+
value="ubuntu-python-${{ matrix.python-version }}-pytest-${{ matrix.pytest-version }}"
129+
value="${value//./_}"
130+
echo "ALLURE_MATRIX_ENV=${value//\*/x}" >> "$GITHUB_ENV"
131+
119132
- name: Install packages
120133
run: |
121134
pip install ./allure-python-commons \
@@ -127,13 +140,20 @@ jobs:
127140
128141
- name: Test allure-pytest
129142
working-directory: allure-pytest
130-
run: poe tests
143+
run: npx -y allure@3 run --config ./.allurerc.mjs --rerun 2 --environment="${{ env.ALLURE_MATRIX_ENV }}" --dump="${{ env.ALLURE_TEST_DUMP_NAME }}" -- poe tests
144+
145+
- name: Upload report
146+
uses: actions/upload-artifact@v7
147+
with:
148+
name: ${{ env.ALLURE_TEST_DUMP_NAME }}
149+
path: ./${{ env.ALLURE_TEST_DUMP_NAME }}.zip
150+
retention-days: 1
131151

132152
test-others:
133153
name: Test other packages
134154
runs-on: ubuntu-latest
135155
needs: [other-changes]
136-
if: ${{ needs.other-changes.outputs.packages != '[]' }}
156+
if: ${{ needs.other-changes.outputs.count != '0' }}
137157
strategy:
138158
matrix:
139159
package: ${{ fromJSON(needs.other-changes.outputs.packages) }}
@@ -143,6 +163,7 @@ jobs:
143163
env:
144164
TEST_TMP: /tmp
145165
ALLURE_INDENT_OUTPUT: yep
166+
ALLURE_TEST_DUMP_NAME: allure-results-test-${{ matrix.package }}-python-${{ matrix.python-version }}
146167
steps:
147168
- uses: actions/checkout@v4
148169

@@ -151,6 +172,16 @@ jobs:
151172
with:
152173
python-version: ${{ matrix.python-version }}
153174

175+
- uses: actions/setup-node@v6
176+
with:
177+
node-version: '20.x'
178+
179+
- name: Normalize ALLURE_MATRIX_ENV
180+
run: |
181+
value="ubuntu-package-${{ matrix.package }}-python-${{ matrix.python-version }}"
182+
value="${value//./_}"
183+
echo "ALLURE_MATRIX_ENV=${value//\*/x}" >> "$GITHUB_ENV"
184+
154185
- name: Install packages
155186
run: |
156187
pip install ./allure-python-commons \
@@ -162,3 +193,48 @@ jobs:
162193
- name: Test ${{ matrix.package }}
163194
working-directory: ${{ matrix.package }}
164195
run: poe tests
196+
197+
- name: Upload report
198+
uses: actions/upload-artifact@v7
199+
with:
200+
name: ${{ env.ALLURE_TEST_DUMP_NAME }}
201+
path: ./${{ env.ALLURE_TEST_DUMP_NAME }}.zip
202+
retention-days: 1
203+
204+
report:
205+
needs: [test-pytest, test-others]
206+
name: Build Allure report
207+
runs-on: ubuntu-latest
208+
if: always()
209+
permissions:
210+
contents: read
211+
pull-requests: write
212+
checks: write
213+
env:
214+
ALLURE_TOKEN: ${{ secrets.ALLURE_TOKEN }}
215+
ALLURE_ENDPOINT: ${{ secrets.ALLURE_ENDPOINT }}
216+
ALLURE_PROJECT_ID: ${{ secrets.ALLURE_PROJECT_ID }}
217+
steps:
218+
- uses: actions/checkout@v6
219+
220+
- uses: actions/setup-node@v6
221+
with:
222+
node-version: '20.x'
223+
224+
- name: Download Allure dumps
225+
uses: actions/download-artifact@v8
226+
continue-on-error: true
227+
with:
228+
pattern: allure-results-*
229+
path: ./
230+
merge-multiple: true
231+
232+
- name: Generate Allure report
233+
run: npx -y allure@3 generate --config ./.allurerc.mjs --dump="allure-results-*.zip" --output=./out/allure-report
234+
235+
- name: Post Allure summary
236+
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false
237+
uses: allure-framework/allure-action@v0
238+
with:
239+
report-directory: ./out/allure-report
240+
github-token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)