Skip to content

Commit

Permalink
chore(makefile; maintenance_scripts): sync with pikaur - move all lin…
Browse files Browse the repository at this point in the history
…ting to the makefile
  • Loading branch information
actionless committed Aug 19, 2024
1 parent f46e503 commit c8b8374
Show file tree
Hide file tree
Showing 9 changed files with 229 additions and 303 deletions.
25 changes: 4 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,14 @@ jobs:
matrix:
include:
- PYVER: current_arch
SKIP_SHELLCHECK: 0
SKIP_MYPY: 0
SKIP_VULTURE: 0
SKIP_RUFF: 0
SKIP_PYPROJECT: 0
CI_MAKE_TARGET: lint

- PYVER: python310_ubuntu_2204
SKIP_SHELLCHECK: 1
SKIP_MYPY: 1
SKIP_VULTURE: 1
SKIP_RUFF: 1
SKIP_PYPROJECT: 1
CI_MAKE_TARGET: lint_ubuntu_310

env:
PYVER: ${{ matrix.PYVER }}
SKIP_SHELLCHECK: ${{ matrix.SKIP_SHELLCHECK }}
SKIP_MYPY: ${{ matrix.SKIP_MYPY }}
SKIP_VULTURE: ${{ matrix.SKIP_VULTURE }}
SKIP_RUFF: ${{ matrix.SKIP_RUFF }}
SKIP_PYPROJECT: ${{ matrix.SKIP_PYPROJECT }}
CI_MAKE_TARGET: ${{ matrix.CI_MAKE_TARGET }}

steps:
- uses: actions/checkout@v2
Expand All @@ -50,10 +38,5 @@ jobs:

- name: run ci in docker
run: docker run
-e SKIP_SHELLCHECK=${SKIP_SHELLCHECK}
-e SKIP_MYPY=${SKIP_MYPY}
-e SKIP_VULTURE=${SKIP_VULTURE}
-e SKIP_RUFF=${SKIP_RUFF}
-e SKIP_PYPROJECT=${SKIP_PYPROJECT}
oomox:latest
./maintenance_scripts/lint.sh
make ${CI_MAKE_TARGET}
174 changes: 172 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,41 @@ DEST_APPDIR = $(DESTDIR)$(APPDIR)
DEST_PLUGIN_DIR = $(DESTDIR)$(APPDIR)/plugins
DEST_PREFIX = $(DESTDIR)$(PREFIX)

