From d3f52da8dee36357433e66b272e6d0d9a9d4deb2 Mon Sep 17 00:00:00 2001 From: James Adams Date: Fri, 25 Aug 2023 13:25:44 +0100 Subject: [PATCH] Rework old TravisCI test config to GitHub actions --- .github/workflows/continuous-integration.yaml | 38 +++++++++++++++++++ .gitignore | 1 + {.travis-scripts => .tests}/dictionary.txt | 0 .../html-proofer => .tests/htmlproofer | 8 ++-- .tests/spellchecker | 35 +++++++++++++++++ {.travis-scripts => .tests}/url-ignore | 0 .travis-scripts/spellchecker | 35 ----------------- .travis.yml | 37 ------------------ Gemfile | 10 +---- 9 files changed, 80 insertions(+), 84 deletions(-) create mode 100644 .github/workflows/continuous-integration.yaml rename {.travis-scripts => .tests}/dictionary.txt (100%) rename .travis-scripts/html-proofer => .tests/htmlproofer (83%) create mode 100755 .tests/spellchecker rename {.travis-scripts => .tests}/url-ignore (100%) delete mode 100755 .travis-scripts/spellchecker delete mode 100644 .travis.yml diff --git a/.github/workflows/continuous-integration.yaml b/.github/workflows/continuous-integration.yaml new file mode 100644 index 00000000..69a73550 --- /dev/null +++ b/.github/workflows/continuous-integration.yaml @@ -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 diff --git a/.gitignore b/.gitignore index 5301eff3..9380531f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ _site *~ Gemfile.lock +vendor/ # Eclipse project .project diff --git a/.travis-scripts/dictionary.txt b/.tests/dictionary.txt similarity index 100% rename from .travis-scripts/dictionary.txt rename to .tests/dictionary.txt diff --git a/.travis-scripts/html-proofer b/.tests/htmlproofer similarity index 83% rename from .travis-scripts/html-proofer rename to .tests/htmlproofer index ab25e8fd..74cc0707 100755 --- a/.travis-scripts/html-proofer +++ b/.tests/htmlproofer @@ -38,13 +38,13 @@ done < "${url_ignore_file}" url_ignore_patterns=$(echo "${url_ignore_patterns}" | sed -e 's/^,//') if [ -n "${url_ignore_patterns}" ] then - url_ignore_option="--url-ignore ${url_ignore_patterns}" + 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 ${url_ignore_option} ${debug_option} ./_site" +echo "Running: $cmd" +$cmd status=$? if [ ${status} -ne 0 -a -z "${debug_option}" ] then diff --git a/.tests/spellchecker b/.tests/spellchecker new file mode 100755 index 00000000..b98be544 --- /dev/null +++ b/.tests/spellchecker @@ -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 diff --git a/.travis-scripts/url-ignore b/.tests/url-ignore similarity index 100% rename from .travis-scripts/url-ignore rename to .tests/url-ignore diff --git a/.travis-scripts/spellchecker b/.travis-scripts/spellchecker deleted file mode 100755 index 85fe0797..00000000 --- a/.travis-scripts/spellchecker +++ /dev/null @@ -1,35 +0,0 @@ -#!/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 .travis-scripts/dictionary.txt /tmp/markdown-spellchecker-$SCVERSION/src/dict.txt - -echo -echo spellchecker config: -echo -------------------- -cat /tmp/markdown-spellchecker-$SCVERSION/src/config.ini -echo -------------------- -echo - -pyenv versions -pyenv local 3.6 -pip3 install pyenchant - -# In a pull request, ${TRAVIS_COMMIT_RANGE} contains the commit range of the PR -# Using it allows to test modified/added files of all PR commits and ensure that -# deleted files are ignored (git diff provides the summary of all the modifications) -if [ -n "${TRAVIS_COMMIT_RANGE}" ] -then - commit_range=${TRAVIS_COMMIT_RANGE} - echo "Checking modified MD files in commit range ${commit_range}..." -else - commit_range="HEAD^" - echo "Checking modified MD files in last commit..." -fi - -# Ignore deleted files -git diff --name-only --diff-filter=d ${commit_range} | grep '\.md$' | grep -v '^assets/' | xargs -r python3.6 /tmp/markdown-spellchecker-$SCVERSION/src/spellchecker.py || exit 1 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 14f32903..00000000 --- a/.travis.yml +++ /dev/null @@ -1,37 +0,0 @@ -language: ruby - -rvm: -- 2.4.2 - -before_install: gem install bundler # update bundler. - -before_script: bundle update github-pages - -# Assume bundler is being used, therefore -# the `install` step will run `bundle install` by default. -script: - - ./.travis-scripts/spellchecker - - ./.travis-scripts/html-proofer - -# branch whitelist, only for GitHub Pages -branches: - only: - - master - -env: - global: - - NOKOGIRI_USE_SYSTEM_LIBRARIES=true # speeds up installation of html-proofer - -cache: - bundler: true - directories: - - $TRAVIS_BUILD_DIR/tmp/.htmlproofer # See https://github.com/gjtorikian/html-proofer/issues/381 - -addons: - apt: - packages: - - python3-enchant # Won't be used, but pulls in required system dependencies for version from PIP - - libcurl4-openssl-dev # required to avoid SSL errors - -sudo: false -dist: trusty diff --git a/Gemfile b/Gemfile index 2711a01c..664ad42f 100644 --- a/Gemfile +++ b/Gemfile @@ -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'