Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 125 additions & 7 deletions .github/workflows/gateway-integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,40 @@ on:
branches:
- main
paths:
- 'gateway/**'
- '.github/workflows/gateway-integration-test.yml'
- "gateway/**"
- "tests/mock-servers/**"
- "samples/sample-service/**"
- ".github/workflows/gateway-integration-test.yml"
- ".github/workflows/gateway-integration-test-postgres.yml"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if the referenced workflow file exists
fd "gateway-integration-test-postgres.yml" .github/workflows/

Repository: wso2/api-platform

Length of output: 43


Remove the stale path filter entry for gateway-integration-test-postgres.yml.

The referenced workflow file does not exist, so this path filter will never trigger. Either restore the postgres integration workflow file or remove this entry from the filter.

🤖 Prompt for AI Agents
In @.github/workflows/gateway-integration-test.yml at line 13, Remove the stale
path filter entry ".github/workflows/gateway-integration-test-postgres.yml" from
the paths list in the workflow configuration in gateway-integration-test.yml (or
alternatively restore that missing workflow file if intended); update the paths
filter so it only references existing workflow files and ensure the paths array
no longer contains the exact string
".github/workflows/gateway-integration-test-postgres.yml".


permissions:
contents: read

jobs:
integration-test:
build-images:
runs-on: ubuntu-24.04
env:
BUILDX_CACHE_ARGS: >-
--cache-from type=gha,scope=gateway-it-pr-build
--cache-to type=gha,mode=max,scope=gateway-it-pr-build
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25'
go-version: "1.25"
cache: true
cache-dependency-path: |
go.work.sum
gateway/gateway-controller/go.sum
gateway/gateway-builder/go.sum
gateway/gateway-runtime/policy-engine/go.sum
gateway/it/go.sum
gateway/system-policies/analytics/go.sum
gateway/sample-policies/count-letters/go.sum
gateway/sample-policies/uppercase-body/go.sum

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -41,24 +61,122 @@ jobs:
cd samples/sample-service
make build

- name: Export reusable integration images
run: |
mkdir -p /tmp/ci-images
docker save \
ghcr.io/wso2/api-platform/gateway-controller-coverage:test \
ghcr.io/wso2/api-platform/gateway-runtime-coverage:test \
ghcr.io/wso2/api-platform/sample-service:latest \
ghcr.io/wso2/api-platform/mock-jwks:latest \
ghcr.io/wso2/api-platform/mock-azure-content-safety:latest \
ghcr.io/wso2/api-platform/mock-aws-bedrock-guardrail:latest \
ghcr.io/wso2/api-platform/mock-embedding-provider:latest \
ghcr.io/wso2/api-platform/mock-analytics-collector:latest | gzip > /tmp/ci-images/gateway-it-images.tar.gz

- name: Upload reusable integration images
uses: actions/upload-artifact@v4
with:
name: gateway-it-images
path: /tmp/ci-images/gateway-it-images.tar.gz
retention-days: 1

integration-test:
runs-on: ubuntu-24.04
needs: build-images
strategy:
fail-fast: false
matrix:
include:
- mode: sqlite
compose_file: docker-compose.test.yaml
suffix: normal
- mode: postgres
compose_file: docker-compose.test.postgres.yaml
suffix: postgres
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.25"
cache: true
cache-dependency-path: |
go.work.sum
gateway/it/go.sum

- name: Download reusable integration images
uses: actions/download-artifact@v4
with:
name: gateway-it-images
path: /tmp/ci-images

- name: Load reusable integration images
run: |
gzip -dc /tmp/ci-images/gateway-it-images.tar.gz | docker load

- name: Record test start time
run: echo "TEST_START_TS=$(date +%s)" >> "$GITHUB_ENV"

- name: Verify gateway-controller uses PostgreSQL
if: matrix.mode == 'postgres'
run: |
set -euo pipefail
cd gateway/it

PROJECT="gateway-it-postgres-verify"
cleanup() {
docker compose -p "$PROJECT" -f docker-compose.test.postgres.yaml down -v --remove-orphans || true
}
trap cleanup EXIT

docker compose -p "$PROJECT" -f docker-compose.test.postgres.yaml up -d postgres gateway-controller

timeout 90 bash -c 'until curl -fsS http://localhost:9090/health >/dev/null; do sleep 2; done'

docker logs it-gateway-controller > /tmp/gateway-controller.log 2>&1 || true
grep -Eq "Initializing PostgreSQL storage|PostgreSQL schema up to date" /tmp/gateway-controller.log

