|
| 1 | +name: Build and Test Dockerized App |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + branches: [ main, development ] |
| 7 | + |
| 8 | +jobs: |
| 9 | + build-and-test: |
| 10 | + runs-on: ${{ matrix.os }} |
| 11 | + strategy: |
| 12 | + matrix: |
| 13 | + os: [ubuntu-latest] |
| 14 | + java: [17, 21] |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Checkout code |
| 18 | + uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: Set up JDK ${{ matrix.java }} |
| 21 | + uses: actions/setup-java@v4 |
| 22 | + with: |
| 23 | + distribution: 'temurin' |
| 24 | + java-version: ${{ matrix.java }} |
| 25 | + |
| 26 | + - name: Grant execute permission for Gradle wrapper (Unix) |
| 27 | + if: runner.os != 'Windows' |
| 28 | + run: chmod +x gradlew |
| 29 | + |
| 30 | + # Build Docker image instead of bootable JAR |
| 31 | + - name: Build Docker image |
| 32 | + run: | |
| 33 | + docker build -f docker/Dockerfile -t wap-server:${{ matrix.os }}-${{ matrix.java }} . |
| 34 | +
|
| 35 | + # Run Docker container (detached, expose port 8080) |
| 36 | + - name: Run Docker container |
| 37 | + run: | |
| 38 | + docker run -d -p 8080:8080 --name wap-server \ |
| 39 | + wap-server:${{ matrix.os }}-${{ matrix.java }} |
| 40 | + echo "Wait for wap server to be healthy before proceeding to tests" |
| 41 | + while true; do |
| 42 | + docker ps -a |
| 43 | + if ! docker ps | grep -q wap-server; then |
| 44 | + echo "Docker container stopped unexpectedly. Aborting." |
| 45 | + exit 1 |
| 46 | + fi |
| 47 | + if curl -f http://localhost:8080; then |
| 48 | + echo "Service is running." |
| 49 | + break |
| 50 | + fi |
| 51 | + echo "Waiting for the service to be ready..." |
| 52 | + docker logs --tail 20 wap-server |
| 53 | + sleep 5 |
| 54 | + done |
| 55 | +
|
| 56 | + - name: hurl install |
| 57 | + |
| 58 | + with: {disable-cache: true} |
| 59 | + |
| 60 | + - name: hurl CRUD tests (windows) |
| 61 | + if: runner.os == 'Windows' |
| 62 | + shell: bash |
| 63 | + run: | |
| 64 | + for file in ./integration_tests/CRUD/*.hurl; do |
| 65 | + hurl --variable host=http://localhost:8080 --test "$file" --verbose --error-format=long --continue-on-error --report-html hurlreports |
| 66 | + done |
| 67 | +
|
| 68 | + - name: hurl tests (other) |
| 69 | + if: runner.os != 'Windows' |
| 70 | + run: hurl --variable host=http://localhost:8080 --test ./integration_tests/CRUD/*.hurl --verbose --error-format=long --continue-on-error --report-html hurlreports |
| 71 | + |
| 72 | + # Stop and clean up container |
| 73 | + - name: Stop Docker container |
| 74 | + if: always() |
| 75 | + run: | |
| 76 | + docker logs wap-server |
| 77 | + docker stop wap-server |
| 78 | + docker rm wap-server |
| 79 | +
|
| 80 | + # Upload artifacts (optional: you may want to upload Docker logs instead of JARs) |
| 81 | + - name: Upload Docker logs |
| 82 | + if: always() |
| 83 | + uses: actions/upload-artifact@v4 |
| 84 | + with: |
| 85 | + name: docker_logs_jdk${{ matrix.java }}_${{ matrix.os }} |
| 86 | + path: ./hurlreports |
0 commit comments