-
Notifications
You must be signed in to change notification settings - Fork 0
179 lines (168 loc) · 5.65 KB
/
build.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
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
# SPDX-FileCopyrightText: © 2022 Tim Weber
# SPDX-FileCopyrightText: © 2023 Tobias Mühlberger
#
# SPDX-License-Identifier: AGPL-3.0-or-later
name: Build
on:
- push
jobs:
backend:
defaults:
run:
working-directory: server
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.13"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y graphviz graphviz-dev python3-dev
python -m pip install uv
uv sync --all-extras
- name: Lint with Ruff
run: uv run ruff check --output-format github
- name: Typecheck with mypy
run: uv run mypy
- name: Test with pytest
run: uv run pytest
- name: Export OpenAPI spec & ERD
if: ${{ matrix.python-version == '3.13' }} # We only need it once.
run: |
uv run dearmep dump openapi > openapi.json
uv run dearmep dump erd dearmep-erd.svg
# Copy the OpenAPI spec to be deployed to GitHub pages.
mkdir ../.github-pages
cp openapi.json ../.github-pages
- name: Collect OpenAPI spec & ERD as an artifact
if: ${{ matrix.python-version == '3.13' }}
uses: actions/upload-artifact@v3
with:
name: specs
retention-days: 8
path: |
server/dearmep-erd.svg
server/openapi.json
- name: Collect test results
if: ${{ always() }} # Meaning: also if the job fails.
uses: actions/upload-artifact@v3
with:
name: test-results-${{ matrix.python-version }}
retention-days: 15
path: |
server/coverage.xml
server/report.xml
- name: Prepare OpenAPI spec for GitHub Pages
if: ${{ matrix.python-version == '3.13' }}
uses: actions/upload-pages-artifact@v3
with:
path: .github-pages
frontend:
needs: backend # Because of the OpenAPI spec.
defaults:
run:
working-directory: client
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ["18.x", "20.x"]
steps:
- uses: actions/checkout@v3
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Retrieve OpenAPI spec
uses: actions/download-artifact@v3
with:
name: specs
- name: Install dependencies
run: npm ci
- name: Build API client
run: npm run generate-client
- name: Lint
run: npm run lint
- name: Build
run: npm run build
- name: Collect completed frontend build as an artifact
if: ${{ matrix.node-version == '20.x' }}
uses: actions/upload-artifact@v3
with:
name: frontend
retention-days: 8
path: |
client/dist/dear-mep-bundle/
build:
needs: frontend # For JS, CSS & assets.
defaults:
run:
working-directory: server
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.13
uses: actions/setup-python@v4
with:
python-version: 3.13
- name: Set package version
run: |
if [ "$GITHUB_REF_TYPE" = 'tag' ]; then
printf '%s' "$GITHUB_REF_NAME" > .build-version
else
sed -n -e "0,/^version = \"\\(.*\\)-dev\.9999999999\"$/s//\\1-dev.$(date +%s)+gh$(git rev-parse --short HEAD)/p" pyproject.toml > .build-version
fi
cat .build-version; echo
sed -i -e "0,/^version = \".*\$/s//version = \"$(cat .build-version)\"/" pyproject.toml
- name: Install dependencies
run: |
python -m pip install uv
uv sync
uv run dearmep version
- name: Retrieve frontend
uses: actions/download-artifact@v3
with:
name: frontend
path: server/dearmep/static_files/static
- name: Build Python package
run: |
uv build
- name: Collect Python package as an artifact
uses: actions/upload-artifact@v3
with:
name: python-package
path: |
server/dist/*.whl
server/dist/*.tar.gz
- name: Upload Python package to Nextcloud
env:
NEXTCLOUD_HOST: ${{ secrets.NEXTCLOUD_HOST }}
NEXTCLOUD_SHARE_ID: ${{ secrets.NEXTCLOUD_SHARE_ID }}
NEXTCLOUD_BASE: https://${{ secrets.NEXTCLOUD_HOST }}/public.php/webdav/
run: |
(umask 0077; printf "machine $NEXTCLOUD_HOST login $NEXTCLOUD_SHARE_ID\\n" >> ~/.netrc)
cd dist
find . -type f -exec curl --netrc --upload-file '{}' "$NEXTCLOUD_BASE" \;
deploy:
needs: build # Technically, it only needs "backend", but we want the build to succeed first.
# Only update the web-hosted version on the main branch.
if: github.ref_name == 'main'
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.pages_deployment.outputs.page_url }}
# Specify runner + deployment step
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: pages_deployment
uses: actions/deploy-pages@v4