2022-02-04 13:49:56 +00:00
|
|
|
# This is a basic workflow to help you get started with Actions
|
|
|
|
|
|
|
|
name: Test Square SVGs
|
|
|
|
|
|
|
|
# Triggers the workflow on push / pull request events but only for the svg folder
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
paths: svg/
|
|
|
|
pull_request:
|
|
|
|
paths: svg/
|
|
|
|
|
|
|
|
# Allows you to run this workflow manually from the Actions tab
|
|
|
|
workflow_dispatch:
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
|
|
|
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: Install Inkscape
|
2022-02-04 13:51:03 +00:00
|
|
|
run: sudo apt install inkscape
|
2022-02-04 13:49:56 +00:00
|
|
|
|
2022-02-04 14:09:27 +00:00
|
|
|
- name: Check SVG validity
|
2022-02-04 13:49:56 +00:00
|
|
|
run: |
|
|
|
|
# Enables globstar to recursively go through folders
|
|
|
|
shopt -s globstar
|
|
|
|
errArr=()
|
|
|
|
for f in ./**/*.svg
|
|
|
|
do
|
2022-02-04 14:09:27 +00:00
|
|
|
echo "Checking '$f'"
|
2022-02-04 13:49:56 +00:00
|
|
|
# Gets everything in between the viewBox quotes
|
|
|
|
vbStr=$(cat $f)
|
|
|
|
vbStr=${vbStr##*viewBox=\"}
|
|
|
|
vbStr=${vbStr%%\"*}
|
|
|
|
|
|
|
|
# sets x, y, width, height params
|
|
|
|
vbArr=($vbStr)
|
|
|
|
x=${vbArr[0]}
|
2022-02-04 13:54:49 +00:00
|
|
|
y=${vbArr[1]}
|
|
|
|
w=${vbArr[2]}
|
|
|
|
h=${vbArr[3]}
|
2022-02-04 13:49:56 +00:00
|
|
|
|
|
|
|
# Check that x and y are 0
|
|
|
|
if [[ $x != 0 || $y != 0 ]] ; then
|
|
|
|
errArr+=("$f has x: $x and y: $y")
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check that width and height are equal
|
|
|
|
if [[ $w != $h ]] ; then
|
|
|
|
errArr+=("$f has width: $w and height: $h")
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check that svg is not 1 line
|
|
|
|
if [[ $(wc -l < $f) == 0 ]] ; then
|
|
|
|
errArr+=("$f is only one line!")
|
|
|
|
fi
|
|
|
|
done
|
2022-02-04 14:09:27 +00:00
|
|
|
|
|
|
|
# Results
|
2022-02-04 13:56:52 +00:00
|
|
|
if [[ ${#errArr[@]} != 0 ]] ; then
|
2022-02-04 13:49:56 +00:00
|
|
|
for errMess in "${errArr[@]}"
|
|
|
|
do
|
|
|
|
echo $errMess
|
|
|
|
done
|
|
|
|
exit 1
|
|
|
|
fi
|
2022-02-04 13:59:43 +00:00
|
|
|
echo "No Errors!"
|