diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 021779f02..0248da707 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,15 +6,32 @@ concurrency: cancel-in-progress: true jobs: + linux: + name: Static linting runs-on: ubuntu-24.04 env: CLICOLOR_FORCE: "1" steps: + + - name: Checkout + uses: actions/checkout@v4 + with: + clean: false + show-progress: false + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 'latest' + # No cache, there are complaints about lockfiles that we don't want otherwise. See . + # cache: 'npm' + - name: Install prerequisites run: | + set -ex packages=( clang-tidy cppcheck @@ -33,26 +50,9 @@ jobs: # We need a more recent version of libunibreak for `lb_get_char_class` support. wget http://ftp.debian.org/debian/pool/main/libu/libunibreak/libunibreak{6,-dev}_6.1-2_amd64.deb sudo dpkg -i *.deb - - - name: Checkout - uses: actions/checkout@v4 - with: - clean: false - show-progress: false + # Install stylelint. + npm init --yes + npm install stylelint stylelint-config-standard - name: Lint run: ./utils/lint.sh 2>&1 - - # NPM tests - - - name: Uses Node.js - uses: actions/setup-node@v4 - with: - node-version: 'latest' - # No cache, there are complaints about lockfiles that we don't want otherwise. See . - # cache: 'npm' - - - run: npm init --yes && npm install stylelint stylelint-config-standard - - - name: Check CSS syntax (only epub.css, html5.css and fb2.css) - run: npx stylelint cr3gui/data/epub.css cr3gui/data/html5.css cr3gui/data/fb2.css diff --git a/utils/lint.mk b/utils/lint.mk index cd2dfffe7..d71e6318d 100644 --- a/utils/lint.mk +++ b/utils/lint.mk @@ -98,6 +98,16 @@ endef # }}} +# CSS files. {{{ + +define CSS_FILES +cr3gui/data/epub.css +cr3gui/data/html5.css +cr3gui/data/fb2.css +endef + +# }}} + # Hyphenation patterns. {{{ HYPH_DIR := cr3gui/data/hyph @@ -281,6 +291,19 @@ endef # }}} +# Stylelint. {{{ + +define STYLELINT_FLAGS +$(if $(CLICOLOR_FORCE),--color) +--formatter=$(if $(GITHUB_ACTIONS),github,unix) +endef + +define stylelint_rule +$(call lint_rule,stylelint,$1,$(ci_time) npx stylelint $(strip $(STYLELINT_FLAGS) $1)) +endef + +# }}} + # XmlLint. {{{ define xmllint_rule @@ -290,17 +313,20 @@ endef # }}} CPPFILES := $(filter %.c %.cpp,$(sort $(CPPFILES) $(filter-out cppcheck-% clang-tidy-%,$(MAKECMDGOALS)))) +CSS_FILES := $(filter %.css, $(sort $(CSS_FILES) $(filter-out stylelint-%,$(MAKECMDGOALS)))) HYPH_PATTERNS := $(filter %.pattern,$(sort $(HYPH_PATTERNS) $(filter-out xmllint-%,$(MAKECMDGOALS)))) -lint: $(CPPFILES) $(HYPH_LANGUAGES) $(HYPH_PATTERNS) +lint: $(CPPFILES) $(CSS_FILES) $(HYPH_LANGUAGES) $(HYPH_PATTERNS) cpp: $(CPPFILES) hyph: $(HYPH_LANGUAGES) $(HYPH_PATTERNS) +style: $(CSS_FILES) + # Avoid "Nothing to be done for '…'" # or "'…' is up to date messages". -$(CPPFILES) $(HYPH_PATTERNS): +$(CPPFILES) $(CSS_FILES) $(HYPH_PATTERNS): @: .PHONY: $(HYPH_LANGUAGES) @@ -310,6 +336,10 @@ $(foreach f,$(CPPFILES),\ $(eval $(call cppcheck_rule,$f))\ ) +$(foreach f,$(CSS_FILES),\ + $(eval $(call stylelint_rule,$f))\ + ) + $(eval $(call lint_rule,check,$(HYPH_LANGUAGES),$(check_languages.json))) $(foreach f,$(HYPH_PATTERNS),\