schema_count="$(docker compose -p "$PROJECT" -f docker-compose.test.postgres.yaml exec -T postgres \
psql -U gateway -d gateway_test -tAc "SELECT COUNT(*) FROM schema_migrations WHERE id = 1 AND version >= 1;")"
[ "$schema_count" = "1" ]

conn_count="$(docker compose -p "$PROJECT" -f docker-compose.test.postgres.yaml exec -T postgres \
psql -U gateway -d gateway_test -tAc "SELECT COUNT(*) FROM pg_stat_activity WHERE application_name = 'gateway-controller';")"
[ "${conn_count:-0}" -ge 1 ]

- name: Run integration tests
run: |
cd gateway
make test-integration
COMPOSE_FILE=${{ matrix.compose_file }} make test-integration

- name: Publish test duration metrics
if: always()
run: |
end_ts="$(date +%s)"
start_ts="${TEST_START_TS:-$end_ts}"
duration="$((end_ts - start_ts))"
minutes="$((duration / 60))"
seconds="$((duration % 60))"
echo "### Gateway integration timing" >> "$GITHUB_STEP_SUMMARY"
echo "- Mode: \`${{ matrix.mode }}\`" >> "$GITHUB_STEP_SUMMARY"
echo "- Duration: ${minutes}m ${seconds}s (${duration}s)" >> "$GITHUB_STEP_SUMMARY"

- name: Upload coverage report
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-report
name: coverage-report-${{ matrix.suffix }}
path: gateway/it/coverage/output
retention-days: 7

- name: Upload test reports
uses: actions/upload-artifact@v4
if: always()
with:
name: test-reports
name: test-reports-${{ matrix.suffix }}
path: gateway/it/reports/
retention-days: 7

Expand Down
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why rename?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this to run Postgres not in PR, but after PR merge?

Original file line number Diff line number Diff line change
@@ -1,25 +1,58 @@
name: Gateway Integration Test (Postgres)
name: Gateway Post-Merge Integration Check

on:
workflow_dispatch:
pull_request:
push:
branches:
- main
paths:
- 'gateway/**'
- '.github/workflows/gateway-integration-test-postgres.yml'
- "gateway/**"
- "tests/mock-servers/**"
- "samples/sample-service/**"
- ".github/workflows/gateway-post-merge-integration-check.yml"

permissions:
contents: read

concurrency:
group: gateway-post-merge-it-${{ github.ref }}
cancel-in-progress: true

jobs:
integration-test:
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
include:
- mode: normal
compose_file: docker-compose.test.yaml
suffix: normal
- mode: postgres
compose_file: docker-compose.test.postgres.yaml
suffix: postgres
env:
BUILDX_CACHE_ARGS: >-
--cache-from type=gha,scope=gateway-it-${{ matrix.mode }}
--cache-to type=gha,mode=max,scope=gateway-it-${{ matrix.mode }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25'
go-version: "1.25"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🌐 Web query:

Go 1.25 release date availability

💡 Result:

  • Go 1.25 release date: August 12, 2025 (Go 1.25.0). [1][2]
  • Availability: Go 1.25 binary installers/archives are available from the official downloads page (go.dev/dl). [1][3]
  • Updates: Go 1.25 has received minor (patch) releases after 1.25.0 (for example Go 1.25.1 on September 3, 2025). [2]

Sources: [1] Go blog announcement, [2] Go release history, [3] Official downloads page.


🏁 Script executed:

cat -n .github/workflows/gateway-post-merge-integration-check.yml

Repository: wso2/api-platform

Length of output: 6880


Fix container name in postgres verification step (line 96).

When docker compose -p "gateway-it-postgres-verify" is used (line 86), the gateway-controller container is named gateway-it-postgres-verify-gateway-controller-1, not it-gateway-controller. Line 96 attempts to read logs from a non-existent container, creating an empty log file. The subsequent grep (line 97) then fails under set -euo pipefail, causing the step to always fail. Use the correct container name: docker logs gateway-it-postgres-verify-gateway-controller-1 or reference the service name via docker compose -p "$PROJECT" logs gateway-controller.

Additionally, the two "Run integration tests" steps (lines 107–118) are identical except for their conditions; consolidate into a single step.

🤖 Prompt for AI Agents
In @.github/workflows/gateway-post-merge-integration-check.yml at line 45, The
workflow uses the wrong container name when collecting logs after `docker
compose -p "gateway-it-postgres-verify"`; replace the incorrect
`it-gateway-controller` reference with the actual container name
`gateway-it-postgres-verify-gateway-controller-1` or, better, use `docker
compose -p "$PROJECT" logs gateway-controller` (or `docker logs
gateway-it-postgres-verify-gateway-controller-1`) so the logs file is populated
and the grep won’t fail under set -euo pipefail; also consolidate the two
duplicated "Run integration tests" steps (the identical steps that differ only
by condition) into a single step that contains both conditional logic or a
unified condition to avoid repetition.

cache: true
cache-dependency-path: |
go.work.sum
gateway/gateway-controller/go.sum
gateway/gateway-builder/go.sum
gateway/gateway-runtime/policy-engine/go.sum
gateway/it/go.sum
gateway/system-policies/analytics/go.sum
gateway/sample-policies/count-letters/go.sum
gateway/sample-policies/uppercase-body/go.sum

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -36,7 +69,16 @@ jobs:
docker build -t ghcr.io/wso2/api-platform/$mock:latest tests/mock-servers/$mock
done

- name: Build sample-service
run: |
cd samples/sample-service
make build

- name: Record test start time
run: echo "TEST_START_TS=$(date +%s)" >> "$GITHUB_ENV"

- name: Verify gateway-controller uses PostgreSQL
if: matrix.mode == 'postgres'
run: |
set -euo pipefail
cd gateway/it
Expand All @@ -62,24 +104,43 @@ jobs:
psql -U gateway -d gateway_test -tAc "SELECT COUNT(*) FROM pg_stat_activity WHERE application_name = 'gateway-controller';")"
[ "${conn_count:-0}" -ge 1 ]

