From 9e4bea3a1d3c419e867cc86f34c41fb947b50e5d Mon Sep 17 00:00:00 2001 From: Sadeq <3616518+msdousti@users.noreply.github.com> Date: Sun, 10 Nov 2024 22:16:11 +0100 Subject: [PATCH 1/3] Improve CI build speed --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 42aefd981..2745269ee 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -41,7 +41,7 @@ jobs: java-version: 17 cache: 'maven' - name: Compile - run: ./mvnw clean package -DskipTests + run: ./mvnw package -DskipTests -pl logbook-servlet -am - name: Test run: ./mvnw verify -P "${{ matrix.profile }}" -B - name: Coverage From fb8808e7c17375e0101430010eb54e02af65e6a3 Mon Sep 17 00:00:00 2001 From: Sadeq <3616518+msdousti@users.noreply.github.com> Date: Sun, 17 Nov 2024 23:24:56 +0100 Subject: [PATCH 2/3] Use run.sh to streamline build --- .github/workflows/build.yaml | 6 ++---- build.sh | 40 ++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 4 deletions(-) create mode 100755 build.sh 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 From 4b45602adf1f0eff93141d802a20d8f6ecd77e6f Mon Sep 17 00:00:00 2001 From: Sadeq Dousti <3616518+msdousti@users.noreply.github.com> Date: Mon, 9 Dec 2024 02:15:20 +0100 Subject: [PATCH 3/3] Add package command to build.sh --- build.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index e1c415670..2d5a7457d 100755 --- a/build.sh +++ b/build.sh @@ -10,19 +10,28 @@ INSTALL_CMD="./mvnw install -DskipTests -Djacoco.skip=true" # Flags to track selected options COMPILE=false NO_TEST_INSTALL=false +PACKAGE=false # Parse options while [[ "$#" -gt 0 ]]; do case $1 in + --package|-p) PACKAGE=true ;; --compile|-c) COMPILE=true ;; --no-test-install|-i) NO_TEST_INSTALL=true ;; -ci|-ic) COMPILE=true; NO_TEST_INSTALL=true ;; + -cp|-pc) PACKAGE=true; COMPILE=true ;; + -ip|-pi) PACKAGE=true; NO_TEST_INSTALL=true ;; *) echo "Unknown option: $1"; exit 1 ;; esac shift done # Execute commands based on the flags +if $PACKAGE; then + echo "Running package..." + eval "$PACKAGE_CMD" +fi + if $COMPILE; then echo "Running compile..." eval "$COMPILE_CMD" @@ -33,7 +42,7 @@ if $NO_TEST_INSTALL; then eval "$INSTALL_CMD" fi -if ! $COMPILE && ! $NO_TEST_INSTALL; then +if ! $COMPILE && ! $NO_TEST_INSTALL && ! $PACKAGE; then echo "Running default commands..." eval "$PACKAGE_CMD" eval "$VERIFY_CMD"