Skip to content

Development: Check bean instantiations on startup #23

Development: Check bean instantiations on startup

Development: Check bean instantiations on startup #23

name: Check Bean Instantiations on Startup
on:
pull_request:
# paths:
# - 'src/main/java/**'
jobs:
build:
name: Check Bean Instantiations on Startup
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '21'
- name: Build application
run: ./gradlew clean bootJar -x test -x webapp
- name: Start Spring Boot app
run: |
PROFILES=dev,localci,lti,aeolus,theia,iris,localvc,artemis,scheduling,buildagent,core,ldap,no-liquibase
JAR=$(ls build/libs/Artemis*.jar | head -n1)
nohup java -jar $JAR \
--spring.profiles.active=dev,localci,lti,aeolus,theia,iris,localvc,artemis,scheduling,buildagent,core,ldap,no-liquibase \
--artemis.user-management.passkey.enabled=true \
--artemis.user-management.use-external=false \
--artemis.iris.url=http://iris.fake \
--artemis.iris.secret-token=token \
--spring.liquibase.enabled=false \
--spring.datasource.url="jdbc:h2:mem:mydb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" \
--spring.datasource.username=sa \
--spring.datasource.password= \
--eureka.client.enabled=false \
--aeolus.url=http://aeolus.fake \
> app.log 2>&1 &
echo $! > app.pid
- name: Wait for the application to start
run: |
echo "Waiting up to 60s for 'Artemis is running!' to appear in app.log..."
for i in {1..30}; do
if grep -q "'Artemis' is running!" app.log; then
echo "✅ Found 'Artemis is running!' in app.log after $i attempts"
break
fi
echo " attempt $i/30: not found yet"
sleep 2
done
if ! grep -q "'Artemis' is running!" app.log; then
echo "❌ Timeout: 'Artemis is running!' not found in app.log"
cat app.log
exit 1
fi
- name: Extract and validate bean instantiation metrics
run: |
LINE=$(grep 'Bean instantiation graph exported' app.log) \
|| { echo "❌ No metrics line"; cat app.log; exit 1; }
if [[ "$LINE" =~ \(([0-9]+)\ edges,\ max\ call\ stack\ size:\ ([0-9]+)\) ]]; then
EDGES=${BASH_REMATCH[1]}
MAXSTACK=${BASH_REMATCH[2]}
else
echo "❌ Failed to parse numbers"; exit 1
fi
echo "• Number of edges = $EDGES"
echo "• Max call stack size = $MAXSTACK"
MIN_EDGES=20
MAX_EDGES=94
MAX_STACK_SIZE_THRESHOLD=9
echo "Validating against thresholds: MIN_EDGES=$MIN_EDGES, MAX_EDGES=$MAX_EDGES, MAX_STACK_SIZE_THRESHOLD=$MAX_STACK_SIZE_THRESHOLD"
(( EDGES < MIN_EDGES )) && { echo "❌ < $MIN_EDGES edges. Something seems to be wrong as usually more beans are instantiated"; exit 1; }
(( EDGES > MAX_EDGES )) && { echo "❌ > $MAX_EDGES edges"; exit 1; }
(( MAXSTACK > MAX_STACK_SIZE_THRESHOLD )) && { echo "❌ stack > $MAX_STACK_SIZE_THRESHOLD"; exit 1; }
echo "✅ Final values → Edges: $EDGES; Max call stack size: $MAXSTACK"
echo "🎉 Number of instantiated beans on startup within expected ranges"
- name: Stop application
if: always()
run: kill $(<app.pid) || true