Skip to content

Commit

Permalink
chore(server): create github actions precheck.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
halisyucel committed Jul 1, 2024
1 parent c58454a commit baf580e
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/prcheck.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
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

0 comments on commit baf580e

Please sign in to comment.