Skip to content

Commit

Permalink
Simplify CI-PR
Browse files Browse the repository at this point in the history
Removed checks for changed modules and ensure the build scripts works in the absence of credentials.

See #550
  • Loading branch information
corneil committed Nov 11, 2024
1 parent f7d502b commit aaf8f47
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 101 deletions.
106 changes: 17 additions & 89 deletions .github/workflows/ci-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,10 @@ jobs:
shell: bash
run: find . -type f -name "*.sh" -exec chmod a+x '{}' \;
- name: 'Configure: Install Java'
if: ${{ github.base_ref != 'main' }}
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
java-version: 17
- name: 'Configure: Install GraalVM'
if: ${{ github.base_ref == 'main' }}
uses: graalvm/setup-graalvm@v1
with:
version: 'latest'
java-version: '17'
components: 'js'
github-token: ${{ secrets.GITHUB_TOKEN }}
java-version: '17.0.12'
distribution: 'graalvm'
- name: 'Configure: cache for maven dependencies'
uses: actions/cache@v3
with:
Expand All @@ -49,81 +41,24 @@ jobs:
maven-repo-
- name: 'Configure: Install xsltproc'
uses: ./.github/actions/install-xsltproc
- name: 'Action: verify changed modules'
- name: 'Action: Build Core'
shell: bash
env:
VERBOSE: ${{ github.debug && 'true' || '' }}
ARTIFACTORY_USERNAME: 'anonymous'
ARTIFACTORY_PASSWORD: 'anonymous'
run: |
export SKIP_DEPLOY=true
./build-core.sh "-T 1C package -Psnapshot"
- name: 'Action: Build Apps'
shell: bash
env:
VERBOSE: ${{ github.debug && 'true' || '' }}
ARTIFACTORY_USERNAME: 'anonymous'
ARTIFACTORY_PASSWORD: 'anonymous'
run: |
PR=$(echo "${{ github.ref_name }}" | grep -o '[[:digit:]]*')
echo "Checking out pull request #$PR"
gh pr checkout $PR
BUILD_DIR=$(realpath $MAIN_PATH)
echo "Changed files:"
gh pr diff --name-only
CHANGED=$(gh pr diff --name-only)
$BUILD_DIR/scripts/determine-modules-changed.sh "$CHANGED"
MODULES=$(jq '.[]' modules.json | sed 's/\"//g')
FOLDERS=
ROOT_MODULES=
if [ "$MAVEN_THREADS" = "true" ]; then
MVN_THR="-T 0.5C"
else
MVN_THR=
fi
MAVEN_OPTS="-s $BUILD_DIR/.settings.xml -B -U $MVN_THR"
echo "VERBOSE=$VERBOSE"
if [ "$VERBOSE" = "true" ]; then
MAVEN_OPTS="-X $MAVEN_OPTS"
fi
for module in $MODULES; do
if [[ "$module" == *"/"* ]]; then
if [ "$FOLDERS" = "" ]; then
FOLDERS="$module"
else
FOLDERS="$FOLDERS,$module"
fi
else
if [ "$ROOT_MODULES" == "" ]; then
ROOT_MODULES=$module
else
ROOT_MODULES="$ROOT_MODULES,$module"
fi
fi
done
set +e
if [ "$ROOT_MODULES" != "" ]; then
# Module with no / are probably a root module that contains other modules and will trigger a lot of dependant builds without real value
echo "::info ::building $ROOT_MODULES"
echo "::debug ::MAVEN:./mvnw $MAVEN_OPTS -pl $ROOT_MODULES install"
./mvnw $MAVEN_OPTS -pl $ROOT_MODULES install
RC=$?
if ((RC!=0)); then
exit $RC
fi
fi
if [ "$FOLDERS" != "" ]; then
echo "::info ::verify $FOLDERS and dependents"
echo "::debug ::MAVEN:./mvnw $MAVEN_OPTS -amd -pl $FOLDERS install"
./mvnw $MAVEN_OPTS -amd -pl $FOLDERS install
RC=$?
if ((RC!=0)); then
exit $RC
fi
fi
# Build any applications that was compiled but don't deploy to artifactory.
PROCESSORS=$(find ./applications/processor -name target -exec ./parent-dir '{}' \;)
SINKS=$(find ./applications/sink -name target -exec ./parent-dir '{}' \;)
SOURCES=$(find ./applications/source -name target -exec ./parent-dir '{}' \;)
# true as 3rd argument ensures that jars aren't deployed and containers aren't built.
for appdir in $PROCESSORS; do
./build-app.sh . "./$appdir" true
done
for appdir in $SOURCES; do
./build-app.sh . "./$appdir" true
done
for appdir in $SINKS; do
./build-app.sh . "./$appdir" true
done
export SKIP_DEPLOY=true
./build-apps.sh "-T 1C package -Psnapshot"
- name: 'Upload: Error logs'
if: ${{ failure() }}
uses: actions/upload-artifact@v3
Expand All @@ -135,10 +70,3 @@ jobs:
- name: 'Built'
shell: bash
run: echo "::info ::Built"
done:
runs-on: ubuntu-latest
needs: [ build ]
steps:
- name: 'Done'
shell: bash
run: echo "::info ::Done"
10 changes: 6 additions & 4 deletions build-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ pushd "$PROJECT_FOLDER" >/dev/null
else
MAVEN_GOAL="install verify deploy"
fi
if [[ "$MAVEN_GOAL" == *"deploy"* ]]; then
if [[ "$MAVEN_GOAL" == *"deploy"* ]] && [ "$SKIP_DEPLOY" != "true" ]; then
check_env ARTIFACTORY_USERNAME
check_env ARTIFACTORY_PASSWORD
fi
if [[ "$VERSION" == "4."* ]]; then
JDKS="17"
if [[ "$VERSION" != "3."* ]]; then
JDKS="17 21"
if [ "$DEFAULT_JDK" == "" ]; then
DEFAULT_JDK=17
fi
Expand Down Expand Up @@ -90,9 +90,11 @@ pushd "$PROJECT_FOLDER" >/dev/null
if [ "$SKIP_DEPLOY" == "" ] || [ "$SKIP_DEPLOY" == "false" ]; then
for v in $JDKS; do
echo "Pack:$app:$VERSION-jdk$v"
set -e
pack build \
--pull-policy if-not-present \
--path "target/$app-$VERSION.jar" \
--builder gcr.io/paketo-buildpacks/builder:base \
--builder paketobuildpacks/builder-jammy-base:latest \
--env BP_JVM_VERSION=$v \
--env BPE_APPEND_JDK_JAVA_OPTIONS=-Dfile.encoding=UTF-8 \
--env BPE_APPEND_JDK_JAVA_OPTIONS=-Dsun.jnu.encoding \
Expand Down
2 changes: 1 addition & 1 deletion build-core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ if [ "$1" = "" ]; then
else
MAVEN_GOAL="$*"
fi

