-
-
Notifications
You must be signed in to change notification settings - Fork 3
196 lines (164 loc) · 6.03 KB
/
backend.yml
File metadata and controls
196 lines (164 loc) · 6.03 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
name: Backend CI
on:
workflow_call:
inputs:
base-tag:
required: true
type: string
image-name-prefix:
required: true
type: string
image-name-suffix:
required: true
type: string
python-version:
required: true
type: string
plone-version:
required: true
type: string
defaults:
run:
working-directory: backend
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ inputs.python-version }}
enable-cache: true
- name: Check formatting
if: ${{ success() || failure() }}
id: ruff-format
run: uvx ruff@latest format --diff
- name: Check lint
if: ${{ success() || failure() }}
id: ruff-lint
run: uvx ruff@latest check --diff
- name: Check XML / ZCML
if: ${{ success() || failure() }}
id: zpretty
run: uvx zpretty@latest --check src
- name: Check Package Metadata
if: ${{ success() || failure() }}
id: pyroma
run: uvx pyroma@latest -d .
- name: Check Python Versions
if: ${{ success() || failure() }}
id: py-versions
run: uvx check-python-versions@latest .
- name: Report
if: ${{ success() || failure() }}
run: |
echo '# Code Analysis' >> $GITHUB_STEP_SUMMARY
echo '| Test | Status |' >> $GITHUB_STEP_SUMMARY
echo '| --- | --- |' >> $GITHUB_STEP_SUMMARY
echo '| Format | ${{ steps.ruff-format.conclusion == 'failure' && '❌' || ' ✅' }} |' >> $GITHUB_STEP_SUMMARY
echo '| Lint | ${{ steps.ruff-lint.conclusion == 'failure' && '❌' || ' ✅' }} |' >> $GITHUB_STEP_SUMMARY
echo '| XML / ZCML | ${{ steps.zpretty.conclusion == 'failure' && '❌' || ' ✅' }} |' >> $GITHUB_STEP_SUMMARY
echo '| Package Metadata | ${{ steps.pyroma.conclusion == 'failure' && '❌' || ' ✅' }} |' >> $GITHUB_STEP_SUMMARY
echo '| Python Versions | ${{ steps.py-versions.conclusion == 'failure' && '❌' || ' ✅' }} |' >> $GITHUB_STEP_SUMMARY
test:
runs-on: ubuntu-latest
env:
PYTHON_VERSION: ${{ inputs.python-version }}
PLONE_VERSION: ${{ inputs.plone-version }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ inputs.python-version }}
enable-cache: false
- name: Restore uv cache
uses: actions/cache@v4
with:
path: ${{ env.UV_CACHE_DIR }}
key: uv-${{ runner.os }}-${{ inputs.python-version }}-${{ inputs.plone-version }}-${{ hashFiles('pyproject.toml') }}
restore-keys: |
uv-${{ runner.os }}-${{ inputs.python-version }}-${{ inputs.plone-version }}-${{ hashFiles('pyproject.toml') }}
uv-${{ runner.os }}-${{ inputs.python-version }}-${{ inputs.plone-version }}
- name: Install Plone and package
run: make install
- name: Run tests
run: make test
coverage:
runs-on: ubuntu-latest
needs:
- test
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ inputs.python-version }}
enable-cache: false
- name: Restore uv cache
uses: actions/cache@v4
with:
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ inputs.python-version }}-${{ inputs.plone-version }}-${{ hashFiles('pyproject.toml') }}
restore-keys: |
uv-${{ runner.os }}-${{ inputs.python-version }}-${{ inputs.plone-version }}-${{ hashFiles('pyproject.toml') }}
uv-${{ runner.os }}-${{ inputs.python-version }}-${{ inputs.plone-version }}
- name: Install Plone and package
run: make install
- name: Run tests
run: make test-coverage
- name: Report Coverage
run: |
echo "# Coverage Report" >> $GITHUB_STEP_SUMMARY
echo "$(uv run coverage report --format markdown)" >> $GITHUB_STEP_SUMMARY
release:
runs-on: ubuntu-latest
needs:
- lint
- coverage
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ inputs.image-name-prefix }}-${{ inputs.image-name-suffix }}
labels: |
org.label-schema.docker.cmd=docker run -d -p 8080:8080 ${{ inputs.image-name-prefix }}-${{ inputs.image-name-suffix }}:${{ inputs.base-tag }}
flavor:
latest=false
tags: |
type=ref,event=branch
type=sha
type=raw,value=latest,enable={{is_default_branch}}
type=pep440,pattern={{version}},enable=${{ startsWith(github.ref, 'refs/tags/')}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
platforms: linux/amd64
context: backend/
file: backend/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
PLONE_VERSION=${{ inputs.plone-version }}