1+ name : Main Push - Fast
2+
3+ on :
4+ push :
5+ branches : ['main']
6+ paths-ignore :
7+ - ' spring-ai-docs/**'
8+ - ' *.md'
9+ - ' docs/**'
10+
11+ jobs :
12+ fast-impacted :
13+ name : Fast Build - Affected Modules
14+ runs-on : ubuntu-latest
15+ if : ${{ github.repository_owner == 'spring-projects' }}
16+ permissions :
17+ contents : read
18+ concurrency :
19+ group : ${{ github.workflow }}-${{ github.ref }}
20+ cancel-in-progress : true
21+ services :
22+ ollama :
23+ image : ollama/ollama:latest
24+ ports :
25+ - 11434:11434
26+ env :
27+ OLLAMA_WITH_REUSE : true
28+ steps :
29+ - uses : actions/checkout@v4
30+ with : { fetch-depth: 2 } # Need HEAD and HEAD~1 for single commit diff
31+
32+ - name : Free Disk Space
33+ uses : jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
34+ with :
35+ large-packages : false
36+ docker-images : false
37+
38+ - uses : actions/setup-java@v4
39+ with :
40+ java-version : ' 17'
41+ distribution : ' temurin'
42+ cache : ' maven'
43+
44+ - name : Set up Python
45+ uses : actions/setup-python@v5
46+ with :
47+ python-version : ' 3.11'
48+
49+ - name : Configure Testcontainers
50+ run : |
51+ echo "testcontainers.reuse.enable=true" > $HOME/.testcontainers.properties
52+
53+ - name : Show commit range
54+ run : |
55+ echo "Base ref: HEAD~1"
56+ git log --oneline "HEAD~1...HEAD"
57+
58+ - name : Compute impacted modules
59+ id : mods
60+ run : |
61+ echo "=== Module Detection Debug Info ==="
62+ echo "Environment variables:"
63+ echo " GITHUB_REF_NAME: $GITHUB_REF_NAME"
64+ echo " GITHUB_REF: $GITHUB_REF"
65+ echo " PWD: $(pwd)"
66+ echo ""
67+
68+ echo "Git state verification:"
69+ echo " HEAD: $(git rev-parse HEAD 2>/dev/null || echo 'FAILED')"
70+ echo " HEAD~1: $(git rev-parse HEAD~1 2>/dev/null || echo 'NOT AVAILABLE')"
71+ echo " Branch: $(git branch --show-current 2>/dev/null || echo 'DETACHED')"
72+ echo ""
73+
74+ echo "Testing different git diff approaches:"
75+ echo "1. HEAD~1..HEAD:"
76+ git diff --name-only HEAD~1..HEAD 2>&1 | head -10 || echo " FAILED: $?"
77+
78+ echo "2. git show HEAD:"
79+ git show --name-only --format= HEAD 2>&1 | head -10 || echo " FAILED: $?"
80+
81+ echo "3. Recent commits:"
82+ git log --oneline -3 2>/dev/null || echo " Git log failed"
83+ echo ""
84+
85+ echo "=== Running test_discovery.py for main branch ==="
86+ set -x # Enable bash debug mode
87+ MODS=$(python3 .github/scripts/test_discovery.py modules-from-diff --verbose 2>&1)
88+ EXIT_CODE=$?
89+ set +x # Disable bash debug mode
90+
91+ echo ""
92+ echo "=== Test Discovery Results ==="
93+ echo "Exit code: $EXIT_CODE"
94+ echo "Output:"
95+ echo "$MODS"
96+ echo ""
97+
98+ # Extract just the module list (last line that isn't stderr logging)
99+ MODULE_LIST=$(echo "$MODS" | grep -v "^Detected base ref:" | grep -v "^Changed files" | grep -v "^Final module list:" | tail -1)
100+ echo "Extracted modules: '$MODULE_LIST'"
101+ echo "modules=$MODULE_LIST" >> "$GITHUB_OUTPUT"
102+
103+ - name : Test affected modules with integration tests
104+ env :
105+ OPENAI_API_KEY : ${{ secrets.OPENAI_API_KEY }}
106+ SPRING_AI_OPENAI_API_KEY : ${{ secrets.OPENAI_API_KEY }}
107+ ARTIFACTORY_USERNAME : ${{ secrets.ARTIFACTORY_USERNAME }}
108+ ARTIFACTORY_PASSWORD : ${{ secrets.ARTIFACTORY_PASSWORD }}
109+ OLLAMA_AUTOCONF_TESTS_ENABLED : " true"
110+ OLLAMA_WITH_REUSE : true
111+ run : |
112+ MODS="${{ steps.mods.outputs.modules }}"
113+ if [ -z "$MODS" ]; then
114+ echo "INFO: No affected modules detected - running quick verification build"
115+ echo "This could mean no Java/build files were changed, or only docs were modified"
116+ echo "Running a minimal compile check to ensure the build isn't broken"
117+ ./mvnw -B -T 1C compile -DfailIfNoTests=false
118+ else
119+ echo "INFO: Running tests for affected modules: $MODS"
120+ ./mvnw -B -T 1C -Pci-fast-integration-tests -DfailIfNoTests=false -pl "$MODS" -amd verify
121+ fi
122+
123+ - name : Deploy to Artifactory (affected modules only)
124+ if : steps.mods.outputs.modules != ''
125+ env :
126+ ARTIFACTORY_USERNAME : ${{ secrets.ARTIFACTORY_USERNAME }}
127+ ARTIFACTORY_PASSWORD : ${{ secrets.ARTIFACTORY_PASSWORD }}
128+ run : |
129+ MODS="${{ steps.mods.outputs.modules }}"
130+ echo "INFO: Deploying affected modules to Artifactory: $MODS"
131+ ./mvnw -B -s settings.xml -DfailIfNoTests=false -pl "$MODS" -amd deploy
0 commit comments