Skip to content

Commit

Permalink
CI: Add HTML proofing check; switch to Ruby 3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
lah7 committed Oct 30, 2024
1 parent 570bd13 commit 87ea9b2
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 75 deletions.
24 changes: 6 additions & 18 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,22 @@ on: [push, pull_request]

jobs:
build:
name: Build
name: Build & Deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Cache RubyGems
uses: actions/cache@v4
env:
cache-name: rubygems
- uses: ruby/setup-ruby@v1
with:
path: vendor/bundle
key: ${{ runner.os }}-${{ hashFiles('**/Gemfile.lock') }}

- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install ruby ruby-dev ruby-bundler make gcc rsync
bundle config path vendor/bundle
bundle install --jobs=4
ruby-version: '3.3'
bundler-cache: true

- name: Build
run: |
bundle config path vendor/bundle
scripts/build.sh
# - name: Proofing
# run: |
# scripts/test.sh
- name: Proofing
run: scripts/test.sh

- name: Deploy
if: ${{ github.event_name == 'push' && github.repository == 'polychromatic/website' && github.ref == 'refs/heads/master' }}
Expand Down
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ gem "jekyll-sitemap"
# bundler: failed to load command: jekyll (/opt/gem/ruby/3.0.0/bin/jekyll)
# lib/jekyll.rb:29:in `require': cannot load such file -- json (LoadError)
gem "json", "~> 2.7"

