Skip to content

Commit dc3baa5

Browse files
Add CI workflow for Agents service
1 parent 406e5fc commit dc3baa5

1 file changed

Lines changed: 104 additions & 0 deletions

File tree

.github/workflows/ci-agents.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
2+
name: CI — Agents Service
3+
4+
on:
5+
push:
6+
branches: [main]
7+
pull_request:
8+
branches: [main]
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}/agents
13+
14+
jobs:
15+
lint:
16+
name: Lint & Import Check (Agents)
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: write
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
with:
24+
ref: ${{ github.head_ref || github.ref_name }}
25+
fetch-depth: 0
26+
27+
- name: Set up Python
28+
uses: actions/setup-python@v5
29+
with:
30+
python-version: "3.11"
31+
cache: "pip"
32+
33+
- name: Install lint dependencies
34+
run: |
35+
pip install flake8 black isort
36+
[ -f agents/requirements.txt ] && pip install -r agents/requirements.txt || true
37+
38+
- name: Black auto-format
39+
run: black agents/
40+
41+
- name: isort auto-fix import order
42+
run: isort agents/
43+
44+
- name: Commit formatting fixes (if any)
45+
uses: stefanzweifel/git-auto-commit-action@v5
46+
with:
47+
commit_message: "style: auto-format agents/ with black & isort [skip ci]"
48+
file_pattern: "agents/**/*.py"
49+
50+
- name: Flake8 lint
51+
run: flake8 agents/ --max-line-length=100 --ignore=E203,W503
52+
53+
- name: Python syntax / import check
54+
run: |
55+
cd agents
56+
python -c "import ast, sys, pathlib
57+
errors = []
58+
for f in pathlib.Path('.').rglob('*.py'):
59+
try:
60+
ast.parse(f.read_text())
61+
except SyntaxError as e:
62+
errors.append(f'{f}: {e}')
63+
if errors:
64+
print('\n'.join(errors)); sys.exit(1)
65+
print('All Python files parsed OK')"
66+
67+
build-and-push:
68+
name: Build & Push Agents Image
69+
runs-on: ubuntu-latest
70+
needs: lint
71+
permissions:
72+
contents: read
73+
packages: write
74+
75+
steps:
76+
- name: Checkout code
77+
uses: actions/checkout@v4
78+
79+
- name: Log in to GitHub Container Registry
80+
uses: docker/login-action@v3
81+
with:
82+
registry: ${{ env.REGISTRY }}
83+
username: ${{ github.actor }}
84+
password: ${{ secrets.GITHUB_TOKEN }}
85+
86+
- name: Extract Docker metadata
87+
id: meta
88+
uses: docker/metadata-action@v5
89+
with:
90+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
91+
tags: |
92+
type=sha,prefix=sha-
93+
type=raw,value=latest,enable={{is_default_branch}}
94+
95+
- name: Build and push Agents Docker image
96+
uses: docker/build-push-action@v5
97+
with:
98+
context: .
99+
file: Dockerfile.agents
100+
push: ${{ github.ref == 'refs/heads/main' }}
101+
tags: ${{ steps.meta.outputs.tags }}
102+
labels: ${{ steps.meta.outputs.labels }}
103+
cache-from: type=gha
104+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)