summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorIvan Zorin <[email protected]>2023-07-23 15:18:45 +0300
committerGitHub <[email protected]>2023-07-23 22:18:45 +1000
commitf83ebc8c812f84920f7709c5000144a018205899 (patch)
tree2fac5be88e729d77ea4c2d37c5ef44f982c4410a
parent65dd3e879c0856769c0d7b84b77acfa0856c0f9d (diff)
downloadIronOS-f83ebc8c812f84920f7709c5000144a018205899.tar.gz
IronOS-f83ebc8c812f84920f7709c5000144a018205899.zip
Implement target in Makefile to run github CI-like checks locally (#1753)
* Makefile: implement tests target with subtargets to run github CI-like tests locally (in docker container) * Dockerfile: update comment for PIP packages
-rw-r--r--Makefile47
-rw-r--r--scripts/IronOS.Dockerfile13
2 files changed, 48 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index 90c8f397..d7a4a0c5 100644
--- a/Makefile
+++ b/Makefile
@@ -70,6 +70,7 @@ list:
@echo " * docker-clean - delete created docker container (but not pre-downloaded data for it)"
@echo " * docs - generate \"site\"/ directory with documentation in a form of static html files using ReadTheDocs framework and $(MKDOCS_YML) local config file"
@echo " * docs-deploy - generate & deploy docs online to gh-pages branch of current github repo"
+ @echo " * tests - run set of checks, linters & tests (equivalent of github CI IronOS project settings for push trigger)"
@echo " * clean-build - delete generated files & dirs produced during builds EXCEPT generated docker container image"
@echo " * clean-full - delete generated files & dirs produced during builds INCLUDING generated docker container image"
@echo ""
@@ -81,7 +82,7 @@ list:
@echo " $$ make firmware-LANG_ID model=MODEL_ID"
@echo
@echo "Full list of current supported IDs:"
- @echo " * LANG_ID: BE BG CS DA DE EL EN ES FI FR HR HU IT JA_JP LT NB NL_BE NL PL PT RO RU SK SL SR_CYRL SR_LATN SV TR UK VI YUE_HK ZH_CN ZH_TW"
+ @echo " * LANG_ID: $(shell echo "`ls Translations/ | grep -e "^translation_.*.json$$" | sed -e 's,^translation_,,g; s,\.json$$,,g; ' | tr '\n' ' '`")"
@echo " * MODEL_ID: TS100 TS101 TS80 TS80P MHP30 Pinecil Pinecilv2 S60"
@echo
@echo "For example, to make a local build of IronOS firmware for TS100 with English language, just type:"
@@ -89,9 +90,6 @@ list:
@echo " $$ make firmware-EN model=TS100"
@echo
-# bash one-liner to generate langs for "make list":
-# echo "`ls Translations/ | grep -e "^translation_.*.json$" | sed -e 's,^translation_,,g; s,\.json$,,g; ' | tr '\n' ' '`"
-
# detect availability of docker
docker-check:
ifeq ($(DOCKER_BIN),)
@@ -121,6 +119,44 @@ docs: $(MKDOCS_YML) Documentation/* Documentation/Flashing/* Documentation/im
docs-deploy: $(MKDOCS_YML) Documentation/* Documentation/Flashing/* Documentation/images/*
$(MKDOCS) gh-deploy -f $(MKDOCS_YML) -d ../site
+# routine check for autogenerated Documentation/README.md
+test-md:
+ @echo ""
+ @echo "---- Checking REAMDE.md... ----"
+ @echo ""
+ @/bin/sh ./scripts/deploy.sh docs_readme
+
+# shell style & linter check (github CI version of shellcheck is more recent than alpine one so the latter may not catch some policies)
+test-sh:
+ @echo ""
+ @echo "---- Checking shell scripts... ----"
+ @echo ""
+ @for f in `find ./scripts -type f -iname "*.sh" ! -name "flash_ts100_linux.sh"` ; do shellcheck "$${f}"; done;
+
+# python-related tests & checks
+test-py:
+ @echo ""
+ @echo "---- Checking python code... ----"
+ @echo ""
+ flake8 Translations
+ black --check Translations
+ @make -C source/ Objects/host/brieflz/libbrieflz.so
+ ./Translations/brieflz_test.py
+ ./Translations/make_translation_test.py
+
+# clang-format check for C/C++ code style
+test-ccpp:
+ @echo ""
+ @echo "---- Checking C/C++ code... ----"
+ @echo ""
+ make -C source/ clean check-style
+
+# meta target for tests & checks based on .github/workflows/push
+tests: test-md test-sh test-py test-ccpp
+ @echo ""
+ @echo "All tests & checks have been completed successfully."
+ @echo ""
+
# pass-through target for Makefile inside source/ dir
%:
make -C source/ $@
@@ -135,5 +171,4 @@ clean-build:
clean-full: clean-build docker-clean
# phony targets
-.PHONY: help list docker-check docker-shell docker-build docker-clean docs docs-deploy clean-build clean-full
-
+.PHONY: help list docker-check docker-shell docker-build docker-clean docs docs-deploy test-md test-sh test-py test-ccpp tests clean-build clean-full
diff --git a/scripts/IronOS.Dockerfile b/scripts/IronOS.Dockerfile
index c15fb2b6..93cb5464 100644
--- a/scripts/IronOS.Dockerfile
+++ b/scripts/IronOS.Dockerfile
@@ -6,21 +6,22 @@ LABEL maintainer="Ben V. Brown <[email protected]>"
# Default current dir when container starts
WORKDIR /build/ironos
-# Installing the two compilers (ARM & RISCV), python3 & pip, clang tools:
+# Installing the two compilers (ARM & RISCV), python3 & pip, clang tools, etc.:
## - compilers: gcc-*, newlib-*
## - python3: py*, black (required to check Python code formatting)
## - misc: findutils, make, git, diffutils
## - musl-dev (required for the multi lang firmwares)
## - clang (required for clang-format to check C++ code formatting)
+## - shellcheck (to check sh scripts)
ARG APK_COMPS="gcc-riscv-none-elf gcc-arm-none-eabi newlib-riscv-none-elf \
newlib-arm-none-eabi"
ARG APK_PYTHON="python3 py3-pip black"
ARG APK_MISC="findutils make git diffutils"
-ARG APK_DEV="musl-dev clang bash clang-extra-tools"
+ARG APK_DEV="musl-dev clang bash clang-extra-tools shellcheck"
-# PIP packages
-ARG PIP_PKGS='bdflib'
+# PIP packages to check & test Python code
+ARG PIP_PKGS='bdflib flake8'
# Install system packages using alpine package manager
RUN apk add --no-cache ${APK_COMPS} ${APK_PYTHON} ${APK_MISC} ${APK_DEV}
@@ -31,5 +32,5 @@ RUN python3 -m pip install ${PIP_PKGS}
# Git trust to avoid related warning
RUN git config --global --add safe.directory /build/ironos
-COPY . /build/ironos
-COPY ./scripts/ci /build/ci
+COPY . /build/ironos
+COPY ./scripts/ci /build/ci