Fix failure CI #28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: ci | |
| on: | |
| push: | |
| workflow_dispatch: | |
| env: | |
| COMPOSE_DOCKER_CLI_BUILD: 1 | |
| DB_NAME: kaui | |
| DOCKER_BUILDKIT: 1 | |
| JRUBY_OPTS: -J-Xmx1024M | |
| KB_ADDRESS: 127.0.0.1 | |
| KB_PORT: 8080 | |
| RAILS_ENV: test | |
| jobs: | |
| test: | |
| runs-on: ubuntu-22.04 | |
| strategy: | |
| matrix: | |
| include: | |
| - ruby-version: '3.2.2' | |
| database-adapter: 'mysql2' | |
| database-user: 'root' | |
| database-password: 'root' | |
| database-port: '3306' | |
| docker-compose-file: 'docker-compose.ci.mysql.yml' | |
| - ruby-version: 'jruby-9.4.2.0' | |
| database-adapter: 'mysql2' | |
| database-user: 'root' | |
| database-password: 'root' | |
| database-port: '3306' | |
| docker-compose-file: 'docker-compose.ci.mysql.yml' | |
| - ruby-version: '3.2.2' | |
| database-adapter: 'postgresql' | |
| database-user: 'postgres' | |
| database-password: 'postgres' | |
| database-port: '5432' | |
| docker-compose-file: 'docker-compose.ci.postgresql.yml' | |
| - ruby-version: 'jruby-9.4.2.0' | |
| database-adapter: 'postgresql' | |
| database-user: 'postgres' | |
| database-password: 'postgres' | |
| database-port: '5432' | |
| docker-compose-file: 'docker-compose.ci.postgresql.yml' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: ${{ matrix.ruby-version }} | |
| bundler-cache: true | |
| - name: Start stack | |
| run: | | |
| cd docker | |
| docker compose -p it -f ${{ matrix.docker-compose-file }} up --no-start | |
| docker start it-db-1 | |
| - name: Wait for MySQL | |
| if: ${{ matrix.docker-compose-file == 'docker-compose.ci.mysql.yml' }} | |
| run: | | |
| set +e | |
| count=0 | |
| until mysqladmin ping -h 127.0.0.1 -u root --password=root --silent; do | |
| if [[ "$count" == "25" ]]; then | |
| exit 1 | |
| fi | |
| (( count++ )) | |
| printf '.' | |
| sleep 5 | |
| done | |
| set -e | |
| - name: Wait for PostgreSQL | |
| if: ${{ matrix.docker-compose-file == 'docker-compose.ci.postgresql.yml' }} | |
| run: | | |
| set +e | |
| count=0 | |
| until $(psql -h 127.0.0.1 -U postgres -p 5432 -l > /dev/null); do | |
| if [[ "$count" == "25" ]]; then | |
| exit 1 | |
| fi | |
| (( count++ )) | |
| printf '.' | |
| sleep 5 | |
| done | |
| set -e | |
| - name: Start Kill Bill | |
| # Sometimes it gets stuck (if Kill Bill starts when the DB isn't ready?) | |
| timeout-minutes: 4 | |
| run: | | |
| docker start it-killbill-1 | |
| count=0 | |
| until $(curl --connect-timeout 10 --max-time 30 --output /dev/null --silent --fail http://${KB_ADDRESS}:${KB_PORT}/1.0/healthcheck); do | |
| if [[ "$count" == "180" ]]; then | |
| exit 64 | |
| fi | |
| count=$(( count + 1 )) | |
| sleep 1 | |
| done | |
| curl --connect-timeout 10 --max-time 30 -v \ | |
| -X POST \ | |
| -u admin:password \ | |
| -H 'Content-Type: application/json' \ | |
| -H 'X-Killbill-CreatedBy: GitHub' \ | |
| -d '{"apiKey": "bob", "apiSecret": "lazar"}' \ | |
| "http://${KB_ADDRESS}:${KB_PORT}/1.0/kb/tenants" | |
| - name: Install plugin specific MySQL DDL | |
| if: ${{ matrix.docker-compose-file == 'docker-compose.ci.mysql.yml' }} | |
| run: | | |
| echo "Fetching DDL script from GitHub..." | |
| # First check if the DDL file is accessible | |
| if curl -s --head https://raw.githubusercontent.com/killbill/killbill-deposit-plugin/master/src/main/resources/ddl.sql | head -n 1 | grep "200" > /dev/null; then | |
| echo "DDL file found, applying to MySQL..." | |
| curl -s https://raw.githubusercontent.com/killbill/killbill-deposit-plugin/master/src/main/resources/ddl.sql | mysql -h 127.0.0.1 -u root --password=root killbill | |
| else | |
| echo "Warning: DDL file not found at expected location, checking for alternative branches..." | |
| # Try main branch as an alternative | |
| if curl -s --head https://raw.githubusercontent.com/killbill/killbill-deposit-plugin/main/src/main/resources/ddl.sql | head -n 1 | grep "200" > /dev/null; then | |
| echo "DDL file found on main branch, applying to MySQL..." | |
| curl -s https://raw.githubusercontent.com/killbill/killbill-deposit-plugin/main/src/main/resources/ddl.sql | mysql -h 127.0.0.1 -u root --password=root killbill | |
| else | |
| echo "Error: Cannot find DDL file. Repository or file path might be incorrect." | |
| echo "Continuing without DDL, but this might cause issues later." | |
| fi | |
| fi | |
| - name: Install plugin specific PostgreSQL DDL | |
| if: ${{ matrix.docker-compose-file == 'docker-compose.ci.postgresql.yml' }} | |
| run: | | |
| echo "Fetching DDL script from GitHub..." | |
| # First check if the DDL file is accessible | |
| if curl -s --head https://raw.githubusercontent.com/killbill/killbill-deposit-plugin/master/src/main/resources/ddl.sql | head -n 1 | grep "200" > /dev/null; then | |
| echo "DDL file found, applying to PostgreSQL..." | |
| curl -s https://raw.githubusercontent.com/killbill/killbill-deposit-plugin/master/src/main/resources/ddl.sql | psql -h 127.0.0.1 -U postgres -p 5432 -d killbill | |
| else | |
| echo "Warning: DDL file not found at expected location, checking for alternative branches..." | |
| # Try main branch as an alternative | |
| if curl -s --head https://raw.githubusercontent.com/killbill/killbill-deposit-plugin/main/src/main/resources/ddl.sql | head -n 1 | grep "200" > /dev/null; then | |
| echo "DDL file found on main branch, applying to PostgreSQL..." | |
| curl -s https://raw.githubusercontent.com/killbill/killbill-deposit-plugin/main/src/main/resources/ddl.sql | psql -h 127.0.0.1 -U postgres -p 5432 -d killbill | |
| else | |
| echo "Error: Cannot find DDL file. Repository or file path might be incorrect." | |
| echo "Continuing without DDL, but this might cause issues later." | |
| fi | |
| fi | |
| - name: Install plugin | |
| run: | | |
| echo "Installing deposit plugin..." | |
| curl --connect-timeout 10 --max-time 30 -v \ | |
| -X POST \ | |
| -u admin:password \ | |
| -H 'Content-Type: application/json' \ | |
| -H 'X-Killbill-CreatedBy: GitHub' \ | |
| -d '{ | |
| "nodeCommandProperties": [ | |
| { | |
| "key": "pluginKey", | |
| "value": "deposit" | |
| } | |
| ], | |
| "nodeCommandType": "INSTALL_PLUGIN", | |
| "isSystemCommandType": "true" | |
| }' \ | |
| "http://${KB_ADDRESS}:${KB_PORT}/1.0/kb/nodesInfo" | |
| # Install tools we need | |
| echo "Installing jq for JSON parsing..." | |
| sudo apt-get update && sudo apt-get install -y jq | |
| # Wait a bit before checking status | |
| echo "Giving the plugin some time to install..." | |
| sleep 10 | |
| # Debug: Check nodesInfo response | |
| echo "Checking nodesInfo response..." | |
| curl -s -uadmin:password "http://${KB_ADDRESS}:${KB_PORT}/1.0/kb/nodesInfo" > nodesInfo.json | |
| cat nodesInfo.json | |
| count=0 | |
| echo "Waiting for plugin to be in STOPPED state..." | |
| # More robust check with better error handling | |
| until [[ "$(jq -r '.[]?.pluginsInfo[]? | select(.pluginKey == "deposit") | .state' nodesInfo.json 2>/dev/null)" == "STOPPED" ]]; do | |
| if [[ "$count" == "180" ]]; then | |
| echo "ERROR: Timed out waiting for plugin to be in STOPPED state." | |
| echo "Current plugin status:" | |
| curl -s -uadmin:password "http://${KB_ADDRESS}:${KB_PORT}/1.0/kb/nodesInfo" | jq | |
| exit 64 | |
| fi | |
| # Debug every 30 seconds | |
| if [[ "$((count % 30))" == "0" ]]; then | |
| echo "Checking plugin status (attempt $count)..." | |
| curl -s -uadmin:password "http://${KB_ADDRESS}:${KB_PORT}/1.0/kb/nodesInfo" > nodesInfo.json | |
| echo "Plugin status: $(jq -r '.[]?.pluginsInfo[]? | select(.pluginKey == "deposit") | .state' nodesInfo.json 2>/dev/null || echo "NOT_FOUND")" | |
| fi | |
| count=$(( count + 1 )) | |
| sleep 1 | |
| # Update nodesInfo.json every iteration | |
| curl -s -uadmin:password "http://${KB_ADDRESS}:${KB_PORT}/1.0/kb/nodesInfo" > nodesInfo.json | |
| done | |
| echo "Starting the deposit plugin..." | |
| curl --connect-timeout 10 --max-time 30 -v \ | |
| -X POST \ | |
| -u admin:password \ | |
| -H 'Content-Type: application/json' \ | |
| -H 'X-Killbill-CreatedBy: GitHub' \ | |
| -d '{ | |
| "nodeCommandProperties": [ | |
| { | |
| "key": "pluginKey", | |
| "value": "deposit" | |
| } | |
| ], | |
| "nodeCommandType": "START_PLUGIN", | |
| "isSystemCommandType": "true" | |
| }' \ | |
| "http://${KB_ADDRESS}:${KB_PORT}/1.0/kb/nodesInfo" | |
| count=0 | |
| echo "Waiting for plugin to be in RUNNING state..." | |
| # More robust check with better error handling | |
| until [[ "$(jq -r '.[]?.pluginsInfo[]? | select(.pluginKey == "deposit") | .state' nodesInfo.json 2>/dev/null)" == "RUNNING" ]]; do | |
| if [[ "$count" == "180" ]]; then | |
| echo "ERROR: Timed out waiting for plugin to be in RUNNING state." | |
| echo "Current plugin status:" | |
| curl -s -uadmin:password "http://${KB_ADDRESS}:${KB_PORT}/1.0/kb/nodesInfo" | jq | |
| exit 65 | |
| fi | |
| # Debug every 30 seconds | |
| if [[ "$((count % 30))" == "0" ]]; then | |
| echo "Checking plugin status (attempt $count)..." | |
| curl -s -uadmin:password "http://${KB_ADDRESS}:${KB_PORT}/1.0/kb/nodesInfo" > nodesInfo.json | |
| echo "Plugin status: $(jq -r '.[]?.pluginsInfo[]? | select(.pluginKey == "deposit") | .state' nodesInfo.json 2>/dev/null || echo "NOT_FOUND")" | |
| fi | |
| count=$(( count + 1 )) | |
| sleep 1 | |
| # Update nodesInfo.json every iteration | |
| curl -s -uadmin:password "http://${KB_ADDRESS}:${KB_PORT}/1.0/kb/nodesInfo" > nodesInfo.json | |
| done | |
| echo "Plugin is now in RUNNING state." | |
| - name: Run tests | |
| env: | |
| DB_ADAPTER: ${{ matrix.database-adapter }} | |
| DB_USER: ${{ matrix.database-user }} | |
| DB_PASSWORD: ${{ matrix.database-password }} | |
| DB_PORT: ${{ matrix.database-port }} | |
| run: | | |
| # Some flakiness unfortunately | |
| ./bin/retry bundle exec rails t -w -f | |
| - name: Debugging after failure | |
| if: failure() | |
| run: | | |
| echo "[DEBUG] killbill healthcheck" | |
| curl --connect-timeout 10 --max-time 30 -v http://$\{KB_ADDRESS\}:$\{KB_PORT\}/1.0/healthcheck || true | |
| echo "[DEBUG] hostname" | |
| hostname | |
| echo "[DEBUG] netstat -tulpn" | |
| sudo netstat -tulpn | |
| echo "[DEBUG] docker network ls" | |
| docker network ls | |
| echo "[DEBUG] docker ps -a" | |
| docker ps -a | |
| echo "[DEBUG] killbill env" | |
| docker exec it-killbill-1 env || true | |
| echo "[DEBUG] db env" | |
| docker exec it-db-1 env || true | |
| echo "[DEBUG] killbill logs" | |
| docker logs -t --details it-killbill-1 || true | |
| echo "[DEBUG] db logs" | |
| docker logs -t --details it-db-1 || true |