Fast Build - 1dd686b3e9e767d09da350505af86578ba70de88 #53
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
name: Main Push - Fast | |
run-name: ${{ github.event.inputs.commit_sha && format('Manual Test - {0}', github.event.inputs.commit_sha) || format('Fast Build - {0}', github.sha) }} | |
on: | |
push: | |
branches: ['main'] | |
paths-ignore: | |
- 'spring-ai-docs/**' | |
- '*.md' | |
- 'docs/**' | |
- '.github/**' | |
workflow_dispatch: | |
inputs: | |
commit_sha: | |
description: 'Specific commit SHA to test (optional - defaults to latest)' | |
required: false | |
type: string | |
jobs: | |
fast-impacted: | |
name: Fast Build - Affected Modules | |
runs-on: ubuntu-latest | |
if: ${{ github.repository_owner == 'spring-projects' }} | |
permissions: | |
contents: read | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Always use full history for manual runs to find any commit | |
- name: Checkout specific commit | |
if: github.event.inputs.commit_sha | |
run: | | |
echo "Checking out specific commit: ${{ github.event.inputs.commit_sha }}" | |
# Save the latest main reference | |
LATEST_MAIN=$(git rev-parse origin/main) | |
# Checkout the target commit | |
git checkout ${{ github.event.inputs.commit_sha }} | |
# Preserve all latest GitHub Actions scripts from main | |
echo "Using latest GitHub Actions scripts from main..." | |
# Copy all scripts from main's .github/scripts directory (excluding __pycache__) | |
for script in $(git ls-tree -r --name-only ${LATEST_MAIN} .github/scripts/ | grep -v __pycache__); do | |
echo " Updating ${script}" | |
mkdir -p $(dirname ${script}) | |
git show ${LATEST_MAIN}:${script} > ${script} | |
done | |
# Note: The workflow itself is already from main (since that's what's running) | |
- uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
# cache: 'maven' # Disabled for fast workflow - reduces post-job noise | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Configure Testcontainers | |
run: | | |
echo "testcontainers.reuse.enable=true" > $HOME/.testcontainers.properties | |
- name: Show commit range | |
run: | | |
if [ -n "${{ github.event.inputs.commit_sha }}" ]; then | |
echo "π§ͺ MANUAL TEST RUN" | |
echo "Testing specific commit: ${{ github.event.inputs.commit_sha }}" | |
echo "" | |
echo "π Commit Details:" | |
git log --format=" Author: %an <%ae>%n Date: %ad%n Message: %s" -1 HEAD | |
echo "" | |
echo "π Changed Files:" | |
git diff --name-only HEAD~1..HEAD | head -10 | |
if [ $(git diff --name-only HEAD~1..HEAD | wc -l) -gt 10 ]; then | |
echo " ... and $(( $(git diff --name-only HEAD~1..HEAD | wc -l) - 10 )) more files" | |
fi | |
else | |
echo "π AUTOMATIC BUILD" | |
echo "Testing latest commit on main branch" | |
echo "" | |
echo "π Commit Details:" | |
git log --format=" Author: %an <%ae>%n Date: %ad%n Message: %s" -1 HEAD | |
fi | |
- name: Compute impacted modules | |
id: mods | |
run: | | |
echo "=== Detecting affected modules ===" | |
echo "=== DEBUG: Changed files ===" | |
git diff --name-only HEAD~1..HEAD | |
echo "=== DEBUG: Running test discovery with full output ===" | |
MODULE_LIST=$(python3 .github/scripts/test_discovery.py modules-from-diff --verbose) | |
echo "=== DEBUG: Raw module list: '$MODULE_LIST' ===" | |
echo "modules=$MODULE_LIST" >> "$GITHUB_OUTPUT" | |
if [ -n "$MODULE_LIST" ]; then | |
echo "Affected modules detected: $MODULE_LIST" | |
# Only start Ollama if we're testing Ollama-specific modules | |
if echo "$MODULE_LIST" | grep -q "ollama"; then | |
echo "Ollama-related modules detected - Ollama service needed" | |
echo "needs_ollama=true" >> "$GITHUB_OUTPUT" | |
else | |
echo "Non-Ollama modules detected - Ollama service not needed" | |
echo "needs_ollama=false" >> "$GITHUB_OUTPUT" | |
fi | |
else | |
echo "No affected modules detected - only workflow/docs changes" | |
echo "needs_ollama=false" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Start Ollama service for integration tests | |
if: steps.mods.outputs.needs_ollama == 'true' | |
run: | | |
echo "Starting Ollama for integration tests..." | |
docker run -d --name ollama-test -p 11434:11434 ollama/ollama:latest | |
echo "Ollama container started" | |
- name: Test affected modules with integration tests | |
env: | |
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
SPRING_AI_OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} | |
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} | |
OLLAMA_AUTOCONF_TESTS_ENABLED: "true" | |
OLLAMA_WITH_REUSE: true | |
run: | | |
MODS="${{ steps.mods.outputs.modules }}" | |
if [ -z "$MODS" ]; then | |
echo "INFO: No affected modules detected - skipping build" | |
echo "Only workflow, documentation, or non-build files were changed" | |
echo "Fast workflow optimization: no compilation needed" | |
exit 0 | |
else | |
echo "INFO: Running tests for affected modules: $MODS" | |
# Build dependencies without tests, then test only the affected modules | |
echo "INFO: Phase 1 - Building dependencies (this may take a few minutes)..." | |
./mvnw -B -q -T 1C -DskipTests -pl "$MODS" -am install | |
echo "INFO: Phase 2 - Running tests for affected modules..." | |
./mvnw -B -q -T 1C -Pci-fast-integration-tests -DfailIfNoTests=false -pl "$MODS" verify | |
echo "INFO: Testing complete" | |
fi | |
- name: Deploy to Artifactory (affected modules only) | |
if: steps.mods.outputs.modules != '' | |
env: | |
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} | |
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} | |
run: | | |
MODS="${{ steps.mods.outputs.modules }}" | |
echo "INFO: Deploying affected modules to Artifactory: $MODS" | |
# Skip tests during deploy since we already ran them | |
./mvnw -B -q -s settings.xml -DskipTests -pl "$MODS" deploy |