Skip to content

build: refine workflow configuration #162

build: refine workflow configuration

build: refine workflow configuration #162

Workflow file for this run

name: Build and Test Quarkus Project
on:
pull_request:
branches:
- master
jobs:
run:
runs-on: ubuntu-latest
timeout-minutes: 8
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Make Maven Wrapper executable
run: chmod +x ./mvnw
- name: Create Maven config
run: |
mkdir -p .mvn
echo "--batch-mode" > .mvn/maven.config
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Cache Maven dependencies
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-
- name: Cache build artifacts
id: cache-build
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-build-${{ hashFiles('src/**/*.java', '**/pom.xml') }}
restore-keys: |
${{ runner.os }}-build-
- name: Compile project
if: steps.cache-build.outputs.cache-hit != 'true'
run: ./mvnw compile
- name: Run integration tests
if: steps.cache-build.outputs.cache-hit != 'true'
run: ./mvnw verify
- name: Package project
if: steps.cache-build.outputs.cache-hit != 'true'
run: ./mvnw package -DskipTests
- name: Start and wait for project readiness
if: steps.cache-build.outputs.cache-hit != 'true'
run: |
nohup java -jar target/quarkus-app/quarkus-run.jar &
count_requests=0
MAX_REQUEST_ATTEMPTS=15
HEALTH_CHECK_ENDPOINT="http://localhost:8080/q/health/ready"
while true; do
count_requests=$((count_requests+1))
set +e
http_code=$(curl "$HEALTH_CHECK_ENDPOINT" --silent --output /dev/null --write-out "%{http_code}")
set -e
curl_exit_code=$?
if [ $curl_exit_code -ne 0 ]; then
echo "Attempt $count_requests: curl failed with exit code $curl_exit_code (could not connect)"
else
echo "Attempt $count_requests: HTTP $http_code"
fi
if [ "$http_code" -eq 200 ]; then
echo "Project is ready!"
break
fi
if [ "$count_requests" -ge "$MAX_REQUEST_ATTEMPTS" ]; then
echo "Max attempts reached. Failing the workflow."
exit 1
fi
sleep 1
done
- name: Setup K6
if: steps.cache-build.outputs.cache-hit != 'true'
uses: grafana/setup-k6-action@v1
- name: Run local k6 test
if: steps.cache-build.outputs.cache-hit != 'true'
uses: grafana/run-k6-action@v1
with:
path: ./e2e/api-test.js
github-token: ${{ github.token || 'dummy-token' }} # Dummy token for nektos/act. Can't run this step locally without it
cloud-run-locally: ${{ github.token == 'dummy-token' && 'false' || 'true' }}
cloud-comment-on-pr: ${{ github.token == 'dummy-token' && 'true' || 'false' }}