|
| 1 | +name: spring-postgres-example CI Build |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [master] |
| 6 | + paths: |
| 7 | + - "spring-postgres-example/**" |
| 8 | + types: |
| 9 | + - opened |
| 10 | + - synchronize |
| 11 | + - reopened |
| 12 | + |
| 13 | +jobs: |
| 14 | + |
| 15 | + integration-tests: |
| 16 | + name: Run Unit & Integration Tests |
| 17 | + runs-on: ubuntu-latest |
| 18 | + defaults: |
| 19 | + run: |
| 20 | + working-directory: spring-postgres-example |
| 21 | + strategy: |
| 22 | + matrix: |
| 23 | + distribution: [ 'temurin' ] |
| 24 | + java: [ '21' ] |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v5 |
| 27 | + with: |
| 28 | + fetch-depth: 0 |
| 29 | + |
| 30 | + - name: Set up JDK ${{ matrix.java }} |
| 31 | + |
| 32 | + with: |
| 33 | + java-version: ${{ matrix.java }} |
| 34 | + distribution: ${{ matrix.distribution }} |
| 35 | + cache: 'maven' |
| 36 | + - name: Build and analyze |
| 37 | + run: ./mvnw clean verify |
| 38 | + |
| 39 | + health-check: |
| 40 | + name: Health Check on Services |
| 41 | + runs-on: ubuntu-latest |
| 42 | + steps: |
| 43 | + - name: Checkout repository and submodules |
| 44 | + uses: actions/checkout@v5 |
| 45 | + with: |
| 46 | + submodules: true |
| 47 | + |
| 48 | + - name: Extract service names from docker compose |
| 49 | + id: services |
| 50 | + run: | |
| 51 | + echo "services<<EOF" >> $GITHUB_OUTPUT |
| 52 | + docker compose -f ./spring-postgres-example/compose.yaml config --services >> $GITHUB_OUTPUT |
| 53 | + echo "EOF" >> $GITHUB_OUTPUT |
| 54 | +
|
| 55 | + - name: Start containers with Compose Action |
| 56 | + uses: hoverkraft-tech/[email protected] |
| 57 | + with: |
| 58 | + compose-file: './spring-postgres-example/compose.yaml' |
| 59 | + services: ${{ steps.services.outputs.services }} |
| 60 | + up-flags: '--build' |
| 61 | + down-flags: '--volumes' |
| 62 | + |
| 63 | + - name: Wait for containers to initialize |
| 64 | + run: sleep 30 |
| 65 | + |
| 66 | + - name: Check container health |
| 67 | + run: | |
| 68 | + ./.github/scripts/check-container-health.sh "${{ steps.services.outputs.services }}" |
0 commit comments