set -e
$SCDIR/build-folder.sh stream-applications-build,functions,applications/stream-applications-core "$MAVEN_GOAL"
12 changes: 8 additions & 4 deletions build-folder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,18 @@ function check_env() {
fi
}

if [ "$1" == "" ]; then
echo -e "Options: ${bold} <comma-separated-folders> [<maven-goals>]*${end}"
exit 1
fi
if [ "$VERBOSE" = "true" ]; then
MAVEN_OPTS="-X"
elif [ "$VERBOSE" = "false" ]; then
MAVEN_OPTS="-q"
fi
MAVEN_OPTS="$MAVEN_OPTS -s $SCDIR/.settings.xml -B"
if [ "$1" == "" ]; then
echo -e "Options: ${bold} <comma-separated-folders> [<maven-goals>]*${end}"
MAVEN_OPTS="$MAVEN_OPTS -B"
if [ "$SKIP_DEPLOY" != "true" ]; then
MAVEN_OPTS="$MAVEN_OPTS -s $SCDIR/.settings.xml"
fi
FOLDER_NAMES="$1"
shift
Expand Down Expand Up @@ -83,7 +87,7 @@ for FOLDER in $FOLDER_NAMES; do
done
# IFS will affect mvnw ability to split arguments.
IFS=$SAVED_IFS
if [[ "$MAVEN_GOAL" == *"deploy"* ]]; then
if [[ "$MAVEN_GOAL" == *"deploy"* ]] && [ "$SKIP_DEPLOY" != "true" ]; then
check_env ARTIFACTORY_USERNAME
check_env ARTIFACTORY_PASSWORD
fi
Expand Down
9 changes: 6 additions & 3 deletions local/pack-containers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ for app in ${PROCESSORS[@]}; do
TARGET_FILE="$APP_PATH/$app-$BROKER-$TAG.jar"
if [ -f "$TARGET_FILE" ]; then
pack build \
--pull-policy if-not-present \
--path "$TARGET_FILE" \
--builder gcr.io/paketo-buildpacks/builder:base \
--builder paketobuildpacks/builder-jammy-base:latest \
--env BP_JVM_VERSION=$v \
--env BPE_APPEND_JDK_JAVA_OPTIONS=-Dfile.encoding=UTF-8 \
--env BPE_APPEND_JDK_JAVA_OPTIONS=-Dsun.jnu.encoding \
Expand Down Expand Up @@ -105,8 +106,9 @@ for app in ${SINKS[@]}; do
TARGET_FILE="$APP_PATH/$app-$BROKER-$TAG.jar"
if [ -f "$TARGET_FILE" ]; then
pack build \
--pull-policy if-not-present \
--path "$TARGET_FILE" \
--builder gcr.io/paketo-buildpacks/builder:base \
--builder paketobuildpacks/builder-jammy-base:latest \
--env BP_JVM_VERSION=$v \
--env BPE_APPEND_JDK_JAVA_OPTIONS=-Dfile.encoding=UTF-8 \
--env BPE_APPEND_JDK_JAVA_OPTIONS=-Dsun.jnu.encoding \
Expand Down Expand Up @@ -134,8 +136,9 @@ for app in ${SOURCES[@]}; do
TARGET_FILE="$APP_PATH/$app-$BROKER-$TAG.jar"
if [ -f "$TARGET_FILE" ]; then
pack build \
--pull-policy if-not-present \
--path "$TARGET_FILE" \
--builder gcr.io/paketo-buildpacks/builder:base \
--builder paketobuildpacks/builder-jammy-base:latest \
--env BP_JVM_VERSION=$v \
--env BPE_APPEND_JDK_JAVA_OPTIONS=-Dfile.encoding=UTF-8 \
--env BPE_APPEND_JDK_JAVA_OPTIONS=-Dsun.jnu.encoding \
Expand Down

0 comments on commit aaf8f47

Please sign in to comment.