Skip to content

Commit

Permalink
add shell script to debug repeatable builds
Browse files Browse the repository at this point in the history
to aid reproduce #647
  • Loading branch information
anthrotype committed Jan 15, 2024
1 parent 8ef01ff commit 49f8e46
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 39 deletions.
58 changes: 19 additions & 39 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ name: Continuous integration
# https://github.com/googlefonts/fontations/blob/main/.github/workflows/rust.yml.
# other than the list of crates for cargo check no std

jobs:
jobs:
check:
name: Rustfmt
runs-on: ubuntu-latest
Expand Down Expand Up @@ -178,55 +178,35 @@ jobs:
- name: Build and install fontc (release mode)
run: cd fontc && pwd && cargo install --path .

- name: Fetch OTS
run: |
curl -OL "https://github.com/khaledhosny/ots/releases/download/v9.1.0/ots-9.1.0-Linux.zip"
unzip "ots-9.1.0-Linux.zip" "ots-9.1.0-Linux/ots-sanitize"
- name: Install ttx
run: |
pipx install fonttools
which ttx
ttx --version
- name: Check out font project source repository
uses: actions/checkout@v4
with:
repository: googlefonts/googlesans
path: googlesans
token: ${{ secrets.GS_READ_FONTC }}

- name: Pin SOURCE_DATE_EPOCH
run: echo "SOURCE_DATE_EPOCH=$(date +%s)" >> "$GITHUB_ENV"

- name: Compile me once, shame on you
run: |
rm -rf build
fontc source/GoogleSans/GoogleSans.designspace
cp build/font.ttf ./first-roman.ttf
rm -rf build
fontc source/GoogleSans/GoogleSans-Italic.designspace
cp build/font.ttf ./first-italic.ttf
- name: Compile Roman twice
run: ./resources/scripts/repeatable-builds.sh googlesans/source/GoogleSans/GoogleSans.designspace

- name: Fetch OTS
run: |
curl -OL "https://github.com/khaledhosny/ots/releases/download/v9.1.0/ots-9.1.0-Linux.zip"
unzip "ots-9.1.0-Linux.zip" "ots-9.1.0-Linux/ots-sanitize"
- name: Compile Italic twice
run: ./resources/scripts/repeatable-builds.sh googlesans/source/GoogleSans/GoogleSans-Italic.designspace

- name: OTS tests, Roman
run: ots-9.1.0-Linux/ots-sanitize build/font.ttf
run: ots-9.1.0-Linux/ots-sanitize build/GoogleSans.ttf

- name: OTS tests, Italic
run: ots-9.1.0-Linux/ots-sanitize build/font.ttf

- name: Compile me twice, shame on me
run: |
rm -rf build
fontc source/GoogleSans/GoogleSans.designspace
cp build/font.ttf ./second-roman.ttf
rm -rf build
fontc source/GoogleSans/GoogleSans-Italic.designspace
cp build/font.ttf ./second-italic.ttf
- name: ttx, it might be handy to troubleshoot
# tail -n +2 to skip past the first line because it emits the filename
run: |
pipx install fonttools
which ttx
ttx --version
diff -u <(ttx -l first-roman.ttf | tail -n +2) <(ttx -l second-roman.ttf | tail -n +2)
diff -u <(ttx -l first-italic.ttf | tail -n +2) <(ttx -l second-italic.ttf | tail -n +2)
- name: Stable Roman?
run: cmp first-roman.ttf second-roman.ttf

- name: Stable Italic?
run: cmp first-italic.ttf second-italic.ttf
run: ots-9.1.0-Linux/ots-sanitize build/GoogleSans-Italic.ttf
44 changes: 44 additions & 0 deletions resources/scripts/repeatable-builds.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

# This script is used to test that fontc produces repeatable builds.

if [ -z "$1" ]; then
echo "Error: Please provide path to a font source to compile"
exit 1
fi

INPUT_SOURCE="$1"
filename=$(basename "$INPUT_SOURCE")
first="build/${filename%.*}.ttf"
second="build/${filename%.*}#1.ttf"

ttcmp() {
if [ "$#" -lt 2 ]
then
echo "Usage: ttcmp FONT1.ttf FONT2.ttf"
return 1
fi
cmp $1 $2
if [ $? -ne 0 ]; then
# tail -n +2 to skip past the first line because it emits the filename
diff -u <(ttx -l $1 | tail -n +2) <(ttx -l $2 | tail -n +2)
fi
}

echo "$ which fontc"
which fontc

echo "$ fontc $INPUT_SOURCE -o $first"
fontc "$INPUT_SOURCE" -o $first

echo "$ fontc $INPUT_SOURCE -o $second"
fontc "$INPUT_SOURCE" -o $second

echo "$ ttcmp $first $second"
ttcmp $first $second
if [ $? -eq 0 ]; then
echo "Success: $first and $second are identical"
else
echo "Error: $first and $second are different"
exit 1
fi

0 comments on commit 49f8e46

Please sign in to comment.