SHELL := bash
PYTHON := $(shell which python)
ifeq (,$(PYTHON))
$(error Can't find Python)
endif

# lint:
RUFF := ruff
script_dir := $(shell readlink -e .)
APP_DIR := $(shell readlink -e "$(script_dir)")
TARGET_MODULE := oomox_gui
TARGETS := $(APP_DIR)/oomox_gui/ $(shell ls $(APP_DIR)/plugins/*/oomox_plugin.py) $(shell ls $(APP_DIR)/maintenance_scripts/*.py)
GLOBALS_IGNORES := \
-e ': Final' \
-e ' \# nonfinal-ignore' \
-e ' \# checkglobals-ignore' \
\
-e TypeVar \
-e namedtuple \
-e Generic \
-e Sequence \
\
-e 'BaseClass' \
-e 'HexColor' \
-e 'ColorScheme' \
\
-e './maintenance_scripts/find_.*.py.*:.*:' \
-e '.SRCINFO'

################################################################################

.PHONY: all
all: install

################################################################################

install_gui: install_import_random
$(eval PACKAGING_TMP_DIR := $(shell mktemp -d))
Expand Down Expand Up @@ -220,5 +255,140 @@ install_icons_suruplus_aspromauros:
.PHONY: install_gui install_import_random install_theme_arc install_theme_oomox install_theme_materia install_export_oomoxify install_import_images install_plugin_base16 install_icons_archdroid install_icons_gnomecolors install_icons_numix install_icons_papirus install_icons_suruplus install_icons_suruplus_aspromauros install_import_xresources install_export_xresources
install: install_gui install_theme_oomox install_theme_materia install_export_oomoxify install_import_images install_plugin_base16 install_icons_archdroid install_icons_gnomecolors install_icons_numix install_icons_papirus install_icons_suruplus install_icons_suruplus_aspromauros install_import_xresources install_export_xresources

.PHONY: all
all: install
################################################################################

lint_fix:
$(RUFF) check --fix $(TARGETS)

compile_all:
export PYTHONWARNINGS='ignore,error:::$(TARGET_MODULE)[.*],error:::pikaur_test[.*]'
# Running python compile:
$(PYTHON) -O -m compileall $(TARGETS) \
| (\
grep -v -e '^Listing' -e '^Compiling' || true \
)
# :: python compile passed ::

python_import:
# Running python import:
$(PYTHON) -c "import $(TARGET_MODULE).main"
# :: python import passed ::

non_final_globals:
# Checking for non-Final globals:
result=$$( \
grep -REn "^[a-zA-Z_]+ = " $(TARGETS) --color=always \
| grep -Ev \
\
-e '=.*\|' \
-e '=.*(dict|list|Callable)\[' \
\
$(GLOBALS_IGNORES) \
| sort \
) ; \
echo -n "$$result" ; \
exit "$$(test "$$result" = "" && echo 0 || echo 1)"
# :: non-final globals check passed ::

unreasonable_globals:
# Checking for unreasonable global vars:
result=$$( \
grep -REn "^[a-zA-Z_]+ = [^'\"].*" $(TARGETS) --color=always \
| grep -Ev \
\
-e ' =.*\|' \
-e ' = [a-zA-Z_]+\[' \
-e ' = str[^(]' \
\
$(GLOBALS_IGNORES) \
| sort \
) ; \
echo -n "$$result" ; \
exit "$$(test "$$result" = "" && echo 0 || echo 1)"
# :: global vars check passed ::

ruff:
# Checking Ruff rules up-to-date:
diff --color -u \
<(awk '/select = \[/,/]/' pyproject.toml \
| sed -e 's|", "|/|g' \
| head -n -1 \
| tail -n +2 \
| tr -d '",\#' \
| awk '{print $$1;}' \
| sort) \
<($(RUFF) linter \
| awk '{print $$1;}' \
| sort)
# Running ruff...
$(RUFF) check $(TARGETS)
# :: ruff passed ::

flake8:
# Running flake8:
$(PYTHON) -m flake8 $(TARGETS)
# :: flake8 passed ::

pylint:
# Running pylint:
$(PYTHON) -m pylint $(TARGETS) --score no
# :: pylint passed ::

mypy:
# Running mypy:
#$(PYTHON) -m mypy $(TARGETS) --no-error-summary
$(PYTHON) -m mypy $(TARGET_MODULE) --no-error-summary
# :: mypy passed ::

vulture:
# Running vulture:
$(PYTHON) -m vulture $(TARGETS) \
--min-confidence=1 \
--sort-by-size
# :: vulture passed ::

shellcheck:
# shellcheck disable=SC2046
# Running shellcheck:
( \
cd $(APP_DIR) || exit ; \
shellcheck $$(find . \
-name '*.sh' \
-not -path './plugins/icons_archdroid/archdroid-icon-theme/*' \
-not -path './plugins/icons_gnomecolors/gnome-colors-icon-theme/*' \
-not -path './plugins/icons_papirus/papirus-icon-theme/*' \
-not -path './plugins/icons_suruplus/suru-plus/*' \
-not -path './plugins/icons_suruplus_aspromauros/suru-plus-aspromauros/*' \
-not -path './plugins/base16/*.tmp/*' \
-not -path './plugins/oomoxify/*' \
-not -path './plugins/theme_arc/arc-theme/*' \
-not -path './plugins/theme_materia/materia-theme/*' \
-not -path './plugins/theme_oomox/gtk-theme/*' \
-or -path './packaging/bin/*' \
) \
)
# :: shellcheck passed ::

shellcheck_makefile:
# Running shellcheck on Makefile...
( \
cd $(APP_DIR) || exit ; \
$(PYTHON) ./maintenance_scripts/makefile_shellcheck.py --skip lint ; \
)
# :: shellcheck makefile passed ::

validate_pyproject:
# Validate pyproject file...
( \
exit_code=0 ; \
result=$$(validate-pyproject pyproject.toml 2>&1) || exit_code=$$? ; \
if [[ $$exit_code -gt 0 ]] ; then \
echo "$$result" ; \
exit "$$exit_code" ; \
fi \
)
# :: pyproject validation passed ::

.PHONY: lint compile_all python_import non_final_globals unreasonable_globals ruff flake8 pylint mypy vulture shellcheck shellcheck_makefile validate_pyproject
lint: compile_all python_import non_final_globals unreasonable_globals ruff flake8 pylint mypy vulture shellcheck shellcheck_makefile validate_pyproject
lint_ubuntu_310: compile_all python_import non_final_globals unreasonable_globals flake8 pylint
2 changes: 1 addition & 1 deletion dockerfiles/Dockerfile_current_arch
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ WORKDIR /opt/oomox-build/

# App and test (xvfb, pylint) deps
RUN pacman -Syu --noconfirm && \
pacman -S --needed --noconfirm gtk3 python-gobject python-yaml flake8 python-pylint xorg-server-xvfb mypy python-typing_extensions shellcheck && \
pacman -S --needed --noconfirm gtk3 python-gobject python-yaml ruff flake8 python-pylint xorg-server-xvfb mypy python-typing_extensions shellcheck && \
pacman -S --needed --noconfirm git base-devel && \
(useradd -m user && echo "user ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers || true) && \
(which pikaur || sudo -u user bash -c "\
Expand Down
21 changes: 0 additions & 21 deletions maintenance_scripts/get_global_expressions.sh

This file was deleted.

22 changes: 0 additions & 22 deletions maintenance_scripts/get_non_final_expressions.sh

This file was deleted.

Loading

0 comments on commit c8b8374

Please sign in to comment.