Improve fast workflow performance and logging #3
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 | |
on: | |
push: | |
branches: ['main'] | |
paths-ignore: | |
- 'spring-ai-docs/**' | |
- '*.md' | |
- 'docs/**' | |
- '.github/workflows/**' | |
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 | |
services: | |
ollama: | |
image: ollama/ollama:latest | |
ports: | |
- 11434:11434 | |
env: | |
OLLAMA_WITH_REUSE: true | |
steps: | |
- uses: actions/checkout@v4 | |
with: { fetch-depth: 2 } # Need HEAD and HEAD~1 for single commit diff | |
- uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: 'maven' | |
- 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: | | |
echo "Base ref: HEAD~1" | |
git log --oneline "HEAD~1...HEAD" | |
- name: Compute impacted modules | |
id: mods | |
run: | | |
echo "=== Module Detection Debug Info ===" | |
echo "Environment variables:" | |
echo " GITHUB_REF_NAME: $GITHUB_REF_NAME" | |
echo " GITHUB_REF: $GITHUB_REF" | |
echo " PWD: $(pwd)" | |
echo "" | |
echo "Git state verification:" | |
echo " HEAD: $(git rev-parse HEAD 2>/dev/null || echo 'FAILED')" | |
echo " HEAD~1: $(git rev-parse HEAD~1 2>/dev/null || echo 'NOT AVAILABLE')" | |
echo " Branch: $(git branch --show-current 2>/dev/null || echo 'DETACHED')" | |
echo "" | |
echo "Testing different git diff approaches:" | |
echo "1. HEAD~1..HEAD:" | |
git diff --name-only HEAD~1..HEAD 2>&1 | head -10 || echo " FAILED: $?" | |
echo "2. git show HEAD:" | |
git show --name-only --format= HEAD 2>&1 | head -10 || echo " FAILED: $?" | |
echo "3. Recent commits:" | |
git log --oneline -3 2>/dev/null || echo " Git log failed" | |
echo "" | |
echo "=== Running test_discovery.py for main branch ===" | |
set -x # Enable bash debug mode | |
# Capture stdout (the actual result) and stderr (verbose logging) separately | |
MODULE_LIST=$(python3 .github/scripts/test_discovery.py modules-from-diff --verbose 2>/tmp/discovery_debug.log) | |
EXIT_CODE=$? | |
set +x # Disable bash debug mode | |
echo "" | |
echo "=== Test Discovery Results ===" | |
echo "Exit code: $EXIT_CODE" | |
echo "Debug output:" | |
cat /tmp/discovery_debug.log | |
echo "" | |
echo "Module list result: '$MODULE_LIST'" | |
echo "modules=$MODULE_LIST" >> "$GITHUB_OUTPUT" | |
- 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 - running quick verification build" | |
echo "This could mean no Java/build files were changed, or only docs were modified" | |
echo "Running a minimal compile check to ensure the build isn't broken" | |
./mvnw -B -q -T 1C compile -DfailIfNoTests=false | |
else | |
echo "INFO: Running tests for affected modules: $MODS" | |
./mvnw -B -q -T 1C -Pci-fast-integration-tests -DfailIfNoTests=false -pl "$MODS" -amd verify | |
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" | |
./mvnw -B -q -s settings.xml -DfailIfNoTests=false -pl "$MODS" -amd deploy |