-
-
Notifications
You must be signed in to change notification settings - Fork 759
Add build-changed task in Java workflow #3125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| #!/usr/bin/env bash | ||
| set -eo pipefail | ||
|
|
||
| # Determine the base branch of the PR | ||
| BASE_BRANCH=${GITHUB_BASE_REF:-main} | ||
|
|
||
| # Fetch full history for proper diff | ||
| git fetch origin "$BASE_BRANCH" | ||
|
|
||
| # Compute merge base | ||
| MERGE_BASE=$(git merge-base HEAD origin/"$BASE_BRANCH") | ||
|
|
||
| # Get changed files relative to merge base | ||
| changed_files=$(git diff --name-only "$MERGE_BASE" HEAD) | ||
|
|
||
| # If any Gradle build file changed, run the full suite and exit | ||
| if echo "$changed_files" | grep -qE '\.(gradle|gradlew|bat)$|settings\.gradle'; then | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we also need to also check the Gradle wrapper files (
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In that case, should we also add the following in the Currently it's:
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Initially, I just added this line since that is what we did for the |
||
| echo "Gradle build files changed, running full build suite..." | ||
| cd exercises && ./gradlew compileStarterTestJava --continue | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Extract unique exercise directories | ||
| changed_exercises=$(echo "$changed_files" | \ | ||
| grep -E '^exercises/(practice|concept)/[^/]+/.+\.java$' | \ | ||
| cut -d/ -f1-3 | sort -u || true) | ||
|
|
||
| if [ -z "$changed_exercises" ]; then | ||
| echo "No relevant exercises changed, skipping compile checks." | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Print exercises | ||
| echo "Changed exercises detected:" | ||
| echo "$changed_exercises" | ||
| echo "----------------------------------------" | ||
|
|
||
| # Run build compile checks | ||
| exit_code=0 | ||
| for dir in $changed_exercises; do | ||
| slug=$(basename "$dir") | ||
|
|
||
| echo "========================================" | ||
| echo "=== Running compileStarterTestJava for $slug ===" | ||
| echo "========================================" | ||
|
|
||
| if [[ $dir == exercises/practice/* ]]; then | ||
| ./exercises/gradlew -p exercises ":practice:$slug:compileStarterTestJava" || exit_code=1 | ||
| elif [[ $dir == exercises/concept/* ]]; then | ||
| ./exercises/gradlew -p exercises ":concept:$slug:compileStarterTestJava" || exit_code=1 | ||
| fi | ||
| done | ||
|
|
||
| exit $exit_code | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should use Java 25 (the test runner uses Java 25).