diff --git a/.github/workflows/bruno.yml b/.github/workflows/bruno.yml new file mode 100644 index 00000000..04f78c21 --- /dev/null +++ b/.github/workflows/bruno.yml @@ -0,0 +1,80 @@ +# Standalone workflow for Bruno end-to-end tests. +name: bruno-e2e + +on: + pull_request: + branches: [ "main" ] + paths-ignore: + - 'README.md' + - '**/README.md' + +env: + GO_VERSION: stable + SQLC_VERSION: '1.29.0' + +jobs: + bruno: + name: Bruno E2E + runs-on: ubuntu-latest + timeout-minutes: 25 + steps: + - name: Checkout repository + uses: actions/checkout@v6 + + - uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: xsltproc + version: 1.0 + + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version: ${{ env.GO_VERSION }} + cache-dependency-path: | + go.work.sum + broker/go.sum + illmock/go.sum + + - name : Ensure sqlc is installed + uses: sqlc-dev/setup-sqlc@v4 + with: + sqlc-version: ${{ env.SQLC_VERSION }} + + - name: Generate sources + run: make generate + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 22 + + - name: Start Crosslink stack + run: docker compose -f bruno/docker-compose.yml up -d --build + + - name: Wait for broker readiness + run: | + for i in {1..60}; do + if curl -sSf -o /dev/null http://localhost:8080/healthz; then + exit 0 + fi + sleep 2 + done + echo "Broker did not become ready in time" + docker compose -f bruno/docker-compose.yml ps + docker compose -f bruno/docker-compose.yml logs --no-color broker postgres illmock + exit 1 + + - name: Run Bruno collection (headless) + working-directory: bruno/crosslink + run: | + npx --yes @usebruno/cli@3.1.3 run \ + --env LocalDev \ + --env-var userPassword="dummy" + + - name: Print container logs on failure + if: failure() + run: docker compose -f bruno/docker-compose.yml logs --no-color + + - name: Stop Crosslink stack + if: always() + run: docker compose -f bruno/docker-compose.yml down -v --remove-orphans diff --git a/bruno/README.md b/bruno/README.md index 40d3e890..cb646fe8 100644 --- a/bruno/README.md +++ b/bruno/README.md @@ -12,7 +12,7 @@ docker compose up 2. Launch Bruno and open the `crosslink` collection located in this directory. -3. In Bruno, load the `Local Dev` environment. +3. In Bruno, load the `LocalDev` environment. 4. Run all steps in the Bruno runner. All HTTP response codes and validations should be green. diff --git a/bruno/docker-compose.yml b/bruno/docker-compose.yml index 819fb302..b1b88a27 100644 --- a/bruno/docker-compose.yml +++ b/bruno/docker-compose.yml @@ -1,6 +1,6 @@ services: postgres: - image: postgres:latest + image: postgres:16 container_name: crosslink_postgres environment: POSTGRES_USER: crosslink @@ -8,8 +8,6 @@ services: POSTGRES_DB: crosslink ports: - "25432:5432" - volumes: - - ./pg_data:/var/lib/postgresql healthcheck: test: ["CMD-SHELL", "pg_isready -U crosslink -d crosslink"] interval: 5s @@ -17,26 +15,6 @@ services: retries: 20 start_period: 5s - db-up: - profiles: ["db-up"] - build: - context: .. - dockerfile: broker/Dockerfile - container_name: crosslink_db_up - depends_on: - postgres: - condition: service_healthy - command: ["/broker", "db-up"] - environment: - DB_TYPE: postgres - DB_USER: crosslink - DB_PASSWORD: crosslink - DB_HOST: postgres - DB_DATABASE: crosslink - DB_PORT: 5432 - DB_PROVISION: "true" - DB_MIGRATE: "true" - broker: build: context: ..