forked from wso2/agent-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathagent-manager-service-pr-checks.yml
More file actions
153 lines (128 loc) · 3.91 KB
/
agent-manager-service-pr-checks.yml
File metadata and controls
153 lines (128 loc) · 3.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: Agent Manager API 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
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: ./.github/actions/setup-go
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v9
with:
working-directory: agent-manager-service
args: --config .github/linters/.golangci.yaml
test:
name: Test
runs-on: ubuntu-latest
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: ./.github/actions/setup-go
- name: Create test .env file
working-directory: ./agent-manager-service
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-api-key
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 database migrations
working-directory: ./agent-manager-service
run: ENV_FILE_PATH=.env go run main.go --migrate --server=false
- name: Run tests
working-directory: ./agent-manager-service
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
retention-days: 7
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: ./.github/actions/setup-go
- name: Build
working-directory: ./agent-manager-service
run: go build -v ./...
codegen-format:
name: Code Generation & Format Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: ./.github/actions/setup-go
- 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: Install moq
run: go install github.com/matryer/moq@latest
- name: Run wire code generation
working-directory: ./agent-manager-service
run: make wire
- name: Run go generate
working-directory: ./agent-manager-service
run: make codegen
- name: Run formatting
working-directory: ./agent-manager-service
run: make fmt
- name: Run go mod tidy
working-directory: ./agent-manager-service
run: go mod tidy
- name: Check for uncommitted changes
working-directory: ./agent-manager-service
run: |
if [ ! -z "$(git status --porcelain)" ]; then
echo "Code generation or formatting produced changes:"
git diff
git status
echo ""
echo "Please run 'make codegenfmt-check' locally and commit the changes."
exit 1
fi