-
Notifications
You must be signed in to change notification settings - Fork 6
129 lines (107 loc) · 3.83 KB
/
ci.yml
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
126
127
128
129
name: Build, Test, Deploy
on:
push:
branches:
- "main"
tags:
- "v*"
pull_request:
workflow_dispatch:
permissions:
contents: read
packages: write ## Github container registry
# deployments: write ## Github Pages
concurrency: ci-${{ github.ref }}
jobs:
build-and-test:
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest] #, windows-latest ] # windows takes ~3x longer, not worth the cost for larger projects
runs-on: ${{ matrix.os }}
timeout-minutes: 5
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
- name: Set up Python ⚙️
uses: actions/setup-python@v5
with:
python-version: "3.11" # keep in sync with pipfile
- name: Install dependencies ⚙️
run: |
pip install pipenv
pipenv install --dev -q
- name: Lint with flake8 🔍
run: |
# stop the build if there are Python syntax errors or undefined names
pipenv run flake8 tests/ app/ --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings
pipenv run flake8 tests/ app/ --count --exit-zero --max-complexity=10 --max-line-length=120 --statistics
- name: Test with mypy 🔍
run: |
# stop the build if there are typing errors
pipenv run python -m mypy app/ tests/
- name: Test with pytest 🔍
run: |
# stop the build if there are failed tests
pipenv run python -m pytest --durations=10
build-and-push-docker:
needs: build-and-test
if: github.ref == 'refs/heads/{{ github.event.repository.default_branch }}' || startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
with:
exclude: "docs/*"
# https://github.com/docker/metadata-action
- name: Export Metadata for Docker 🖊️
id: meta
uses: docker/metadata-action@v5
with:
images: |
modischfabrications/cutsolver
ghcr.io/${{ github.repository_owner }}/cutsolver
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU ⚙
uses: docker/setup-qemu-action@v3
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx ⚙
id: buildx
uses: docker/setup-buildx-action@v3
- name: Report Buildx platforms 🖊️
run: echo ${{ steps.buildx.outputs.platforms }}
- name: Login to DH 👤
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GHCR 👤
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
# https://github.com/docker/build-push-action
- name: Build and push to DH & GHCR 📦
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=user/app:latest
cache-to: type=inline
- name: Update DH description 🖊️
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: modischfabrications/cutsolver
readme-filepath: ./README.md
short-description: ${{ github.event.repository.description }}