Skip to content

Commit 262f523

Browse files
committed
setup testops
1 parent d420cff commit 262f523

2 files changed

Lines changed: 87 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: 76 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,15 @@ 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+
echo "ALLURE_MATRIX_ENV=${value//./_}" >> "$GITHUB_ENV"
130+
119131
- name: Install packages
120132
run: |
121133
pip install ./allure-python-commons \
@@ -127,13 +139,20 @@ jobs:
127139
128140
- name: Test allure-pytest
129141
working-directory: allure-pytest
130-
run: poe tests
142+
run: npx -y allure@3 run --config ./.allurerc.mjs --rerun 2 --environment="${{ env.ALLURE_MATRIX_ENV }}" --dump="${{ env.ALLURE_TEST_DUMP_NAME }}" -- poe tests
143+
144+
- name: Upload report
145+
uses: actions/upload-artifact@v7
146+
with:
147+
name: ${{ env.ALLURE_TEST_DUMP_NAME }}
148+
path: ./${{ env.ALLURE_TEST_DUMP_NAME }}.zip
149+
retention-days: 1
131150

132151
test-others:
133152
name: Test other packages
134153
runs-on: ubuntu-latest
135154
needs: [other-changes]
136-
if: ${{ needs.other-changes.outputs.packages != '[]' }}
155+
if: ${{ needs.other-changes.outputs.count != '0' }}
137156
strategy:
138157
matrix:
139158
package: ${{ fromJSON(needs.other-changes.outputs.packages) }}
@@ -143,6 +162,7 @@ jobs:
143162
env:
144163
TEST_TMP: /tmp
145164
ALLURE_INDENT_OUTPUT: yep
165+
ALLURE_TEST_DUMP_NAME: allure-results-test-${{ matrix.package }}-python-${{ matrix.python-version }}
146166
steps:
147167
- uses: actions/checkout@v4
148168

@@ -151,6 +171,15 @@ jobs:
151171
with:
152172
python-version: ${{ matrix.python-version }}
153173

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

0 commit comments

Comments
 (0)