Skip to content

2024-04-12 Marco Ieni #920

2024-04-12 Marco Ieni

2024-04-12 Marco Ieni #920

Workflow file for this run

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