# HTML proofing (+ dependencies)
gem "html-proofer"
gem "ostruct"
gem "logger"
76 changes: 70 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,25 +1,53 @@
GEM
remote: https://rubygems.org/
specs:
Ascii85 (1.1.1)
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
afm (0.2.2)
async (2.18.0)
console (~> 1.26)
fiber-annotation
io-event (~> 1.6, >= 1.6.5)
bigdecimal (3.1.8)
colorator (1.1.0)
concurrent-ruby (1.2.3)
console (1.27.0)
fiber-annotation
fiber-local (~> 1.1)
json
em-websocket (0.5.3)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0)
ethon (0.16.0)
ffi (>= 1.15.0)
eventmachine (1.2.7)
ffi (1.16.3)
fiber-annotation (0.2.0)
fiber-local (1.1.0)
fiber-storage
fiber-storage (1.0.0)
forwardable-extended (2.6.0)
google-protobuf (3.25.2)
google-protobuf (3.25.2-aarch64-linux)
google-protobuf (3.25.2-arm64-darwin)
google-protobuf (3.25.2-x86-linux)
google-protobuf (3.25.2-x86_64-darwin)
google-protobuf (3.25.2-x86_64-linux)
google-protobuf (3.25.5)
google-protobuf (3.25.5-aarch64-linux)
google-protobuf (3.25.5-arm64-darwin)
google-protobuf (3.25.5-x86-linux)
google-protobuf (3.25.5-x86_64-darwin)
google-protobuf (3.25.5-x86_64-linux)
hashery (2.1.2)
html-proofer (5.0.9)
addressable (~> 2.3)
async (~> 2.1)
nokogiri (~> 1.13)
pdf-reader (~> 2.11)
rainbow (~> 3.0)
typhoeus (~> 1.3)
yell (~> 2.0)
zeitwerk (~> 2.5)
http_parser.rb (0.8.0)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
io-event (1.7.3)
jekyll (4.3.3)
addressable (~> 2.4)
colorator (~> 1.0)
Expand Down Expand Up @@ -51,15 +79,42 @@ GEM
listen (3.8.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
logger (1.6.1)
mercenary (0.4.0)
mini_portile2 (2.8.7)
nokogiri (1.16.7)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
nokogiri (1.16.7-aarch64-linux)
racc (~> 1.4)
nokogiri (1.16.7-arm-linux)
racc (~> 1.4)
nokogiri (1.16.7-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.7-x86-linux)
racc (~> 1.4)
nokogiri (1.16.7-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.16.7-x86_64-linux)
racc (~> 1.4)
ostruct (0.6.0)
pathutil (0.16.2)
forwardable-extended (~> 2.6)
pdf-reader (2.12.0)
Ascii85 (~> 1.0)
afm (~> 0.2.1)
hashery (~> 2.0)
ruby-rc4
ttfunk
public_suffix (5.0.4)
racc (1.8.1)
rainbow (3.1.1)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
rexml (3.2.6)
rouge (4.2.0)
ruby-rc4 (0.1.5)
safe_yaml (1.0.5)
sass-embedded (1.69.5-aarch64-linux-android)
google-protobuf (~> 3.23)
Expand Down Expand Up @@ -91,8 +146,14 @@ GEM
google-protobuf (~> 3.23)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
ttfunk (1.8.0)
bigdecimal (~> 3.1)
typhoeus (1.4.1)
ethon (>= 0.9.0)
unicode-display_width (2.5.0)
webrick (1.8.1)
yell (2.2.2)
zeitwerk (2.7.1)

PLATFORMS
aarch64-linux
Expand All @@ -113,9 +174,12 @@ PLATFORMS
x86_64-linux-musl

DEPENDENCIES
html-proofer
jekyll
jekyll-sitemap
json (~> 2.7)
logger
ostruct
webrick

BUNDLED WITH
Expand Down
2 changes: 1 addition & 1 deletion _layouts/downloads.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ <h1 class="page-title">{{ page.title | escape }}</h1>
{{ content }}

<div id="unsupported-os" style="display:none" hidden>
<img id="unsupported-os-img" src="" alt=""/>
<img id="unsupported-os-img" src="/assets/img/platforms/windows.svg" alt="Windows logo"/>
<div>
<h2>Your operating system is not supported yet</h2>
<p id="unsupported-os-msg" class="grey">Sorry! Polychromatic only runs on GNU/Linux systems.</p>
Expand Down
3 changes: 3 additions & 0 deletions assets/polychromatic.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,21 @@ function downloadPage() {
unsupportedBox.style.display = "flex";
unsupportedBox.hidden = false;
unsupportedImg.src = "/assets/img/platforms/windows.svg";
unsupportedImg.alt = "Windows logo";
}

if (userAgent.indexOf("Macintosh") > 0) {
unsupportedBox.style.display = "flex";
unsupportedBox.hidden = false;
unsupportedImg.src = "/assets/img/platforms/macOS.svg";
unsupportedImg.alt = "macOS logo";
}

if (userAgent.indexOf("CrOS") > 0) {
unsupportedBox.style.display = "flex";
unsupportedBox.hidden = false;
unsupportedImg.src = "/assets/img/platforms/chromeOS.svg";
unsupportedImg.alt = "ChromeOS logo";
const msg = document.querySelector("#unsupported-os-msg");
msg.innerText = "While ChromeOS is based on Linux, installing the driver for OpenRazer may not be supported.";
}
Expand Down
58 changes: 8 additions & 50 deletions scripts/test.sh
Original file line number Diff line number Diff line change
@@ -1,59 +1,17 @@
#!/bin/bash
#
# Runs tests against the built version of the site.
# Test the built version of the site by proofing the HTML.
#
# 'html-proofer' RubyGem provided by:
# https://github.com/gjtorikian/html-proofer
#
# This script contains two tests:
#
# <no parameters> Check internal links, images and HTML output.
# --external All of the above, plus external links.
#

cd "$(dirname $0)/../"

# CI only: htmlproofer is installed in vendor folder
if [ -d "vendor/" ]; then
htmlproofer="bundle exec htmlproofer"
else
htmlproofer="htmlproofer"
fi

function check_for_error() {
if [ $1 != 0 ]; then
exit 1
fi
}

if [ "$1" == "--external" ]; then
# i18n pages are ignored as it will take much longer and duplicate URL checks.
ignore_list=""
for lang in $(cat _i18n/locales.txt); do
ignore_list+="/_site/$lang/,"
done
ignore_list+="/_site/en/"

echo "Proofing HTML (and external links)..."
$htmlproofer \
--assume-extension \
--check-html \
--check-img-http \
--empty_alt_ignore \
--enforce-https \
--url-ignore "polychromatic.app" \
--http-status-ignore "301,302,429" \
--file-ignore "$ignore_list" \
./_site
else
echo "Proofing HTML..."
$htmlproofer \
--assume-extension \
--check-html \
--check-img-http \
--enforce-https \
--empty_alt_ignore \
--disable-external \
./_site
fi
check_for_error $?
bundle exec htmlproofer \
--allow-missing-href \
--only-4xx \
--ignore-status-codes 429,500 \
--ignore-urls packages.ubuntu.com \
./_site
exit $?

0 comments on commit 87ea9b2

Please sign in to comment.