|
| 1 | +name: Dropwizard Dedup Sample |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [main] |
| 6 | + push: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + name: JDK ${{ matrix.java-version }} |
| 12 | + runs-on: ubuntu-latest |
| 13 | + strategy: |
| 14 | + fail-fast: false |
| 15 | + matrix: |
| 16 | + java-version: ["8", "17", "21"] |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - name: Set up JDK ${{ matrix.java-version }} |
| 23 | + uses: actions/setup-java@v4 |
| 24 | + with: |
| 25 | + distribution: temurin |
| 26 | + java-version: ${{ matrix.java-version }} |
| 27 | + cache: maven |
| 28 | + |
| 29 | + - name: Build dropwizard-dedup without Keploy compile dependency |
| 30 | + working-directory: dropwizard-dedup |
| 31 | + run: mvn -B -DskipTests clean package |
| 32 | + |
| 33 | + - name: Verify Keploy is not a compile-time dependency |
| 34 | + working-directory: dropwizard-dedup |
| 35 | + run: | |
| 36 | + set -euo pipefail |
| 37 | + mvn -B dependency:tree -Dincludes=io.keploy:keploy-sdk -DoutputFile=target/keploy-dependency-tree.txt |
| 38 | + if grep -q "io.keploy:keploy-sdk" target/keploy-dependency-tree.txt; then |
| 39 | + cat target/keploy-dependency-tree.txt |
| 40 | + exit 1 |
| 41 | + fi |
| 42 | + if grep -R "io.keploy\\.dedup\\|io.keploy\\.servlet\\|KeployDedupAgent\\|KeployMiddleware" src/main/java; then |
| 43 | + exit 1 |
| 44 | + fi |
| 45 | +
|
| 46 | + - name: Smoke Dropwizard runtime with JaCoCo |
| 47 | + working-directory: dropwizard-dedup |
| 48 | + run: | |
| 49 | + set -euo pipefail |
| 50 | + smoke_http_port=$((19080 + ${{ matrix.java-version }})) |
| 51 | + smoke_admin_port=$((20080 + ${{ matrix.java-version }})) |
| 52 | +
|
| 53 | + DW_HTTP_PORT="${smoke_http_port}" DW_ADMIN_PORT="${smoke_admin_port}" \ |
| 54 | + java -javaagent:target/jacocoagent.jar=destfile=target/smoke-jacoco.exec \ |
| 55 | + -jar target/dropwizard-dedup-0.0.1-SNAPSHOT.jar server config.yml \ |
| 56 | + > target/dropwizard-smoke.log 2>&1 & |
| 57 | + app_pid=$! |
| 58 | +
|
| 59 | + cleanup() { |
| 60 | + kill "${app_pid}" >/dev/null 2>&1 || true |
| 61 | + wait "${app_pid}" >/dev/null 2>&1 || true |
| 62 | + } |
| 63 | + trap cleanup EXIT |
| 64 | +
|
| 65 | + ready=0 |
| 66 | + for i in $(seq 1 60); do |
| 67 | + if curl -fsS "http://127.0.0.1:${smoke_http_port}/healthz" >/dev/null; then |
| 68 | + ready=1 |
| 69 | + break |
| 70 | + fi |
| 71 | + if ! kill -0 "${app_pid}" >/dev/null 2>&1; then |
| 72 | + cat target/dropwizard-smoke.log |
| 73 | + exit 1 |
| 74 | + fi |
| 75 | + sleep 1 |
| 76 | + done |
| 77 | + if [ "${ready}" != "1" ]; then |
| 78 | + cat target/dropwizard-smoke.log |
| 79 | + exit 1 |
| 80 | + fi |
| 81 | +
|
| 82 | + curl -fsS "http://127.0.0.1:${smoke_http_port}/catalog?category=electronics&limit=1" | grep -q '"source":"warehouse-b"' |
| 83 | + curl -fsS -H "X-Tenant: flipkart" -H "X-Request-Id: smoke-1" \ |
| 84 | + "http://127.0.0.1:${smoke_http_port}/headers" | grep -q '"tenant":"flipkart"' |
| 85 | + curl -fsS -X POST "http://127.0.0.1:${smoke_http_port}/orders" \ |
| 86 | + -H "Content-Type: application/json" \ |
| 87 | + -d '{"customer":"smoke","sku":"BK-1","quantity":2,"priority":true}' | grep -q '"route":"air"' |
| 88 | + curl -fsS "http://127.0.0.1:${smoke_http_port}/platform/content/html" | grep -q '<h1>dropwizard</h1>' |
| 89 | + test "$(curl -sS -o /tmp/dropwizard-missing.json -w '%{http_code}' "http://127.0.0.1:${smoke_http_port}/catalog/MISSING")" = "404" |
| 90 | + grep -q '"error":"not_found"' /tmp/dropwizard-missing.json |
| 91 | +
|
| 92 | + cleanup |
| 93 | + trap - EXIT |
| 94 | + test -s target/smoke-jacoco.exec |
0 commit comments