Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement target in Makefile to run github CI-like checks locally #1753

Merged
merged 2 commits into from
Jul 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 41 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand All @@ -81,17 +82,14 @@ 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:"
@echo
@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),)
Expand Down Expand Up @@ -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/ $@
Expand All @@ -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
13 changes: 7 additions & 6 deletions scripts/IronOS.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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