Skip to content

Commit 91519e8

Browse files
SONARJAVA-6211 Upload artifacts if ruling or autoscan fails (#5532)
1 parent 560700b commit 91519e8

2 files changed

Lines changed: 65 additions & 0 deletions

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Upload Actual Results
2+
description: Upload test artifacts and diffs when an integration test fails
3+
4+
inputs:
5+
name:
6+
description: Name used for the uploaded artifacts. We upload actual_name and diff_name.
7+
required: true
8+
it-dir:
9+
description: Path to integration tests.
10+
required: true
11+
expected-dir:
12+
description: Relative path to expected test results.
13+
required: true
14+
actual-dir:
15+
description: Relative path to actual test results.
16+
required: true
17+
18+
env:
19+
RETENTION_DAYS: 7
20+
21+
runs:
22+
using: composite
23+
steps:
24+
- name: Upload Actual Results
25+
uses: actions/upload-artifact@v4
26+
with:
27+
name: actual_${{ inputs.name }}
28+
path: ${{ inputs.it-dir }}/${{ inputs.actual-dir }}
29+
retention-days: ${{ env.RETENTION_DAYS }}
30+
31+
- name: Generate Diff Report
32+
shell: bash
33+
env:
34+
IT_DIR: ${{ inputs.it-dir }}
35+
EXPECTED_DIR: ${{ inputs.expected-dir }}
36+
ACTUAL_DIR: ${{ inputs.actual-dir }}
37+
NAME: ${{ inputs.name }}
38+
run: |
39+
cd "${IT_DIR}"
40+
mkdir -p target
41+
diff --unified --recursive --strip-trailing-cr "${EXPECTED_DIR}" "${ACTUAL_DIR}" > "target/test.diff" || true
42+
npx diff2html-cli --input file --style side --file "target/diff_${NAME}.html" -- "target/test.diff"
43+
44+
- name: Upload Diff Report
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: diff_${{ inputs.name }}
48+
path: ${{ inputs.it-dir }}/target/diff_${{ inputs.name }}.html
49+
retention-days: ${{ env.RETENTION_DAYS }}

.github/workflows/build.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ jobs:
9898
run: |
9999
cd its/ruling
100100
mvn package --batch-mode "-Pit-ruling,${{ matrix.item.profile }}" -Dsonar.runtimeVersion=LATEST_RELEASE -Dmaven.test.redirectTestOutputToFile=false -B -e -V -Dparallel=methods -DuseUnlimitedThreads=true
101+
- name: Upload Actual Results On Failure
102+
if: failure()
103+
uses: ./.github/actions/upload-actual
104+
with:
105+
name: ${{ matrix.item.runner }}_${{ matrix.item.profile }}
106+
it-dir: its/ruling
107+
expected-dir: src/test/resources
108+
actual-dir: target/actual
101109

102110
plugin-qa:
103111
strategy:
@@ -323,6 +331,14 @@ jobs:
323331
-Dmaven.test.redirectTestOutputToFile=false
324332
-Dparallel=methods
325333
-DuseUnlimitedThreads=true
334+
- name: Upload Actual Results On Failure
335+
if: failure()
336+
uses: ./.github/actions/upload-actual
337+
with:
338+
name: autoscan
339+
it-dir: its/autoscan
340+
expected-dir: src/test/resources/autoscan/diffs
341+
actual-dir: target/actual/autoscan-diffs
326342

327343
qa-os-win:
328344
name: Build and Unit Test on Windows

0 commit comments

Comments
 (0)