Skip to content

Commit 4562015

Browse files
authored
Use Maven wrapper and replace verify-changed-files check in GHA (#70)
This reduces reliance on third-party GitHub Actions and hardens the workflow by: - Switching to the Maven wrapper (mvnw) for consistent builds - Replacing the verify-changed-files check with a native implementation Signed-off-by: Wouter Born <github@maindrain.net>
1 parent b93ab40 commit 4562015

5 files changed

Lines changed: 437 additions & 10 deletions

File tree

.github/scripts/maven-build

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function mvnp() {
1818
set -o pipefail # exit build with error when pipes fail
1919
local reactor_size=$(find -name "pom.xml" | grep -vE '/src/|/target/' | wc -l)
2020
local padding=$(bc -l <<< "scale=0;2*(l($reactor_size)/l(10)+1)")
21-
local command=(mvn $@)
21+
local command=(./mvnw $@)
2222
exec "${command[@]}" 2>&1 | # execute, redirect stderr to stdout
2323
tee "$BUILD_LOG" | # write output to log
2424
stdbuf -oL grep -aE '^\[INFO\] Building .+ \[.+\]$' | # filter progress
@@ -30,7 +30,7 @@ function build_all() {
3030
echo
3131
echo "Building all projects"
3232
echo
33-
echo "+ mvn $ARGUMENTS"
33+
echo "+ ./mvnw $ARGUMENTS"
3434
echo
3535

3636
mvnp $ARGUMENTS
@@ -47,5 +47,5 @@ function build_all() {
4747
exit $status
4848
}
4949

50-
mvn -v
50+
./mvnw -v
5151
build_all

.github/workflows/ci-build.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ jobs:
1919
fail-fast: false
2020
matrix:
2121
java: [ '21' ]
22-
maven: [ '3.9.10']
2322
os: [ 'ubuntu-24.04' ]
2423
name: Build (Java ${{ matrix.java }}, ${{ matrix.os }})
2524
runs-on: ${{ matrix.os }}
@@ -50,11 +49,6 @@ jobs:
5049
distribution: 'temurin'
5150
java-version: ${{ matrix.java }}
5251

53-
- name: Set up Maven ${{ matrix.maven }}
54-
uses: stCarolas/setup-maven@v5
55-
with:
56-
maven-version: ${{ matrix.maven }}
57-
5852
- name: Build
5953
id: build
6054
run: './.github/scripts/maven-build'
@@ -72,9 +66,14 @@ jobs:
7266
name: build-log-java-${{ matrix.java }}-${{ matrix.os }}
7367
path: build.log
7468

69+
# this will identify modifications to files under source control during the workflow run;
70+
# untracked files will be included as well!
7571
- name: Verify Changed Files
76-
uses: tj-actions/verify-changed-files@v20
7772
id: verify-changed-files
73+
run: |
74+
set -o pipefail
75+
changed_files=$(echo -n "$(git diff --name-only HEAD && git ls-files --others --exclude-standard)"|tr '\n' ' ')
76+
echo "changed_files=$changed_files" >> $GITHUB_OUTPUT
7877
7978
- name: Fail on Changed Files
8079
if: steps.verify-changed-files.outputs.changed_files != ''
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
wrapperVersion=3.3.2
18+
distributionType=only-script
19+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.11/apache-maven-3.9.11-bin.zip
20+
distributionSha256Sum=0d7125e8c91097b36edb990ea5934e6c68b4440eef4ea96510a0f6815e7eeadb

mvnw

Lines changed: 259 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)