- name: Run integration tests
- name: Run integration tests (normal)
if: matrix.mode == 'normal'
run: |
cd gateway
COMPOSE_FILE=docker-compose.test.postgres.yaml make test-integration
COMPOSE_FILE=${{ matrix.compose_file }} make test-integration

- name: Run integration tests (postgres)
if: matrix.mode == 'postgres'
run: |
cd gateway
COMPOSE_FILE=${{ matrix.compose_file }} make test-integration

- name: Publish test duration metrics
if: always()
run: |
end_ts="$(date +%s)"
start_ts="${TEST_START_TS:-$end_ts}"
duration="$((end_ts - start_ts))"
minutes="$((duration / 60))"
seconds="$((duration % 60))"
echo "### Gateway integration timing" >> "$GITHUB_STEP_SUMMARY"
echo "- Mode: \`${{ matrix.mode }}\`" >> "$GITHUB_STEP_SUMMARY"
echo "- Duration: ${minutes}m ${seconds}s (${duration}s)" >> "$GITHUB_STEP_SUMMARY"

- name: Upload coverage report
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-report-postgres
name: coverage-report-${{ matrix.suffix }}
path: gateway/it/coverage/output
retention-days: 7

- name: Upload test reports
uses: actions/upload-artifact@v4
if: always()
with:
name: test-reports-postgres
name: test-reports-${{ matrix.suffix }}
path: gateway/it/reports/
retention-days: 7

Expand Down
3 changes: 3 additions & 0 deletions gateway/gateway-builder/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ DOCKER_REGISTRY ?= ghcr.io/wso2/api-platform
IMAGE_NAME := $(DOCKER_REGISTRY)/gateway-builder
IMAGE_TAG := $(VERSION)
FULL_IMAGE := $(IMAGE_NAME):$(IMAGE_TAG)
BUILDX_CACHE_ARGS ?=

.DEFAULT_GOAL := help

Expand Down Expand Up @@ -58,6 +59,7 @@ help: ## Show this help message
build: ## Build Docker image using buildx
@echo "Building Docker image ($(IMAGE_NAME):$(VERSION))..."
@docker buildx build -f Dockerfile \
$(BUILDX_CACHE_ARGS) \
--build-context policy-engine=../gateway-runtime/policy-engine \
--build-context system-policies=../system-policies \
--build-context sdk=../../sdk \
Expand Down Expand Up @@ -93,6 +95,7 @@ push: ## Push Docker image to registry
build-and-push-multiarch: ## Build and push multi-architecture Docker image (linux/amd64, linux/arm64)
@echo "Building and pushing multi-arch Docker image: $(IMAGE_NAME):$(VERSION)"
docker buildx build -f Dockerfile \
$(BUILDX_CACHE_ARGS) \
--build-context policy-engine=../gateway-runtime/policy-engine \
--build-context system-policies=../system-policies \
--build-context sdk=../../sdk \
Expand Down
4 changes: 4 additions & 0 deletions gateway/gateway-controller/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ LDFLAGS := -X main.Version=$(VERSION) -X main.GitCommit=$(GIT_COMMIT) -X main.Bu
# Docker image configuration
DOCKER_REGISTRY ?= ghcr.io/wso2/api-platform
IMAGE_NAME := $(DOCKER_REGISTRY)/gateway-controller
BUILDX_CACHE_ARGS ?=

