Build - push #576
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Check Build | |
# | |
# Description: | |
# Runs the build for every java version we support | |
# | |
# Triggers: | |
# - pull_request: when a PR is sent to us | |
# - push: when code is pushed to a specified branch | |
# | |
# Notes: | |
# Builds against Java 11, 17, and 21 which are the supported versions. | |
on: | |
workflow_dispatch: | |
pull_request: | |
paths: | |
- 'powertools-batch/**' | |
- 'powertools-core/**' | |
- 'powertools-cloudformation/**' | |
- 'powertools-common/**' | |
- 'powertools-e2e-tests/**' | |
- 'powertools-idempotency/**' | |
- 'powertools-large-messages/**' | |
- 'powertools-logging/**' | |
- 'powertools-metrics/**' | |
- 'powertools-parameters/**' | |
- 'powertools-serialization/**' | |
- 'powertools-sqs/**' | |
- 'powertools-tracing/**' | |
- 'powertools-tracing/**' | |
- 'powertools-validation/**' | |
- 'examples/**' | |
- 'pom.xml' | |
- 'examples/pom.xml' | |
- '.github/workflows/**' | |
push: | |
branches: | |
- main | |
paths: | |
- 'powertools-batch/**' | |
- 'powertools-core/**' | |
- 'powertools-cloudformation/**' | |
- 'powertools-common/**' | |
- 'powertools-e2e-tests/**' | |
- 'powertools-idempotency/**' | |
- 'powertools-large-messages/**' | |
- 'powertools-logging/**' | |
- 'powertools-metrics/**' | |
- 'powertools-parameters/**' | |
- 'powertools-serialization/**' | |
- 'powertools-sqs/**' | |
- 'powertools-tracing/**' | |
- 'powertools-tracing/**' | |
- 'powertools-validation/**' | |
- 'pom.xml' | |
- 'examples/**' | |
- 'examples/pom.xml' | |
- '.github/workflows/**' | |
name: Build | |
permissions: | |
contents: read | |
run-name: Build - ${{ github.event_name }} | |
jobs: | |
java-build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
java: | |
- 11 | |
- 17 | |
- 21 | |
steps: | |
- id: checkout | |
name: Checkout repository | |
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
- name: Setup Java | |
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 | |
with: | |
distribution: corretto | |
java-version: ${{ matrix.java }} | |
cache: maven | |
- id: build-maven | |
name: Build (Maven) | |
run: | | |
mvn -B -q install --file pom.xml | |
graalvm-build: | |
runs-on: aws-powertools_ubuntu-latest_8-core | |
steps: | |
- id: checkout | |
name: Checkout repository | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
fetch-depth: 0 | |
- name: Get changed files | |
id: changed-files | |
uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46.0.5 | |
with: | |
files: | | |
powertools-*/** | |
- name: Setup GraalVM | |
uses: graalvm/setup-graalvm@7f488cf82a3629ee755e4e97342c01d6bed318fa # v1.3.5 | |
with: | |
java-version: "21" | |
distribution: "graalvm" | |
cache: maven | |
- id: graalvm-native-test | |
name: GraalVM Native Test | |
if: steps.changed-files.outputs.any_changed == 'true' | |
env: | |
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} | |
run: | | |
# Build the entire project first to ensure test-jar dependencies are available | |
echo "::group::Building project dependencies" | |
mvn -B -q install -DskipTests | |
echo "::endgroup::" | |
echo "Changes detected in powertools modules: $CHANGED_FILES" | |
# Find modules with graalvm-native profile and run tests | |
find . -name "pom.xml" -path "./powertools-*" | while read module; do | |
if grep -q "<id>graalvm-native</id>" "$module"; then | |
module_dir=$(dirname "$module") | |
module_name=$(basename "$module_dir") | |
# Check if this specific module or common dependencies changed | |
if echo "$CHANGED_FILES" | grep -q "$module_name/" || \ | |
echo " $CHANGED_FILES " | grep -q " pom.xml " || \ | |
echo "$CHANGED_FILES" | grep -q "powertools-common/"; then | |
echo "::group::Building $module_name with GraalVM" | |
echo "Changes detected in $module_name - running GraalVM tests" | |
echo "Regenerating GraalVM metadata for $module_dir" | |
mvn -B -q -f "$module" -Pgenerate-graalvm-files clean test | |
echo "Running GraalVM native tests for $module_dir" | |
mvn -B -q -f "$module" -Pgraalvm-native test | |
echo "::endgroup::" | |
else | |
echo "No changes detected in $module_name - skipping GraalVM tests" | |
fi | |
fi | |
done |