Skip to content

Commit cb393e3

Browse files
authored
Update ci.yml
1 parent f5833c7 commit cb393e3

File tree

1 file changed

+81
-24
lines changed

1 file changed

+81
-24
lines changed

.github/workflows/ci.yml

Lines changed: 81 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,90 @@
1-
name: CI
1+
name: CI Pipeline
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [ "*" ]
66
pull_request:
7-
branches: [ main ]
7+
branches: [ "*" ]
88

99
jobs:
10-
build_and_test:
10+
11+
# =======================================================
12+
# 1. Python Lint + Test Job
13+
# =======================================================
14+
tests:
1115
runs-on: ubuntu-latest
16+
timeout-minutes: 10
1217

1318
steps:
14-
- uses: actions/checkout@v3
15-
16-
- name: Set up Python 3.9
17-
uses: actions/setup-python@v4
18-
with:
19-
python-version: '3.9'
20-
21-
- name: Install dependencies
22-
run: |
23-
python -m pip install --upgrade pip
24-
pip install -r requirements.txt
25-
pip install -r requirements-dev.txt
26-
27-
- name: Lint with flake8
28-
run: |
29-
flake8 src/
30-
31-
- name: Run tests
32-
run: |
33-
pytest --maxfail=1 --disable-warnings -q
19+
- name: Checkout repository
20+
uses: actions/checkout@v3
21+
22+
- name: Set up Python
23+
uses: actions/setup-python@v4
24+
with:
25+
python-version: '3.10'
26+
27+
- name: Cache pip packages
28+
uses: actions/cache@v3
29+
with:
30+
path: ~/.cache/pip
31+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
32+
restore-keys: |
33+
${{ runner.os }}-pip-
34+
35+
- name: Install dependencies
36+
run: |
37+
pip install --upgrade pip
38+
pip install -r requirements.txt
39+
pip install black flake8 pytest
40+
41+
- name: Lint with flake8
42+
run: |
43+
flake8 src || true
44+
45+
- name: Format check with black
46+
run: |
47+
black --check src
48+
49+
- name: Run unit tests
50+
run: |
51+
pytest -q
52+
53+
54+
# =======================================================
55+
# 2. Docker Build Job
56+
# =======================================================
57+
docker-build:
58+
runs-on: ubuntu-latest
59+
needs: tests
60+
timeout-minutes: 15
61+
62+
steps:
63+
- name: Checkout repository
64+
uses: actions/checkout@v3
65+
66+
- name: Set up Docker Buildx
67+
uses: docker/setup-buildx-action@v2
68+
69+
- name: Cache Docker layers
70+
uses: actions/cache@v3
71+
with:
72+
path: /tmp/.buildx-cache
73+
key: ${{ runner.os }}-buildx-${{ github.sha }}
74+
restore-keys: |
75+
${{ runner.os }}-buildx-
76+
77+
- name: Build Driver Location Service image
78+
run: |
79+
docker build \
80+
-f src/driver-location-service/Dockerfile \
81+
-t driver-location-service .
82+
83+
- name: Build Dispatch Service image
84+
run: |
85+
docker build \
86+
-f src/dispatch-service/Dockerfile \
87+
-t dispatch-service .
88+
89+
- name: List built Docker images
90+
run: docker images

0 commit comments

Comments
 (0)