ci: lint YAML and spell check code

This commit is contained in:
Ben Grande 2024-07-08 11:12:38 +02:00
parent ab044c15b1
commit 077b9b4e5e
No known key found for this signature in database
GPG Key ID: 00C64E14F51F9E56
11 changed files with 115 additions and 13 deletions

9
.codespellrc Normal file
View File

@ -0,0 +1,9 @@
# SPDX-FileCopyrightText: 2023 Benjamin Grande M. S. <ben.grande.b@gmail.com>
#
# SPDX-License-Identifier: GPL-3.0-or-later
# vim: ft=toml
[codespell]
skip = LICENSES,.git,*.asc,./rpm_spec/*-*.spec,*.muttrc,./salt/sys-cacher/files/server/conf/*_mirrors_*,./salt/dotfiles/files/vim/.config/vim/after/plugin/update-time.vim
ignore-words-list = uptodate,iterm,doas
ignore-regex = (nnoremap|bind)\b.*

View File

@ -34,13 +34,12 @@ jobs:
run: sudo apt-get -y update run: sudo apt-get -y update
- name: Install OS packages - name: Install OS packages
# yamllint disable-line rule:line-length # yamllint disable-line rule:line-length
run: sudo apt-get install -y python3-dev python3-pip shellcheck reuse ruby-mdl pylint run: sudo apt-get install -y $(cat dev-deps-debian.txt)
# gitlint is available on Debian but Ubuntu has an older version.
- name: Remove externally managed python environment flag - name: Remove externally managed python environment flag
# yamllint disable-line rule:line-length # yamllint disable-line rule:line-length
run: sudo dpkg-divert --rename --add /usr/lib/$(py3versions -d)/EXTERNALLY-MANAGED run: sudo dpkg-divert --rename --add /usr/lib/$(py3versions -d)/EXTERNALLY-MANAGED
- name: Install pip packages - name: Install pip packages
run: pip3 install salt-lint gitlint run: pip3 install $(cat dev-deps-pip.txt)
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0

View File

@ -1,3 +1,4 @@
# yamllint disable-line rule:line-length
# SPDX-FileCopyrightText: 2023 - 2024 Benjamin Grande M. S. <ben.grande.b@gmail.com> # SPDX-FileCopyrightText: 2023 - 2024 Benjamin Grande M. S. <ben.grande.b@gmail.com>
# #
# SPDX-License-Identifier: AGPL-3.0-or-later # SPDX-License-Identifier: AGPL-3.0-or-later
@ -14,6 +15,13 @@ repos:
pass_filenames: true pass_filenames: true
description: Prohibit Unicode description: Prohibit Unicode
- id: spell-lint
name: spell-lint
entry: scripts/spell-lint.sh
language: script
pass_filenames: true
description: Spellcheck files
- id: shell-lint - id: shell-lint
name: shell-lint name: shell-lint
entry: scripts/shell-lint.sh entry: scripts/shell-lint.sh
@ -45,6 +53,14 @@ repos:
files: \.(sls|top)$ files: \.(sls|top)$
description: Lint Salt files description: Lint Salt files
- id: yaml-lint
name: yaml-lint
entry: scripts/yaml-lint.sh
language: script
pass_filenames: true
files: \.(yaml|yml)$
description: Lint YAML files
- id: qubesbuilder-gen - id: qubesbuilder-gen
name: qubesbuilder-gen name: qubesbuilder-gen
entry: scripts/qubesbuilder-gen.sh entry: scripts/qubesbuilder-gen.sh
@ -53,14 +69,14 @@ repos:
pass_filenames: false pass_filenames: false
description: Check if .qubesbuilder is up to date description: Check if .qubesbuilder is up to date
# TODO: generate temporary spec and compare against staged one. # TODO: generate temporary spec and compare against staged one.
# - id: spec-gen # - id: spec-gen
# name: spec-gen # name: spec-gen
# language: script # language: script
# entry: scripts/spec-gen.sh test # entry: scripts/spec-gen.sh test
# args: [test] # args: [test]
# # pass_filenames: true # # pass_filenames: true
# description: Check if RPM SPEC files are up to date # description: Check if RPM SPEC files are up to date
- id: reuse-lint - id: reuse-lint
name: reuse-lint name: reuse-lint

View File

@ -11,6 +11,10 @@ Files: version salt/*/version
Copyright: 2023 - 2024 Benjamin Grande M. S. <ben.grande.b@gmail.com> Copyright: 2023 - 2024 Benjamin Grande M. S. <ben.grande.b@gmail.com>
License: CC0-1.0 License: CC0-1.0
Files: dependencies/*
Copyright: 2024 Benjamin Grande M. S. <ben.grande.b@gmail.com>
License: CC0-1.0
Files: salt/electrum/files/client/keys/* Files: salt/electrum/files/client/keys/*
Copyright: SomberNight/ghost43 <somber.night@protonmail.com> Copyright: SomberNight/ghost43 <somber.night@protonmail.com>
Stephan Oeste <stephan@oeste.de> Stephan Oeste <stephan@oeste.de>

View File

@ -11,8 +11,8 @@ ignore: |
yaml-files: yaml-files:
- '*.yaml' - '*.yaml'
- '*.yml' - '*.yml'
- .salt-lint
- .yamllint strict: true
rules: rules:
empty-values: empty-values:

11
dependencies/debian.txt vendored Normal file
View File

@ -0,0 +1,11 @@
codespell
git
gitlint
pre-commit
pylint
python3-dev
python3-pip
reuse
ruby-mdl
shellcheck
yamllint

1
dependencies/pip.txt vendored Normal file
View File

@ -0,0 +1 @@
salt-lint

4
dependencies/rpm.txt vendored Normal file
View File

@ -0,0 +1,4 @@
dnf
dnf-plugins-core
rpm
rpmlint

30
scripts/spell-lint.sh Executable file
View File

@ -0,0 +1,30 @@
#!/bin/sh
## SPDX-FileCopyrightText: 2023 - 2024 Benjamin Grande M. S. <ben.grande.b@gmail.com>
##
## SPDX-License-Identifier: AGPL-3.0-or-later
# shellcheck disable=SC2086
set -eu
command -v git >/dev/null || { echo "Missing program: git" >&2; exit 1; }
cd "$(git rev-parse --show-toplevel)" || exit 1
./scripts/requires-program.sh codespell
if test -n "${1-}"; then
files=""
for f in "$@"; do
test -f "$f" || continue
case "$f" in
*LICENSES/*|.git/*|*.asc|rpm_spec/*-*.spec|*.muttrc| \
salt/sys-cacher/files/server/conf/*_mirrors_*|\
salt/dotfiles/files/vim/.config/vim/after/plugin/update-time.vim)
continue;;
*) files="$files $f";;
esac
done
test -n "$files" || exit 0
exec codespell --check-filenames --check-hidden ${files}
fi
exec codespell --check-filenames --check-hidden

28
scripts/yaml-lint.sh Executable file
View File

@ -0,0 +1,28 @@
#!/bin/sh
## SPDX-FileCopyrightText: 2024 Benjamin Grande M. S. <ben.grande.b@gmail.com>
##
## SPDX-License-Identifier: AGPL-3.0-or-later
# shellcheck disable=SC2086
set -eu
command -v git >/dev/null || { echo "Missing program: git" >&2; exit 1; }
cd "$(git rev-parse --show-toplevel)" || exit 1
./scripts/requires-program.sh yamllint
if test -n "${1-}"; then
files=""
for f in "$@"; do
test -f "$f" || continue
extension="${f##*.}"
case "$extension" in
yaml|yml) files="$files $f";;
*) continue;;
esac
done
test -n "$files" || exit 0
exec yamllint ${files}
fi
exec yamllint .