-
Notifications
You must be signed in to change notification settings - Fork 28
116 lines (114 loc) · 3.92 KB
/
jekyll.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: Jekyll site CI
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize]
jobs:
episode:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Dates are valid
run: |
pip install pytz ciso8601
for episode in _episodes/*/*.md; do
date=$(grep 'date:' "$episode" | head -n1 | sed 's/^date: //')
if ! python -c "import ciso8601; ciso8601.parse_rfc3339('$date');"; then
echo "$episode: bad date '$date'"
exit 1
fi
done
- name: File size specifications are correct
run: |
for episode in _episodes/*/*.md; do
length=$(grep 'length:' "$episode" | head -n1 | awk '{print $2}' | sed 's/"//g')
file=$(grep 'file:' "$episode" | head -n1 | sed -e 's/^file: //' -e 's/"//g')
size=$(curl --head -f -s "$file" | grep content-length | awk '{print $2}' | sed 's/\r//')
if [ -z $size ]; then
echo "couldn't get content length of \"$file\""
exit 1
fi
if [ $size -ne $length ]; then
echo "$(basename "$episode"): ${length}b (reported) != ${size}b (actual)"
exit 1
fi
done
- name: No duplicate URLs
run: |
for episode in _episodes/*/*.md; do
file=$(grep 'file:' "$episode" | head -n1 | sed -e 's/^file: //' -e 's/"//g')
n=$(grep -F "$file" -l _episodes/*/*.md | wc -l)
if [[ $n -gt 1 ]]; then
echo "$episode: shares file with other episodes:"
grep -F "$file" -l _episodes/*/*.md | grep -vF "$episode"
exit 1
fi
done
- name: No duplicate slugs
# For collections, jekyll _only_ uses the basename (without date) of each
# post for the slug, and doesn't error on duplicates. So we must check.
run: |
for episode in _episodes/*/*.md; do
slug="$(basename "$episode" | sed 's/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]-//')"
files=(_episodes/*/????-??-??-$slug)
if [[ "${#files[@]}" -gt 1 ]]; then
echo "Duplicate slugs found: ${files[*]}"
exit 1
fi
done
transcript:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Transcripts match episodes
run: |
for transcript in _transcripts/*/*.md; do
episode="_episodes/$(basename "$(dirname "$transcript")")/$(basename "$transcript")"
if [[ ! -e $episode ]]; then
echo "$transcript: no matching episode"
exit 1
fi
done
feed:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'
bundler-cache: true
- name: Install dependencies
run: bundle install
- name: Build site and feed
run: |
# have site.url produce a valid value
sed -i -e '/^collections:/i \
url: https://rustacean-station.org' \
_config.yml
bundle exec jekyll build
- name: Grab feed validator
run: |
git clone https://github.com/w3c/feedvalidator.git
- uses: actions/setup-python@v4
with:
python-version: '3.x'
cache: 'pip'
- name: Validate feed
run: |
# Fix Ubuntu MIME type for RSS
sudo sed -i 's@application/x-rss+xml@application/rss+xml@' /etc/mime.types
cp _site/podcast.rss validate.rss
# https://github.com/rubys/feedvalidator/issues/16
sed -i -e 's/https:/http:/g' \
-e '/rel="self"/ s@href="[^"]*"@href="file://'"$(pwd)"'/validate.rss"@' \
-e '/xmlns:content/a \
xml:base="https://rustacean-station.org"' \
validate.rss
cd feedvalidator
pip install -r requirements.txt
if ! python src/demo.py ../validate.rss; then
cat ../validate.rss
exit 1
fi