Main workflow #1007
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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: | |
workflow_dispatch: | |
inputs: | |
release: | |
description: Run a release build | |
type: boolean | |
next-version: | |
description: Next version number (optional) | |
type: string | |
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 | |
charset: testing | |
harfbuzz-version: 9.0.0 | |
- build-venv: dev | |
requirements: oldest | |
charset: testing | |
harfbuzz-version: 8.1.0 | |
- build-venv: dev | |
requirements: newest | |
charset: testing | |
harfbuzz-version: 9.0.0 | |
- build-venv: dev | |
optimize: -O | |
charset: standard | |
harfbuzz-version: 9.0.0 | |
- build-venv: dev | |
optimize: -O | |
charset: noto | |
harfbuzz-version: 9.0.0 | |
- build-venv: dev | |
optimize: -O | |
charset: testing | |
unjoined: unjoined | |
harfbuzz-version: 9.0.0 | |
- build-venv: dev | |
optimize: -O | |
charset: standard | |
unjoined: unjoined | |
harfbuzz-version: 9.0.0 | |
- build-venv: dev | |
optimize: -O | |
charset: noto | |
unjoined: unjoined | |
harfbuzz-version: 9.0.0 | |
- build-venv: build | |
charset: testing | |
harfbuzz-version: 9.0.0 | |
- build-venv: build | |
charset: standard | |
harfbuzz-version: 9.0.0 | |
- build-venv: build | |
charset: noto | |
harfbuzz-version: 9.0.0 | |
- build-venv: build | |
charset: testing | |
unjoined: unjoined | |
harfbuzz-version: 9.0.0 | |
- build-venv: build | |
charset: standard | |
unjoined: unjoined | |
harfbuzz-version: 9.0.0 | |
- build-venv: build | |
charset: noto | |
unjoined: unjoined | |
harfbuzz-version: 9.0.0 | |
- build-venv: dev | |
charset: testing | |
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 'CHARSET=${{ matrix.charset }}' 'COVERAGE=${{ matrix.coverage }}' ${{ matrix.charset == 'noto' && 'NOTO=1' || '' }} 'PYTHONOPTIMIZE=${{ matrix.optimize }}' ${{ inputs.release && 'RELEASE=1' || '' }} 'UNJOINED=${{ matrix.unjoined }}' | |
- name: Test | |
if: matrix.coverage == '' | |
run: | | |
. dev-venv/bin/activate | |
make -j 'CHARSET=${{ matrix.charset }}' ${{ matrix.charset == 'noto' && 'NOTO=1' || '' }} 'UNJOINED=${{ matrix.unjoined }}' ${{ matrix.optimize == '' && 'check-fonts' || '' }} check-sources | |
- name: Check coverage | |
if: matrix.coverage != '' | |
run: | | |
. dev-venv/bin/activate | |
make -j 'CHARSET=${{ matrix.charset }}' COVERAGE=1 ${{ matrix.noto == 'noto' && 'NOTO=1' || '' }} 'UNJOINED=${{ matrix.unjoined }}' check-coverage | |
- name: Upload build artifacts | |
if: matrix.build-venv == 'build' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: fonts-${{ matrix.charset }}${{ matrix.unjoined && '-unjoined' || '' }} | |
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.charset }}-${{ matrix.unjoined }} | |
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-testing- | |
path: fonts | |
- uses: actions/cache/restore@v4 | |
with: | |
key: ${{ github.run_id }}-${{ github.run_number }}--O-standard- | |
path: fonts | |
- uses: actions/cache/restore@v4 | |
with: | |
key: ${{ github.run_id }}-${{ github.run_number }}--O-noto- | |
path: fonts | |
- uses: actions/cache/restore@v4 | |
with: | |
key: ${{ github.run_id }}-${{ github.run_number }}--O-testing-unjoined | |
path: fonts | |
- uses: actions/cache/restore@v4 | |
with: | |
key: ${{ github.run_id }}-${{ github.run_number }}--O-standard-unjoined | |
path: fonts | |
- uses: actions/cache/restore@v4 | |
with: | |
key: ${{ github.run_id }}-${{ github.run_number }}--O-noto-unjoined | |
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 }}--testing- | |
path: fonts | |
- uses: actions/cache/restore@v4 | |
with: | |
key: ${{ github.run_id }}-${{ github.run_number }}--standard- | |
path: fonts | |
- uses: actions/cache/restore@v4 | |
with: | |
key: ${{ github.run_id }}-${{ github.run_number }}--noto- | |
path: fonts | |
- uses: actions/cache/restore@v4 | |
with: | |
key: ${{ github.run_id }}-${{ github.run_number }}--testing-unjoined | |
path: fonts | |
- uses: actions/cache/restore@v4 | |
with: | |
key: ${{ github.run_id }}-${{ github.run_number }}--standard-unjoined | |
path: fonts | |
- uses: actions/cache/restore@v4 | |
with: | |
key: ${{ github.run_id }}-${{ github.run_number }}--noto-unjoined | |
path: fonts | |
- name: Compare the fonts built with `PYTHONOPTIMIZE` | |
run: diff -qrs fonts fonts-PYTHONOPTIMIZE | |
release: | |
permissions: | |
contents: write | |
runs-on: ubuntu-22.04 | |
if: ${{ inputs.release }} | |
needs: | |
- compare-PYTHONOPTIMIZE | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Tag the release commit and bump the version number | |
run: | | |
git config --local user.email '41898282+github-actions[bot]@users.noreply.github.com' | |
git config --local user.name 'github-actions[bot]' | |
make ${{ inputs.next-version != '' && format('''NEXT_VERSION={0}''', inputs.next-version) || '' }} release | |
git push --follow-tags |