-
-
Notifications
You must be signed in to change notification settings - Fork 8
125 lines (104 loc) · 2.98 KB
/
linter-and-builder.yaml
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
name: 'Linter and Builder 🚀'
on:
pull_request:
branches:
- 'main'
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
cancel-in-progress: true
jobs:
code-quality:
name: 'Code-Quality 💎'
strategy:
matrix:
os:
- ubuntu-latest
python-version:
- "3.11"
# No need to set to specific directory
# defaults:
# run:
# working-directory: backend/
runs-on: ${{ matrix.os }}
steps:
- name: Check repository
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install Dependencies for Linting
run: |
pip install ruff==0.4.9
- name: Lint with ruff
run: |
make ruff
unittest:
name: 'Unit Test 🧪'
needs: [code-quality]
strategy:
matrix:
os:
- ubuntu-latest
python-version:
- "3.11"
poetry-version:
- "1.8.2"
pytest-version:
- "8.1.1"
# No need to set to specific directory
# defaults:
# run:
# working-directory: backend/
runs-on: ${{ matrix.os }}
steps:
- name: Check repository
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install Dependencies for Unit Test
run: |
pip install -r backend/requirements.txt
- name: Install PyTest
run: |
pip install pytest==${{ matrix.pytest-version }}
- name: Run Unit Test
run: |
make env
make test
check-build-images:
name: 'Docker Build Checker🐳'
needs: [code-quality, unittest]
strategy:
matrix:
config:
- { dockerfile: "backend/Dockerfile", platforms: "linux/amd64,linux/arm64" }
# defaults:
# run:
# working-directory: backend/
runs-on: ubuntu-latest
steps:
- name: Check repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Get Commit Hash
id: commit
shell: bash
run: |
echo "SHORT_HASH=$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV
- name: Build Docker image
# if: startsWith(github.ref, 'refs/tags/') != true && success()
uses: docker/build-push-action@v6
with:
context: backend/
push: false
platforms: ${{ matrix.config.platforms }}
tags: "${{ secrets.DOCKER_REGISTRY_KIRIN }}/${{ secrets.IMAGE_NAME_KIRIN }}:${{ env.SHORT_HASH }}"
file: ${{ matrix.config.dockerfile }}