From 18f9798506d37ea5f39245c59072daa046fdbfc4 Mon Sep 17 00:00:00 2001 From: phamnazage-jpg <247508310+phamnazage-jpg@users.noreply.github.com> Date: Tue, 12 May 2026 18:40:42 +0800 Subject: [PATCH] ci: add github actions workflow --- .github/workflows/ci.yml | 59 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..f422d6c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,59 @@ +name: ai-ops-ci + +on: + push: + branches: [ main, master ] + pull_request: + branches: [ main, master ] + +jobs: + test: + runs-on: ubuntu-latest + services: + postgres: + image: postgres:16-alpine + env: + POSTGRES_USER: aiops + POSTGRES_PASSWORD: aiops123 + POSTGRES_DB: ai_ops + ports: + - 5432:5432 + options: >- + --health-cmd="pg_isready -U aiops -d ai_ops" + --health-interval=10s + --health-timeout=5s + --health-retries=5 + redis: + image: redis:7-alpine + ports: + - 6379:6379 + options: >- + --health-cmd="redis-cli ping" + --health-interval=10s + --health-timeout=5s + --health-retries=5 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.22.x' + cache: true + + - name: Verify formatting + run: test -z "$(gofmt -l .)" + + - name: Build + run: go build -buildvcs=false ./... + + - name: Test + run: go test -buildvcs=false -race ./... + + - name: Apply migrations smoke test + env: + PGPASSWORD: aiops123 + run: | + psql -h localhost -U aiops -d ai_ops -f tech/migrations/000001_init_schema.up.sql + psql -h localhost -U aiops -d ai_ops -f tech/migrations/000002_add_notification_logs.up.sql