build: refine workflow configuration #159
Workflow file for this run
This file contains 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: Build and Test Quarkus Project | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
timeout-minutes: 8 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up JDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '21' | |
cache: 'maven' | |
- 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 | |
uses: actions/cache@v4 | |
with: | |
path: target | |
key: ${{ runner.os }}-build-${{ hashFiles('src/**/*.java') }} | |
restore-keys: | | |
${{ runner.os }}-build- | |
- name: Make Maven Wrapper executable | |
run: chmod +x ./mvnw | |
- name: Download Project dependencies | |
run: ./mvnw dependency:resolve --batch-mode | |
- name: Check if project needs to be recompiled | |
id: calculate_project_hash | |
run: echo "cache-hit=${{ steps.cache-build.outputs.cache-hit }}" >> $GITHUB_ENV | |
- name: Compile project | |
if: env.cache-hit != 'true' | |
run: ./mvnw package | |
- name: Run tests | |
if: env.cache-hit != 'true' | |
run: ./mvnw test | |
- name: Start app and wait for readiness | |
shell: bash | |
run: | | |
java -jar target/quarkus-app/quarkus-run.jar & | |
timeout 10s bash -c ' | |
while true; do | |
curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/q/health/ready | |
if [[ $? -eq 0 ]]; then | |
break | |
fi | |
sleep 1 | |
done | |
' | |
- name: Setup K6 | |
uses: grafana/setup-k6-action@v1 | |
# TODO: all e2e tests fail locally in nektos/act for whatever reason | |
- name: Run local k6 test | |
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' }} |