Skip to content

Commit 879557e

Browse files
feat: Add GitHub Actions workflow for building, linting, and testing the GenAI service
1 parent f7c2517 commit 879557e

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Build, Lint & Test the GenAI Service
2+
3+
on:
4+
push:
5+
paths:
6+
- 'genai/**'
7+
pull_request:
8+
paths:
9+
- 'genai/**'
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
build-lint-test-genai:
17+
name: Build, Lint & Test GenAI Service
18+
runs-on: ubuntu-latest
19+
20+
defaults:
21+
run:
22+
working-directory: .
23+
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
28+
- name: Set up Python
29+
uses: actions/setup-python@v5
30+
with:
31+
python-version: '3.12'
32+
33+
- name: Cache pip
34+
uses: actions/cache@v4
35+
with:
36+
path: ~/.cache/pip
37+
key: ${{ runner.os }}-pip-${{ hashFiles('genai/requirements.txt') }}
38+
restore-keys: |
39+
${{ runner.os }}-pip-
40+
41+
- name: Install dependencies
42+
run: |
43+
python -m pip install --upgrade pip
44+
pip install -r genai/requirements.txt
45+
46+
- name: Lint code with flake8
47+
run: |
48+
pip install flake8
49+
flake8 genai/src --count --select=E9,F63,F7,F82 --show-source --statistics
50+
continue-on-error: true
51+
52+
- name: Run tests if test files exist
53+
run: |
54+
if ls genai/tests/*.py 1> /dev/null 2>&1; then
55+
echo "Found test files. Running tests..."
56+
pip install pytest
57+
pytest genai/tests
58+
else
59+
echo "No test files found. Skipping tests."
60+
fi
61+
62+
- name: Verify main entrypoint exists
63+
run: |
64+
if [ -f "genai/src/main.py" ]; then
65+
echo "main.py exists."
66+
else
67+
echo "genai/src/main.py does not exist! Build failed."
68+
exit 1
69+
fi

0 commit comments

Comments
 (0)