name: Spring Boot App API tests on: push: branches: - master pull_request: jobs: run-tests: runs-on: ubuntu-latest steps: - name: Checkout Spring Boot app repository uses: actions/checkout@v4 with: repository: aceton41k/spring-boot-app path: app - name: Build Spring Boot Docker image run: | docker build -t spring-boot-app:latest ./app - name: Create Docker network run: docker network create my-network - name: Run PostgreSQL container run: | docker run -d --name db \ --network my-network \ -e POSTGRES_USER=appuser \ -e POSTGRES_PASSWORD=appuser123$ \ -e POSTGRES_DB=appdb \ -p 5432:5432 \ postgres:latest - name: Run Spring Boot app container run: | docker run -d -p 8080:8080 \ --name spring-boot-app \ --network my-network \ --env SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/appdb \ --env SPRING_DATASOURCE_USERNAME=appuser \ --env SPRING_DATASOURCE_PASSWORD=appuser123$ \ spring-boot-app:latest - name: Wait for PostgreSQL to be ready run: | for i in {1..30}; do if docker exec db pg_isready -U appuser; then echo "PostgreSQL is ready!" break else echo "Waiting for PostgreSQL..." sleep 10 fi done - name: Wait for Spring Boot app to be ready run: | for i in {1..30}; do if curl -s http://localhost:8080/actuator/health | grep '"status":"UP"'; then echo "Spring Boot app is ready!" break else echo "Waiting for Spring Boot app..." sleep 10 fi done - name: Checkout API tests uses: actions/checkout@v4 with: path: tests - name: Set up JDK 17 uses: actions/setup-java@v4 with: java-version: '17' distribution: 'temurin' - name: Compile test classes run: | cd tests ./gradlew compileTestJava -PskipJooqGeneration - name: Run tests run: | cd tests ./gradlew test --tests template.framework.api.test.AppTests -PskipJooqGeneration -Dapi.url=http://localhost:8080 -Ddb.url=jdbc:postgresql://localhost:5432/appdb -Ddb.password=appuser123$ -Ddb.user=appuser --info - name: Get Allure history uses: actions/checkout@v4 if: always() continue-on-error: true with: ref: gh-pages path: gh-pages - name: Build Allure report uses: simple-elf/allure-report-action@v1.9 with: gh_pages: gh-pages allure_results: './tests/build/allure-results' allure_report: './tests/build/allure-report' - name: Deploy Allure report to GitHub Pages uses: peaceiris/actions-gh-pages@v4 if: github.ref == 'refs/heads/master' with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_branch: gh-pages publish_dir: allure-history