|
| 1 | +name: Verify Liquibase Backward Compatibility |
| 2 | + |
| 3 | +on: [pull_request] |
| 4 | + |
| 5 | +permissions: |
| 6 | + contents: read |
| 7 | + |
| 8 | +jobs: |
| 9 | + liquibase-backward-compatibility-check: |
| 10 | + runs-on: ubuntu-24.04 |
| 11 | + timeout-minutes: 30 |
| 12 | + |
| 13 | + services: |
| 14 | + postgresql: |
| 15 | + image: postgres:17.4 |
| 16 | + ports: |
| 17 | + - 5432:5432 |
| 18 | + env: |
| 19 | + POSTGRES_USER: root |
| 20 | + POSTGRES_PASSWORD: postgres |
| 21 | + options: >- |
| 22 | + --health-cmd="pg_isready -q -d postgres -U root" |
| 23 | + --health-interval=5s |
| 24 | + --health-timeout=2s |
| 25 | + --health-retries=5 |
| 26 | +
|
| 27 | + env: |
| 28 | + DB_USER: root |
| 29 | + DB_PASSWORD: postgres |
| 30 | + DB_NAME: fineract_default |
| 31 | + TZ: Asia/Kolkata |
| 32 | + |
| 33 | + steps: |
| 34 | + - name: Checkout the base branch (`develop`) |
| 35 | + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v5 |
| 36 | + with: |
| 37 | + repository: ${{ github.event.pull_request.base.repo.full_name }} |
| 38 | + ref: ${{ github.event.pull_request.base.ref }} |
| 39 | + fetch-depth: 0 |
| 40 | + |
| 41 | + - name: Set up JDK 21 |
| 42 | + uses: actions/setup-java@v4 |
| 43 | + with: |
| 44 | + distribution: 'zulu' |
| 45 | + java-version: '21' |
| 46 | + |
| 47 | + - name: Wait for PostgreSQL |
| 48 | + run: | |
| 49 | + until pg_isready -h localhost -U $DB_USER; do |
| 50 | + echo "Waiting for postgres..." |
| 51 | + sleep 2 |
| 52 | + done |
| 53 | +
|
| 54 | + - name: Init base schema |
| 55 | + run: | |
| 56 | + ./gradlew --no-daemon createPGDB -PdbName=fineract_tenants |
| 57 | + ./gradlew --no-daemon createPGDB -PdbName=$DB_NAME |
| 58 | +
|
| 59 | + - name: Start backend on base branch |
| 60 | + run: | |
| 61 | + ./gradlew :fineract-provider:devRun --args="\ |
| 62 | + --spring.datasource.hikari.driverClassName=org.postgresql.Driver \ |
| 63 | + --spring.datasource.hikari.jdbcUrl=jdbc:postgresql://localhost:5432/fineract_tenants \ |
| 64 | + --spring.datasource.hikari.username=root \ |
| 65 | + --spring.datasource.hikari.password=postgres \ |
| 66 | + --fineract.tenant.host=localhost \ |
| 67 | + --fineract.tenant.port=5432 \ |
| 68 | + --fineract.tenant.username=root \ |
| 69 | + --fineract.tenant.password=postgres" & |
| 70 | + BACKEND_PID=$! |
| 71 | + echo $BACKEND_PID > backend.pid |
| 72 | +
|
| 73 | + # Wait for Actuator to come up (adjust host/port/path if needed) |
| 74 | + ACTUATOR_URL="https://localhost:8443/fineract-provider/actuator/health" |
| 75 | + TIMEOUT_SECONDS=600 |
| 76 | + INTERVAL_SECONDS=2 |
| 77 | +
|
| 78 | + echo "Waiting for backend Actuator: $ACTUATOR_URL (timeout ${TIMEOUT_SECONDS}s)..." |
| 79 | +
|
| 80 | + start_ts=$(date +%s) |
| 81 | + while true; do |
| 82 | + # If the process died, fail fast |
| 83 | + if ! kill -0 "$BACKEND_PID" 2>/dev/null; then |
| 84 | + echo "Backend process exited before Actuator became available." |
| 85 | + exit 1 |
| 86 | + fi |
| 87 | +
|
| 88 | + # Check endpoint |
| 89 | + if curl -kfsS "$ACTUATOR_URL" >/dev/null 2>&1; then |
| 90 | + echo "Actuator is up." |
| 91 | + break |
| 92 | + fi |
| 93 | +
|
| 94 | + # Timeout |
| 95 | + now_ts=$(date +%s) |
| 96 | + if [ $((now_ts - start_ts)) -ge "$TIMEOUT_SECONDS" ]; then |
| 97 | + echo "Timed out waiting for Actuator." |
| 98 | + exit 1 |
| 99 | + fi |
| 100 | +
|
| 101 | + sleep "$INTERVAL_SECONDS" |
| 102 | + done |
| 103 | +
|
| 104 | + - name: Stop backend |
| 105 | + run: | |
| 106 | + kill $(cat backend.pid) |
| 107 | + sleep 10 |
| 108 | +
|
| 109 | + - name: Checkout the PR branch |
| 110 | + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v5 |
| 111 | + with: |
| 112 | + repository: ${{ github.event.pull_request.head.repo.full_name }} |
| 113 | + ref: ${{ github.event.pull_request.head.sha }} |
| 114 | + fetch-depth: 0 |
| 115 | + |
| 116 | + - name: Start backend on PR branch |
| 117 | + run: | |
| 118 | + ./gradlew :fineract-provider:devRun --args="\ |
| 119 | + --spring.datasource.hikari.driverClassName=org.postgresql.Driver \ |
| 120 | + --spring.datasource.hikari.jdbcUrl=jdbc:postgresql://localhost:5432/fineract_tenants \ |
| 121 | + --spring.datasource.hikari.username=root \ |
| 122 | + --spring.datasource.hikari.password=postgres \ |
| 123 | + --fineract.tenant.host=localhost \ |
| 124 | + --fineract.tenant.port=5432 \ |
| 125 | + --fineract.tenant.username=root \ |
| 126 | + --fineract.tenant.password=postgres" & |
| 127 | + BACKEND_PID=$! |
| 128 | + echo $BACKEND_PID > backend.pid |
| 129 | +
|
| 130 | + # Wait for Actuator to come up (adjust host/port/path if needed) |
| 131 | + ACTUATOR_URL="https://localhost:8443/fineract-provider/actuator/health" |
| 132 | + TIMEOUT_SECONDS=600 |
| 133 | + INTERVAL_SECONDS=2 |
| 134 | +
|
| 135 | + echo "Waiting for backend Actuator: $ACTUATOR_URL (timeout ${TIMEOUT_SECONDS}s)..." |
| 136 | +
|
| 137 | + start_ts=$(date +%s) |
| 138 | + while true; do |
| 139 | + # If the process died, fail fast |
| 140 | + if ! kill -0 "$BACKEND_PID" 2>/dev/null; then |
| 141 | + echo "Backend process exited before Actuator became available." |
| 142 | + exit 1 |
| 143 | + fi |
| 144 | +
|
| 145 | + # Check endpoint |
| 146 | + if curl -kfsS "$ACTUATOR_URL" >/dev/null 2>&1; then |
| 147 | + echo "Actuator is up." |
| 148 | + break |
| 149 | + fi |
| 150 | +
|
| 151 | + # Timeout |
| 152 | + now_ts=$(date +%s) |
| 153 | + if [ $((now_ts - start_ts)) -ge "$TIMEOUT_SECONDS" ]; then |
| 154 | + echo "Timed out waiting for Actuator." |
| 155 | + exit 1 |
| 156 | + fi |
| 157 | +
|
| 158 | + sleep "$INTERVAL_SECONDS" |
| 159 | + done |
| 160 | + - name: Stop backend |
| 161 | + run: | |
| 162 | + kill $(cat backend.pid) |
| 163 | + sleep 10 |
0 commit comments