|
1 | | -name: CI |
| 1 | +name: CI Pipeline |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | | - branches: [ main ] |
| 5 | + branches: [ "*" ] |
6 | 6 | pull_request: |
7 | | - branches: [ main ] |
| 7 | + branches: [ "*" ] |
8 | 8 |
|
9 | 9 | jobs: |
10 | | - build_and_test: |
| 10 | + |
| 11 | + # ======================================================= |
| 12 | + # 1. Python Lint + Test Job |
| 13 | + # ======================================================= |
| 14 | + tests: |
11 | 15 | runs-on: ubuntu-latest |
| 16 | + timeout-minutes: 10 |
12 | 17 |
|
13 | 18 | 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