run.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # Only run gftools qa on prs which have modified files in directories which
  2. # contain font binaries.
  3. # Find directories which contain files that have been altered or added. Also
  4. # Skip /static directories.
  5. CHANGED_DIRS=$(git diff origin/main --dirstat=files --diff-filter d | sed "s/[0-9. ].*%//g" | grep -v "static")
  6. OUT=out
  7. PR_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/pull/$PR_NUMBER"
  8. echo "PR url: $PR_URL"
  9. for dir in $CHANGED_DIRS
  10. do
  11. font_count=$(ls -1 $dir*.ttf 2>/dev/null | wc -l)
  12. is_designer_dir=$(echo $dir | grep "designers")
  13. if [ $font_count != 0 ]
  14. then
  15. echo "Checking $dir"
  16. mkdir -p $OUT
  17. # If pr contains modified fonts, check with Fontbakery, Diffenator and DiffBrowsers.
  18. # If pr doesn't contain modified fonts, just check with Fontbakery.
  19. modified_fonts=$(git diff --name-only origin/main HEAD $dir*.ttf)
  20. if [ -n "$modified_fonts" ]
  21. then
  22. echo "Fonts have been modified. Checking fonts with all tools"
  23. gftools qa -f $dir*.ttf -gfb -a -o $OUT/$(basename $dir)_qa --out-url $PR_URL
  24. else
  25. echo "Fonts have not been modified. Checking fonts with Fontbakery only"
  26. gftools qa -f $dir*.ttf --fontbakery -o $OUT/$(basename $dir)_qa --out-url $PR_URL
  27. fi
  28. elif [ ! -z $is_designer_dir ]
  29. then
  30. echo "Checking designer profile"
  31. pytest .ci/test_profiles.py $dir
  32. else
  33. echo "Skipping $dir. Directory does not contain fonts"
  34. fi
  35. done