Skip to content

Build test and quality checks #1330

Build test and quality checks

Build test and quality checks #1330

Workflow file for this run

name: Build test and quality checks
on: [pull_request, push]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
main:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.owner.login != github.event.pull_request.base.repo.owner.login
# https://github.com/actions/runner-images
runs-on: ubuntu-22.04
env:
HEAD_OWNER: ${{ github.event.pull_request.head.repo.owner.login }}
defaults:
run:
shell: sh
working-directory: /dev/shm
steps:
- name: Deploy DietPi-Website locally
id: deploy
run: bash -c "$(curl -sSf "https://raw.githubusercontent.com/${HEAD_OWNER:-$GITHUB_REPOSITORY_OWNER}/DietPi-Website/${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}/deploy.bash")" bash .
- name: Setup JRE for Nu Html Checker
# https://github.com/actions/setup-java/tags
uses: actions/setup-java@v4
with:
distribution: 'temurin'
# https://github.com/adoptium
java-version: '19'
java-package: jre
check-latest: true
- name: Download Nu Html Checker
run: curl -sSfLO 'https://github.com/validator/validator/releases/download/latest/vnu.jar'
- name: Run Nu Html Checker to check HTML, CSS and SVG files
run: |
java -jar vnu.jar --verbose *.html
java -jar vnu.jar --css --verbose css/[!b][!o]*.css # Exclude bootstrap.min.css
java -jar vnu.jar --skip-non-svg --verbose .
- name: Check for obsolete image files
if: always() && steps.deploy.outcome == 'success'
run: |
ec=0
while read -r line; do [ $line != ${line#images/dietpi-logo_} ] || grep -rq "$line" *.html || { ec=1; echo "ERROR: $line is not used"; }; done << _EOF_
$(find images/ -type f)
_EOF_
exit "$ec"
- name: Setup Python for PySpelling
id: python
if: always() && steps.deploy.outcome == 'success'
# https://github.com/actions/setup-python/tags
uses: actions/setup-python@v5
with:
python-version: '3.x'
check-latest: true
- name: Install PySpelling
id: pyspelling
if: always() && steps.python.outcome == 'success'
run: |
{ pip3 install -U pip setuptools wheel; pip3 install -U pyspelling; } &
sudo apt-get -q update
sudo apt-get -qq --no-install-recommends install aspell-en
- name: Run PySpelling to check HTML files
if: always() && steps.pyspelling.outcome == 'success'
run: pyspelling -vc .spellcheck.yml
- name: Download lychee
id: lychee
if: always() && steps.deploy.outcome == 'success'
run: |
curl -sSfL "$(curl -sSfH 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' 'https://api.github.com/repos/lycheeverse/lychee/releases/latest' | mawk -F\" '/"browser_download_url.*x86_64-unknown-linux-musl\.tar\.gz"/{print $4;exit}')" -o lychee.tar.gz
tar xf lychee.tar.gz
- name: Run lychee to check Markdown and HTML files
if: always() && steps.lychee.outcome == 'success'
run: ./lychee -En --cache --require-https --exclude '^https://(twitter.com/DietPi_|www.patreon.com/DietPi)$' --github-token '${{ secrets.GITHUB_TOKEN }}' -b '.' '**/*.md' '**/*.html'