infrahub 0.4.0

small graphql client for infrahub
Documentation
name: Integration

on:
  workflow_dispatch:
  pull_request:
    branches:
      - "**"
    paths:
      - "Cargo.toml"
      - "Cargo.lock"
      - "src/**"
      - "tests/**"
      - "test-client/**"
      - "schema/**"
      - ".github/workflows/integration.yml"
  push:
    branches:
      - main
    paths:
      - "Cargo.toml"
      - "Cargo.lock"
      - "src/**"
      - "tests/**"
      - "test-client/**"
      - "schema/**"
      - ".github/workflows/integration.yml"
  schedule:
    - cron: "0 6 * * 1"

jobs:
  smoke:
    runs-on: ubuntu-latest
    timeout-minutes: 30
    env:
      INFRAHUB_VERSION: 1.9.6
      INFRAHUB_URL: http://localhost:8000
      INFRAHUB_ADMIN_PASSWORD: ci-admin-password
      INFRAHUB_ADMIN_TOKEN: ci-admin-token

    steps:
      - name: Checkout
        uses: actions/checkout@v6

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable

      - name: Cache cargo
        uses: kunobi-ninja/kache-action@v1
        with:
          cache-key-prefix: kache-smoke

      - name: Download Infrahub docker compose
        run: |
          curl -sSfL \
            "https://raw.githubusercontent.com/opsmill/infrahub/infrahub-v${INFRAHUB_VERSION}/docker-compose.yml" \
            -o /tmp/infrahub-compose.yml

      - name: Start Infrahub
        env:
          VERSION: ${{ env.INFRAHUB_VERSION }}
          INFRAHUB_IMAGE_TAG: ${{ env.INFRAHUB_VERSION }}
          INFRAHUB_INITIAL_ADMIN_PASSWORD: ${{ env.INFRAHUB_ADMIN_PASSWORD }}
          INFRAHUB_INITIAL_ADMIN_TOKEN: ${{ env.INFRAHUB_ADMIN_TOKEN }}
        run: docker compose -f /tmp/infrahub-compose.yml up -d

      - name: Wait for Infrahub readiness
        run: |
          set -euo pipefail
          for i in $(seq 1 180); do
            if curl -fsS "${INFRAHUB_URL}/api/config" >/dev/null 2>&1; then
              echo "Infrahub is ready after ${i} checks"
              exit 0
            fi
            sleep 5
          done

          echo "Infrahub failed readiness checks; dumping logs"
          docker compose -f /tmp/infrahub-compose.yml logs --tail 200 || true
          exit 1

      - name: Verify generated test client is up to date
        run: |
          cargo run --bin infrahub-codegen -- \
            --schema schema/infrahub.graphql \
            --out /tmp/test-client-check \
            --crate-name infrahub-test-client \
            --infrahub-path ..
          diff -r test-client/src /tmp/test-client-check/src

      - name: Run smoke tests
        env:
          INFRAHUB_TOKEN: ${{ env.INFRAHUB_ADMIN_TOKEN }}
        run: |
          cargo test -p infrahub --test smoke_query
          cargo test -p infrahub-test-client --test smoke_api -- --test-threads=1