diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 2745269ee..acad45b0f 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -40,10 +40,8 @@ jobs: distribution: temurin java-version: 17 cache: 'maven' - - name: Compile - run: ./mvnw package -DskipTests -pl logbook-servlet -am - - name: Test - run: ./mvnw verify -P "${{ matrix.profile }}" -B + - name: Compile & test + run: ./build.sh - name: Coverage if: github.event_name != 'pull_request' run: ./mvnw -P coverage coveralls:report -B -D repoToken=${{ secrets.COVERALLS_TOKEN }} diff --git a/build.sh b/build.sh new file mode 100755 index 000000000..e1c415670 --- /dev/null +++ b/build.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +set -euxo pipefail + +# Define default commands +COMPILE_CMD="./mvnw compile" +PACKAGE_CMD="./mvnw package -DskipTests -pl logbook-servlet -am" +VERIFY_CMD="./mvnw verify -B" +INSTALL_CMD="./mvnw install -DskipTests -Djacoco.skip=true" + +# Flags to track selected options +COMPILE=false +NO_TEST_INSTALL=false + +# Parse options +while [[ "$#" -gt 0 ]]; do + case $1 in + --compile|-c) COMPILE=true ;; + --no-test-install|-i) NO_TEST_INSTALL=true ;; + -ci|-ic) COMPILE=true; NO_TEST_INSTALL=true ;; + *) echo "Unknown option: $1"; exit 1 ;; + esac + shift +done + +# Execute commands based on the flags +if $COMPILE; then + echo "Running compile..." + eval "$COMPILE_CMD" +fi + +if $NO_TEST_INSTALL; then + echo "Running install without tests..." + eval "$INSTALL_CMD" +fi + +if ! $COMPILE && ! $NO_TEST_INSTALL; then + echo "Running default commands..." + eval "$PACKAGE_CMD" + eval "$VERIFY_CMD" +fi