Skip to content

Force ruby 2 until fontcustom gets updated #77

Force ruby 2 until fontcustom gets updated

Force ruby 2 until fontcustom gets updated #77

Workflow file for this run

name: Build Academicons Fonts
on:
push:
branches:
- sources
pull_request:
branches:
- sources
workflow_dispatch:
inputs:
force:
description: 'Force deploying to master even if checks fail (yes/no)'
required: true
default: 'no'
jobs:
build:
name: Build
runs-on: ubuntu-latest
outputs:
describe_commit: ${{ steps.describe.outputs.commit }}
steps:
- name: Get sources
uses: actions/checkout@v1
- name: Describe commit
id: describe
run: |
echo "::set-output name=commit::`git log -n1 --pretty=format:'commit %h by %aN <%aE>%n%n%ad | %B'`"
- uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'
bundler-cache: true
- name: Check ruby
run: gem --version
- name: Install dependencies
run: |
sudo apt-get install zlib1g-dev fontforge lcdf-typetools jq yui-compressor
for repo in bramstein/sfnt2woff-zopfli google/woff2 wget/sfnt2woff; do
dir=${TMPDIR:-/tmp}/${repo#*/}
git clone --recursive https://github.com/$repo $dir
pushd $dir
make
sudo make install || find * -maxdepth 0 -type f -executable -exec sudo cp -v {} /usr/local/bin/ \;
popd
done
sudo gem install fontcustom
- name: Keep only specified input files
run: |
jq -r 'keys[] | "svg/\(.).svg"' config/codepoints.json > files
rm -f `find svg/ -type f | grep -vFxf files`
ls `cat files` > /dev/null
- name: Build fonts
run: |
# Pre-populate manifest with fixed codepoints, by populating the glyphs from config/manifest-template.json
# with the contents of config/codepoints.json
jq '.glyphs = ($points[0] | with_entries({key: .key, value: {codepoint: .value}}))' \
--slurpfile points config/codepoints.json config/manifest-template.json > .fontcustom-manifest.json
fontcustom compile
- name: Add minified css
run: |
yui-compressor -o academicons/css/academicons.min.css academicons/css/academicons.css
- name: Check defined glyphs
run: |
# We expect a glyph matching the basename without extension of every svg file
find svg/ -type f -exec basename {} .svg \; > expected_glyphs
# Some other expected glyphs, always generated by fontforge
echo ".notdef .null nonmarkingreturn space" | tr ' ' '\n' >> expected_glyphs
otfinfo -g academicons/fonts/academicons.ttf | sort | diff - <(sort expected_glyphs)
- name: Check defined unicode codepoints
run: |
# Negatively matching allowed codepoints, so we should have no matches and a non-zero return value negated with !
! otfinfo -u fonts/academicons.ttf | grep -ve '^uniFFFF ' -e '^uniE9[0-9A-F][0-9A-F] '
- name: Archive production artifacts
uses: actions/upload-artifact@v2
with:
name: academicons
path: |
academicons
diff_and_deploy:
name: Diff and deploy
needs: build
runs-on: ubuntu-latest
steps:
- name: Get sources
uses: actions/checkout@v1
with:
ref: master
fetch-depth: 0
- name: Install dependencies, other setup
run: |
sudo apt-get install python3-selenium imagemagick
mv test/glyph-table.png test/glyph-table.current.png
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Download the built sources
uses: actions/download-artifact@v2
with:
name: academicons
path: .
- name: Diff glyph table
id: image-diff
run: |
# Update images, compute diff
./test/capture.py -d firefox test/glyph-table.png
rm -f *driver.log
npxdiff=`compare -metric AE -fuzz 25% test/glyph-table.current.png test/glyph-table.png test/glyph-table.diff.png 2>&1 || :`
echo "::set-output name=PXDIFF::$npxdiff"
- name: Push table diff to gist
id: image-upload
run: |
git clone --depth=1 $GIST_URL image-gist
# Add images to gist
cp test/glyph-table.diff.png test/glyph-table.png image-gist/
git -C image-gist add glyph-table.diff.png glyph-table.png
git -C image-gist commit -m "Images generated from ${{ needs.build.outputs.describe_commit }}"
git -C image-gist push https://${TOKEN}@${GIST_URL#https://}
image_url=${GIST_URL/github./githubusercontent.}/raw/$(git -C image-gist rev-parse HEAD)/glyph-table.diff.png
echo "Diff image available at: $image_url"
echo "::set-output name=URL::$image_url"
rm -rf image-gist
env:
GIST_URL: https://gist.github.com/lucjaulmes/1df00b3e5e24e32f4eb56de5dbc934f3
TOKEN: ${{ secrets.GIST_PUSHER }}
- name: Post diff on PR
if: ${{ github.base_ref != '' }} # Only do this on pull requests
run: |
set +o histexpand # get rid of annoying ! bash behaviour
image_url=${{ steps.image-upload.outputs.URL }}
pr_number=$(jq -r .pull_request.number "$GITHUB_EVENT_PATH")
curl -X POST -H "Authorization: token ${TOKEN}" -H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/$GITHUB_REPOSITORY/issues/$pr_number/comments \
-d "{\"body\":\"Automatically generated preview of changes (in red):\n![glyph table]($image_url)\n(See [full glyph table](${image_url/.diff./.}).)\"}"
env:
TOKEN: ${{ secrets.GIST_PUSHER }}
- name: Difference check
run: |
npxdiff=${{ steps.image-diff.outputs.PXDIFF }}
force=${{ steps.events.inputs.force }}
# Each table cell is 45x45 px so there should (?) be no alignment problems,
# and 2025px would be the max number of pixels changed per icon.
# ~1k for a new icon, ~110k for removing all glyphs.
echo "Pushing if $npxdiff < 5000 or $force != no"
if [ ${npxdiff:-0} -gt 5000 ] ; then
level=`[ "${force:-no}" != "no" ] && echo warning || echo error`
echo "::$level ::Number of different pixels exceeds limit: $npxdiff"
[ "${force:-no}" != "no" ] || exit 1
fi
- name: Deploy to public branch
if: ${{ github.ref == 'refs/heads/sources' || steps.events.inputs.force != 'no' }}
run: |
# Add modified files and new files in selected subdirectories
git add -u
git add fonts/ css/ docs/
git commit -m "Fonts generated from ${{ needs.build.outputs.describe_commit }}"
git push https://${TOKEN}@github.com/${GITHUB_REPOSITORY} HEAD:master
env:
TOKEN: ${{ secrets.GIST_PUSHER }}