.PHONY: help generate build build-local test generate-listener-certs push build-coverage-image

Expand All @@ -48,6 +49,7 @@ test: ## Run unit and integration tests
build: generate test ## Build Docker image using buildx
@echo "Building Docker image ($(IMAGE_NAME):$(VERSION))..."
docker buildx build -f Dockerfile \
$(BUILDX_CACHE_ARGS) \
--build-context sdk=../../sdk \
--build-context common=../../common \
--build-arg VERSION=$(VERSION) \
Expand Down Expand Up @@ -76,6 +78,7 @@ push: ## Push Docker image to registry
build-and-push-multiarch: ## Build and push multi-architecture Docker image (linux/amd64, linux/arm64)
@echo "Building and pushing multi-arch Docker image: $(IMAGE_NAME):$(VERSION)"
docker buildx build -f Dockerfile \
$(BUILDX_CACHE_ARGS) \
--build-context sdk=../../sdk \
--build-context common=../../common \
--platform linux/amd64,linux/arm64 \
Expand All @@ -88,6 +91,7 @@ build-and-push-multiarch: ## Build and push multi-architecture Docker image (lin

build-coverage-image: test ## Build coverage-instrumented gateway-controller image
docker buildx build -f Dockerfile \
$(BUILDX_CACHE_ARGS) \
--build-context sdk=../../sdk \
--build-context common=../../common \
--build-arg VERSION=$(VERSION) \
Expand Down
7 changes: 6 additions & 1 deletion gateway/gateway-runtime/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
# Docker image configuration
DOCKER_REGISTRY ?= ghcr.io/wso2/api-platform
IMAGE_NAME := $(DOCKER_REGISTRY)/gateway-runtime
BUILDX_CACHE_ARGS ?=

.PHONY: help build build-local build-coverage-image push clean build-and-push-multiarch test

Expand All @@ -38,6 +39,7 @@ build: ## Build Gateway Runtime Docker image using buildx
@echo "Building Gateway Runtime Docker image ($(IMAGE_NAME):$(VERSION))..."
@mkdir -p target && cp ../build.yaml target/
docker buildx build -f Dockerfile \
$(BUILDX_CACHE_ARGS) \
--build-context sdk=../../sdk \
--build-context common=../../common \
--build-context gateway-builder=../gateway-builder \
Expand Down Expand Up @@ -74,7 +76,8 @@ build-local: ## Build Gateway Runtime Docker image locally (faster, no buildx)
build-coverage-image: test ## Build Gateway Runtime Docker image with coverage instrumentation
@echo "Building Gateway Runtime coverage image ($(IMAGE_NAME)-coverage:$(VERSION))..."
@mkdir -p target && cp ../build.yaml target/
DOCKER_BUILDKIT=1 docker build -f Dockerfile \
docker buildx build -f Dockerfile \
$(BUILDX_CACHE_ARGS) \
--build-context sdk=../../sdk \
--build-context common=../../common \
--build-context gateway-builder=../gateway-builder \
Expand All @@ -85,6 +88,7 @@ build-coverage-image: test ## Build Gateway Runtime Docker image with coverage i
--build-arg GIT_COMMIT=$(GIT_COMMIT) \
--build-arg ENABLE_COVERAGE=true \
-t $(IMAGE_NAME)-coverage:$(VERSION) \
--load \
.
@rm -rf target
@echo "Coverage image built successfully: $(IMAGE_NAME)-coverage:$(VERSION)"
Expand All @@ -98,6 +102,7 @@ build-and-push-multiarch: ## Build and push Gateway Runtime Docker image for mul
@echo "Building and pushing multi-arch Gateway Runtime Docker image ($(VERSION))..."
@mkdir -p target && cp ../build.yaml target/
docker buildx build -f Dockerfile \
$(BUILDX_CACHE_ARGS) \
--build-context sdk=../../sdk \
--build-context common=../../common \
--build-context gateway-builder=../gateway-builder \
Expand Down
Loading