Skip to content

Commit

Permalink
Merge pull request #277 from jrha/github_actions
Browse files Browse the repository at this point in the history
Rework old TravisCI test config to GitHub actions
  • Loading branch information
wpoely86 authored Aug 28, 2023
2 parents 55fe487 + b0b7022 commit d8f5a1b
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 97 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/continuous-integration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Run Tests

on: [push, pull_request]

jobs:
runtests:
runs-on: ubuntu-latest
steps:
- name: Set up Ruby
uses: ruby/setup-ruby@ec02537da5712d66d4d50a0f33b7eb52773b5ed1
with:
bundler-cache: true
ruby-version: '3.1'
- name: Set up Python 3
uses: actions/setup-python@v4
with:
python-version: 3
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install pyenchant
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 250
- name: Install Ruby gems
run: bundle install
env:
NOKOGIRI_USE_SYSTEM_LIBRARIES: true # speeds up installation of html-proofer
- name: Build with Jekyll
uses: actions/jekyll-build-pages@v1
with:
source: ./
destination: ./_site
- name: Check Spelling
run: .tests/spellchecker
- name: Check HTML
run: .tests/htmlproofer
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
_site
*~
Gemfile.lock
vendor/

# Eclipse project
.project
Expand Down
File renamed without changes.
31 changes: 14 additions & 17 deletions .travis-scripts/html-proofer → .tests/htmlproofer
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,15 @@ usage () {

debug_option=

if [ "$1" == "--debug" ]
then
if [[ "$1" == "--debug" ]]; then
debug_option="--log-level debug"
elif [ -n "$1" ]
then
elif [[ -n "$1" ]]; then
echo "Unsupported option ($1)"
usage
fi

url_ignore_file=$(dirname $0)/url-ignore
if [ ! -f ${url_ignore_file} ]
then
url_ignore_file="$(dirname "$0")/url-ignore"
if [[ ! -f "${url_ignore_file}" ]]; then
echo "List of URL to ignore must exist (${url_ignore_file}), even if empty"
exit 1
fi
Expand All @@ -28,26 +25,26 @@ url_ignore_patterns=
url_ignore_option=
# The following construct ensure that the end line is processed if not ending by \n
while IFS='' read -r url || [[ -n "$url" ]]; do
url=$(echo ${url} | sed -e 's/\s*#.*$//')
#shellcheck disable=SC2001
url=$(echo "${url}" | sed -e 's/\s*#.*$//')
if [ -n "${url}" ]
then
url=$(echo ${url} | sed -e 's%/%\\/%g' -e 's/\./\\./g' -e 's/\?/\\?/')
url=$(echo "${url}" | sed -e 's%/%\\/%g' -e 's/\./\\./g' -e 's/\?/\\?/')
url_ignore_patterns="${url_ignore_patterns},/${url}/"
fi
done < "${url_ignore_file}"
#shellcheck disable=SC2001
url_ignore_patterns=$(echo "${url_ignore_patterns}" | sed -e 's/^,//')
if [ -n "${url_ignore_patterns}" ]
then
url_ignore_option="--url-ignore ${url_ignore_patterns}"
if [[ -n "${url_ignore_patterns}" ]]; then
url_ignore_option="--ignore-urls=${url_ignore_patterns}"
fi
echo "html-proofer url-ignore option: ${url_ignore_option}"

bundle exec jekyll build
set +e # do not halt script on error
bundle exec htmlproofer --disable-external ${url_ignore_option} ${debug_option} --check-html ./_site
cmd="bundle exec htmlproofer --disable-external=true --enforce-https=false ${url_ignore_option} ${debug_option} ./_site"
echo "Running: $cmd"
$cmd
status=$?
if [ ${status} -ne 0 -a -z "${debug_option}" ]
then
if [[ ${status} -ne 0 && -z "${debug_option}" ]]; then
echo ""
echo "htmlproofer failed to validate site contents: use --debug for more information"
fi
Expand Down
35 changes: 35 additions & 0 deletions .tests/spellchecker
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
set -e # halt script on error

SCVERSION="1.4"

wget https://github.com/stfc/markdown-spellchecker/archive/$SCVERSION.tar.gz -O /tmp/spellchecker.tar.gz
(cd /tmp && tar -xvzf spellchecker.tar.gz)

cp -f .tests/dictionary.txt /tmp/markdown-spellchecker-$SCVERSION/src/dict.txt

echo
echo spellchecker config:
echo --------------------
cat /tmp/markdown-spellchecker-$SCVERSION/src/config.ini
echo --------------------
echo

commit_range="HEAD^..HEAD"

echo "Commit Range: ${commit_range}"

# Ignore deleted files
md_files="$(git diff --name-only --diff-filter=d "${commit_range}" -- | grep '\.md$' | grep -v '^assets/' || true)"

if [[ -n "$md_files" ]]; then
echo "Markdown files changed:"
#shellcheck disable=SC2001
echo "$md_files" | sed 's/^/ /g'
echo "Running markdown-spellchecker:"
python3 /tmp/markdown-spellchecker-$SCVERSION/src/spellchecker.py $md_files || exit 1
exit 0
else
echo "No markdown files changed, nothing to do."
exit 0
fi
File renamed without changes.
35 changes: 0 additions & 35 deletions .travis-scripts/spellchecker

This file was deleted.

37 changes: 0 additions & 37 deletions .travis.yml

This file was deleted.

10 changes: 2 additions & 8 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
source 'https://rubygems.org'

gem 'github-pages', '>= 175'
gem 'jekyll-feed'
gem 'jekyll-redirect-from'
gem 'html-proofer', '~> 3'

# Suggested by Jekyll
gem 'wdm', '>= 0.1.0' if Gem.win_platform?
ruby "~> 3"
gem 'html-proofer', '~> 4'

0 comments on commit d8f5a1b

Please sign in to comment.