Skip to content

Commit 3a87fd1

Browse files
authored
Merge pull request #79 from jimustafa/update-checks
update checks
2 parents 9535515 + b67f73c commit 3a87fd1

File tree

6 files changed

+57
-6
lines changed

6 files changed

+57
-6
lines changed

.github/workflows/main.yaml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,9 @@ jobs:
5151
cp -r fonts/ /usr/share/fonts/
5252
fc-cache
5353
make all
54-
- name: Check layouts
54+
- name: Run checks
5555
run: |
56-
set -x
57-
[[ "$(pdfinfo cheatsheets.pdf | grep Pages | awk '{print $2}')" == "2" ]] || exit 1
58-
[[ "$(pdfinfo handout-tips.pdf | grep Pages | awk '{print $2}')" == "1" ]] || exit 1
59-
[[ "$(pdfinfo handout-beginner.pdf | grep Pages | awk '{print $2}')" == "1" ]] || exit 1
60-
[[ "$(pdfinfo handout-intermediate.pdf | grep Pages | awk '{print $2}')" == "1" ]] || exit 1
56+
make check
6157
- uses: actions/upload-artifact@v2
6258
if: ${{ always() }}
6359
with:

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ handouts:
3636
convert -density 150 handout-beginner.pdf handout-beginner.png
3737
convert -density 150 handout-intermediate.pdf handout-intermediate.png
3838

39+
.PHONY: check
40+
check:
41+
./check-num-pages.sh cheatsheets.pdf 2
42+
./check-num-pages.sh handout-tips.pdf 1
43+
./check-num-pages.sh handout-beginner.pdf 1
44+
./check-num-pages.sh handout-intermediate.pdf 1
45+
./check-links.py cheatsheets.pdf
46+
3947
.PHONY: fonts
4048
fonts:
4149
make -C fonts/

check-links.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env python
2+
import sys
3+
4+
import pdfx
5+
6+
7+
pdf = pdfx.PDFx(sys.argv[1])
8+
9+
refs = [ref for ref in pdf.get_references() if ref.reftype == 'url']
10+
11+
status_codes = list(map(lambda ref: pdfx.downloader.get_status_code(ref.ref), refs))
12+
13+
broken_links = [refs[idx].ref for idx in range(len(refs)) if status_codes[idx] != 200]
14+
15+
# it seems that Twitter does not respond well to the link checker and throws a 400
16+
if all(['twitter.com' in url for url in broken_links]):
17+
sys.exit(0)
18+
else:
19+
print('Broken links:', broken_links)
20+
sys.exit(1)

check-num-pages.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
#
3+
# Check that a given pdf has a certain number of pages.
4+
# Usage:
5+
# check-num-pages.sh [pdffile] [num_pages]
6+
7+
set -x
8+
pdffile=$1
9+
num_pages=$2
10+
[[ "$(pdfinfo $pdffile | grep Pages | awk '{print $2}')" == "$num_pages" ]] || exit 1

requirements/requirements.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
bump2version
22
cartopy==0.19.0.post1
33
matplotlib==3.4.2
4+
pdfx
45
pip-tools
56
pre-commit
67
scipy

requirements/requirements.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,18 @@ bump2version==1.0.1
1212
# via -r requirements.in
1313
cartopy==0.19.0.post1
1414
# via -r requirements.in
15+
cffi==1.15.0
16+
# via cryptography
1517
cfgv==3.2.0
1618
# via pre-commit
19+
chardet==4.0.0
20+
# via
21+
# pdfminer.six
22+
# pdfx
1723
click==8.0.0
1824
# via pip-tools
25+
cryptography==35.0.0
26+
# via pdfminer.six
1927
cycler==0.10.0
2028
# via matplotlib
2129
distlib==0.3.1
@@ -40,6 +48,10 @@ numpy==1.19.5
4048
# cartopy
4149
# matplotlib
4250
# scipy
51+
pdfminer.six==20201018
52+
# via pdfx
53+
pdfx==1.4.1
54+
# via -r requirements.in
4355
pep517==0.10.0
4456
# via pip-tools
4557
pillow==8.1.2
@@ -48,6 +60,8 @@ pip-tools==6.1.0
4860
# via -r requirements.in
4961
pre-commit==2.11.1
5062
# via -r requirements.in
63+
pycparser==2.20
64+
# via cffi
5165
pyparsing==2.4.7
5266
# via matplotlib
5367
pyshp==2.1.3
@@ -65,6 +79,8 @@ six==1.15.0
6579
# cycler
6680
# python-dateutil
6781
# virtualenv
82+
sortedcontainers==2.4.0
83+
# via pdfminer.six
6884
toml==0.10.2
6985
# via
7086
# pep517

0 commit comments

Comments
 (0)