-
Notifications
You must be signed in to change notification settings - Fork 2
246 lines (245 loc) · 9.45 KB
/
main.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
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# Copyright 2019, 2022-2024 David Corbett
# Copyright 2020-2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Main workflow
on: push
permissions:
contents: read
env:
FONTFORGE_COMMIT: aa062f4cbd1db21e27b2620f16993ebe4c540ab6
PYTHON_VERSION: 3.11
jobs:
main:
runs-on: ubuntu-22.04
strategy:
matrix:
include:
- build-venv: dev
optimize: -O
harfbuzz-version: 9.0.0
- build-venv: dev
requirements: oldest
harfbuzz-version: 8.1.0
- build-venv: dev
requirements: newest
harfbuzz-version: 9.0.0
- build-venv: dev
optimize: -O
noto: Noto
harfbuzz-version: 9.0.0
- build-venv: build
harfbuzz-version: 9.0.0
- build-venv: build
noto: Noto
harfbuzz-version: 9.0.0
- build-venv: dev
coverage: coverage
harfbuzz-version: 9.0.0
steps:
- uses: actions/checkout@v4
- name: Select the setup-python cache
run: |
echo '${{ matrix.requirements }}' >>setup-python-cache-key.txt
echo '${{ matrix.build-venv }}' >>setup-python-cache-key.txt
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: pip
cache-dependency-path: |
dev-requirements.in
dev-requirements.txt
requirements.in
requirements.txt
setup-python-cache-key.txt
- name: Cache FontForge
id: cache-fontforge
uses: actions/cache@v4
with:
key: ${{ runner.os }}-fontforge-${{ env.FONTFORGE_COMMIT }}-python-${{ env.PYTHON_VERSION }}
path: fontforge
- name: Install FontForge
if: steps.cache-fontforge.outputs.cache-hit != 'true'
run: |
sudo apt-get update
sudo apt-get -qy --no-install-recommends install \
build-essential \
cmake \
ninja-build \
packaging-dev \
pkg-config \
python${{ env.PYTHON_VERSION }}-dev \
;
curl -Lo fontforge.zip https://github.com/fontforge/fontforge/archive/${{ env.FONTFORGE_COMMIT }}.zip
unzip fontforge.zip
mv fontforge-${{ env.FONTFORGE_COMMIT }} fontforge
cd fontforge
curl -O https://patch-diff.githubusercontent.com/raw/fontforge/fontforge/pull/4232.patch
patch -p1 <4232.patch
mkdir build
cd build
cmake -G Ninja \
-D CMAKE_INSTALL_PREFIX="$PWD/target" \
-D ENABLE_DOCS=OFF \
-D ENABLE_GUI=OFF \
-D ENABLE_LIBGIF=OFF \
-D ENABLE_LIBJPEG=OFF \
-D ENABLE_LIBPNG=OFF \
-D ENABLE_LIBREADLINE=OFF \
-D ENABLE_LIBSPIRO=OFF \
-D ENABLE_LIBTIFF=OFF \
-D ENABLE_LIBUNINAMESLIST=OFF \
-D ENABLE_PYTHON_EXTENSION=ON \
-D ENABLE_NATIVE_SCRIPTING=OFF \
-D ENABLE_WOFF2=OFF \
.. \
;
ninja
sudo ninja install
- name: Add site-packages to default search path
run: echo "PYTHONPATH=$PWD/fontforge/build/target/lib/python${{ env.PYTHON_VERSION }}/site-packages:$PYTHONPATH" >>"$GITHUB_ENV"
- name: Cache HarfBuzz
if: matrix.coverage == ''
id: cache-harfbuzz
uses: actions/cache@v4
with:
key: ${{ runner.os }}-harfbuzz-${{ matrix.harfbuzz-version }}
path: .hb/harfbuzz-${{ matrix.harfbuzz-version }}
- name: Install HarfBuzz
if: steps.cache-harfbuzz.outputs.cache-hit != 'true' && matrix.coverage == ''
run: |
sudo apt-get update
sudo apt-get -qy --no-install-recommends install meson
make HB_VERSION=${{ matrix.harfbuzz-version }} hb-shape
- name: Add HarfBuzz to path
if: matrix.coverage == ''
run: echo "$PWD/.hb/harfbuzz-${{ matrix.harfbuzz-version }}/build/util" >>"$GITHUB_PATH"
- name: Install unifdef
run: |
sudo apt-get -qy --no-install-recommends install unifdef
- name: Prepare oldest requirements
if: matrix.requirements == 'oldest'
run: |
python -m venv oldest-venv
. oldest-venv/bin/activate
pip install uv=="$(grep -o '^uv *[=>~]= *[^ ,]*' dev-requirements.in | grep -o '[^ ]*$')"
uv pip compile --resolution lowest -o dev-requirements.txt dev-requirements.in
uv pip compile --resolution lowest -o requirements.txt requirements.in
- name: Prepare newest requirements
if: matrix.requirements == 'newest'
run: |
cp dev-requirements.in dev-requirements.txt
cp requirements.in requirements.txt
- name: Make a virtual environment
run: python -m venv dev-venv
- name: Install dev requirements
run: |
. dev-venv/bin/activate
pip install ${{ matrix.requirements != 'newest' && '--no-deps' || '' }} --upgrade --upgrade-strategy eager -r dev-requirements.txt
- name: Test updating the requirements files
if: matrix.coverage == ''
run: |
. dev-venv/bin/activate
mv dev-requirements.txt dev-requirements.txt.bak
mv requirements.txt requirements.txt.bak
make -j dev-requirements.txt requirements.txt
mv dev-requirements.txt.bak dev-requirements.txt
mv requirements.txt.bak requirements.txt
- name: Make a virtual environment for building
if: matrix.build-venv == 'build'
run: python -m venv ${{ matrix.build-venv }}-venv
- name: Install build requirements
if: matrix.build-venv == 'build'
run: |
. ${{ matrix.build-venv }}-venv/bin/activate
pip install ${{ matrix.requirements != 'newest' && '--no-deps' || '' }} --upgrade --upgrade-strategy eager -r requirements.txt
- name: Build
run: |
. ${{ matrix.build-venv }}-venv/bin/activate
make clean
make -B -j "COVERAGE=${{ matrix.coverage }}" "NOTO=${{ matrix.noto }}" "PYTHONOPTIMIZE=${{ matrix.optimize }}"
- name: Test
if: matrix.coverage == ''
run: |
. dev-venv/bin/activate
make -j "NOTO=${{ matrix.noto }}" ${{ matrix.optimize == '' && 'check-fonts' || '' }} check-sources
- name: Check coverage
if: matrix.coverage != ''
run: |
. dev-venv/bin/activate
make -j "COVERAGE=${{ matrix.coverage }}" "NOTO=${{ matrix.noto }}" check-coverage
- name: Determine whether to push the fonts or upload them
if: matrix.build-venv == 'build'
id: push-or-upload
run: |
is_noto=${{ matrix.noto != '' }}
job_will_push=${{ github.ref_name == github.event.repository.default_branch && contains(github.event.repository.name, 'Noto') }}
if [ $job_will_push = true ]
then
echo push=$is_noto >>"$GITHUB_OUTPUT"
else
if [ $is_noto = true ]
then
upload_name=fonts-noto
elif [ ${{ matrix.build-venv }} = build ]
then
upload_name=fonts
fi
echo upload-name=$upload_name >>"$GITHUB_OUTPUT"
fi
- name: Commit and push
if: steps.push-or-upload.outputs.push == 'true'
run: |
git config --local user.email '41898282+github-actions[bot]@users.noreply.github.com'
git config --local user.name 'github-actions[bot]'
git add -f fonts
git commit -m 'Automatically build the fonts'
git push
- name: Upload build artifacts
if: steps.push-or-upload.outputs.upload-name
uses: actions/upload-artifact@v4
with:
name: ${{ steps.push-or-upload.outputs.upload-name }}
path: fonts
- name: Cache the fonts for the next job
if: matrix.build-venv == 'build' || matrix.optimize != ''
uses: actions/cache/save@v4
with:
key: ${{ github.run_id }}-${{ github.run_number }}-${{ matrix.optimize }}-${{ matrix.noto }}
path: fonts
compare-PYTHONOPTIMIZE:
runs-on: ubuntu-22.04
needs:
- main
steps:
- uses: actions/checkout@v4
- uses: actions/cache/restore@v4
with:
key: ${{ github.run_id }}-${{ github.run_number }}--O-
path: fonts
- uses: actions/cache/restore@v4
with:
key: ${{ github.run_id }}-${{ github.run_number }}--O-Noto
path: fonts
- name: Move the fonts from the optimized builds
run: mv fonts fonts-PYTHONOPTIMIZE
- uses: actions/cache/restore@v4
with:
key: ${{ github.run_id }}-${{ github.run_number }}--
path: fonts
- uses: actions/cache/restore@v4
with:
key: ${{ github.run_id }}-${{ github.run_number }}--Noto
path: fonts
- name: Compare the fonts built with `PYTHONOPTIMIZE`
run: diff -qrs fonts fonts-PYTHONOPTIMIZE