Skip to content

Add GitHub Actions workflow for PR checks including linting, testing,… #1

Add GitHub Actions workflow for PR checks including linting, testing,…

Add GitHub Actions workflow for PR checks including linting, testing,… #1

name: Agent Manager Service PR Checks
on:
push:
branches: ["main"]
paths:
- "agent-manager-service/**"
- ".github/workflows/agent-manager-service-pr-checks.yml"
pull_request:
branches: ["main"]
paths:
- "agent-manager-service/**"
- ".github/workflows/agent-manager-service-pr-checks.yml"
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./agent-manager-service
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.24.2"
cache-dependency-path: agent-manager-service/go.sum
- name: Install golangci-lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.1.0
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Install goimports
run: go install golang.org/x/tools/cmd/goimports@latest
- name: Run lint
run: make lint
test:
name: Test
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./agent-manager-service
services:
postgres:
image: postgres:15-alpine
env:
POSTGRES_USER: agentmanager
POSTGRES_PASSWORD: agentmanager
POSTGRES_DB: agentmanager
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.24.2"
cache-dependency-path: agent-manager-service/go.sum
- name: Create test .env file
run: |
cat > .env << 'EOF'
DB_HOST=localhost
DB_PORT=5432
DB_USER=agentmanager
DB_PASSWORD=agentmanager
DB_NAME=agentmanager
SERVER_PORT=8080
API_KEY_VALUE=test-key
IS_LOCAL_DEV_ENV=true
AMP_VERSION=v0.1.0-rc7
EOF
- name: Wait for PostgreSQL
run: |
until pg_isready -h localhost -p 5432 -U agentmanager; do
echo "Waiting for postgres..."
sleep 1
done
timeout-minutes: 2
- name: Run tests
run: make test
- name: Upload test logs on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-logs
path: agent-manager-service/localdata/test_output.log
if-no-files-found: ignore
build:
name: Build
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./agent-manager-service
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.24.2"
cache-dependency-path: agent-manager-service/go.sum
- name: Build
run: go build -v ./...
codegen-format:
name: Code Generation & Format Check
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./agent-manager-service
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.24.2"
cache-dependency-path: agent-manager-service/go.sum
- name: Install wire
run: go install github.com/google/wire/cmd/wire@latest
- name: Install goimports
run: go install golang.org/x/tools/cmd/goimports@latest
- name: Run wire code generation
run: make wire
- name: Run go generate
run: make codegen
- name: Run formatting
run: make fmt
- name: Run go mod tidy
run: go mod tidy
- name: Check for uncommitted changes
run: |
if [ ! -z "$(git status --porcelain)" ]; then
echo "Code generation or formatting produced changes:"
git diff
git status
echo ""
echo "Please run 'make wire && make codegen && make fmt && go mod tidy' locally and commit the changes."
exit 1
fi