Skip to content

Commit 6ec3429

Browse files
authored
[GHA] Improve CI build workflow (openhab#21254)
* Simplify checkout handling. Signed-off-by: Wouter Born <github@maindrain.net>
1 parent 679f433 commit 6ec3429

1 file changed

Lines changed: 36 additions & 18 deletions

File tree

.github/workflows/ci-build.yml

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,19 @@ jobs:
2020
matrix:
2121
java: [ '21' ]
2222
os: [ 'ubuntu-24.04' ]
23+
include:
24+
- primary: false
25+
- java: '21'
26+
primary: true
2327
name: Build (Java ${{ matrix.java }}, ${{ matrix.os }})
2428
runs-on: ${{ matrix.os }}
2529
# typical duration is ~70min, set twice the amount as limit (default is 6h)
2630
timeout-minutes: 140
2731
steps:
2832
- name: Checkout
29-
if: github.head_ref == ''
30-
uses: actions/checkout@v7
31-
32-
- name: Checkout merge
33-
if: github.head_ref != ''
3433
uses: actions/checkout@v7
3534
with:
36-
ref: refs/pull/${{github.event.pull_request.number}}/merge
37-
fetch-depth: 2
35+
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 1 }}
3836

3937
- name: Set up Cache
4038
uses: actions/cache@v6
@@ -53,8 +51,7 @@ jobs:
5351
java-version: ${{ matrix.java }}
5452

5553
- name: Register Problem Matchers
56-
if: ${{ matrix.java == '21' }}
57-
id: problem_matchers
54+
if: ${{ matrix.primary }}
5855
run: |
5956
echo "::add-matcher::.github/openhab-compile-problems.json"
6057
@@ -85,22 +82,42 @@ jobs:
8582
-Dmaven.wagon.httpconnectionManager.ttlSeconds=25
8683
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
8784
85+
- name: Prepare Uploads
86+
id: prepare-uploads
87+
if: ${{ !cancelled() && (steps.build.outcome == 'success' || steps.build.outcome == 'failure') }}
88+
shell: bash
89+
run: |
90+
uploads="$RUNNER_TEMP/uploads"
91+
mkdir -p "${uploads}"
92+
93+
if [[ -f build.log ]]; then
94+
cp build.log "${uploads}/build-log-java-${{ matrix.java }}-${{ matrix.os }}.txt"
95+
echo "build-log=true" >> "$GITHUB_OUTPUT"
96+
fi
97+
98+
if [[ -f target/summary_report.html ]]; then
99+
cp target/summary_report.html "${uploads}/sat-summary-report.html"
100+
echo "sat-report=true" >> "$GITHUB_OUTPUT"
101+
fi
102+
88103
- name: Upload Build Log
89-
if: ${{ always() && ((steps.build.outcome == 'success') || (steps.build.outcome == 'failure')) }}
104+
if: ${{ !cancelled() && steps.prepare-uploads.outputs.build-log == 'true' }}
90105
uses: actions/upload-artifact@v7
91106
with:
92-
name: build-log-java-${{ matrix.java }}-${{ matrix.os }}
93-
path: build.log
107+
path: ${{ runner.temp }}/uploads/build-log-java-${{ matrix.java }}-${{ matrix.os }}.txt
108+
archive: false
109+
if-no-files-found: error
94110

95111
- name: Upload SAT Summary Report
96-
if: ${{ always() && ((steps.build.outcome == 'success') || (steps.build.outcome == 'failure')) }}
112+
if: ${{ !cancelled() && matrix.primary && steps.prepare-uploads.outputs.sat-report == 'true' }}
97113
uses: actions/upload-artifact@v7
98114
with:
99-
name: sat-summary-report
100-
path: target/summary_report.html
115+
path: ${{ runner.temp }}/uploads/sat-summary-report.html
116+
archive: false
117+
if-no-files-found: error
101118

102119
- name: Report SAT Errors as Annotations
103-
if: ${{ matrix.java == '21' && always() && ((steps.build.outcome == 'success') || (steps.build.outcome == 'failure')) }}
120+
if: ${{ !cancelled() && matrix.primary && ((steps.build.outcome == 'success') || (steps.build.outcome == 'failure')) }}
104121
uses: ghys/checkstyle-github-action@main
105122
with:
106123
title: CheckStyle Violations
@@ -111,13 +128,14 @@ jobs:
111128
# untracked files will be included as well!
112129
- name: Verify Changed Files
113130
id: verify-changed-files
131+
if: ${{ !cancelled() }}
114132
run: |
115133
set -o pipefail
116-
changed_files=$(echo -n "$(git diff --name-only HEAD && git ls-files --others --exclude-standard)"|tr '\n' ' ')
134+
changed_files=$(echo -n "$(git diff --name-only HEAD && git ls-files --others --exclude-standard)" | tr '\n' ' ')
117135
echo "changed_files=$changed_files" >> $GITHUB_OUTPUT
118136
119137
- name: Fail on Changed Files
120-
if: steps.verify-changed-files.outputs.changed_files != ''
138+
if: ${{ !cancelled() && steps.verify-changed-files.outputs.changed_files != '' }}
121139
env:
122140
CHANGED_FILES: ${{ steps.verify-changed-files.outputs.changed_files }}
123141
run: |

0 commit comments

Comments
 (0)