spotless and ci integration #3
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: check on pr | |
on: | |
pull_request: | |
types: | |
- opened | |
- synchronize | |
branches: | |
- main | |
paths: | |
- 'packages/api/**' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
services: | |
test-db: | |
image: mariadb:latest | |
ports: | |
- 3307:3306 | |
env: | |
MYSQL_DATABASE: app | |
MYSQL_USER: user | |
MYSQL_PASSWORD: secret | |
MYSQL_ROOT_PASSWORD: secret | |
options: >- | |
--health-cmd="mysqladmin ping -uuser -psecret --silent" | |
--health-interval=10s | |
--health-timeout=5s | |
--health-retries=10 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '21' | |
- name: Install Maven dependencies | |
run: mvn install -DskipTests | |
working-directory: packages/api | |
- name: Run Spotless check | |
run: mvn spotless:check | |
working-directory: packages/api | |
- name: Wait for test-db to be ready | |
run: | | |
echo "Waiting for test-db to be ready..." | |
for i in {1..30}; do | |
if [ "$(docker inspect --format='{{.State.Health.Status}}' $(docker ps -q --filter name=test-db))" == "healthy" ]; then | |
echo "test-db is healthy!" | |
exit 0 | |
fi | |
echo "Waiting for test-db to be healthy... ($i/30)" | |
sleep 10 | |
done | |
echo "test-db failed to become healthy" | |
exit 1 | |
- name: Run tests | |
env: | |
SPRING_DATASOURCE_URL: jdbc:mariadb://localhost:3307/app | |
SPRING_DATASOURCE_USERNAME: user | |
SPRING_DATASOURCE_PASSWORD: secret | |
run: mvn test | |
working-directory: packages/api | |
- name: Build project | |
run: mvn clean package | |
working-directory: packages/api |