-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (89 loc) · 2.71 KB
/
ci.yml
File metadata and controls
109 lines (89 loc) · 2.71 KB
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
name: CI - Tests & Quality Checks
run-name: CI triggered by ${{ github.actor }}
on:
push:
branches:
- main
- "releases/**"
# Down scope as necessary via https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
permissions:
checks: write
contents: write
packages: write
jobs:
run-linters:
name: Run linters
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.13"
cache: "pip" # caching pip dependencies
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install black flake8
- name: Run linters
uses: wearerequired/lint-action@v2
with:
black: true
flake8: true
run-test:
name: Run tests
runs-on: ubuntu-latest
needs:
- run-linters
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- name: Check out Git repository
uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run unit tests
run: |
python -m coverage run -m unittest
python -m coverage report -m
build-docker:
name: Build Docker Image
runs-on: ubuntu-latest
# Only run on push to main/develop (not on PRs) to save costs
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
env:
USERNAME: ${{ github.actor }}
PASSWORD: ${{ secrets.GITHUB_TOKEN }}
REPOS_NAME: ${{ github.event.repository.name }}
needs:
- run-test
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ env.USERNAME }}
password: ${{ env.PASSWORD }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
tags: ghcr.io/${{ env.USERNAME }}/${{ env.REPOS_NAME }}:latest
# Enable caching to speed up builds and reduce costs
cache-from: type=gha
cache-to: type=gha,mode=max