chore(ci): configure linters to run locally

This commit organizes linters in scripts that are included in the
codebase, rather than configured only for Gitlab CI.

This way, the Gitlab CI configuration is simplified (it simply calls
the scripts) and they can be run locally (either manually or triggered
by git hooks: I recommend linting commit messages in the `commit-msg`
hook and everything else in the `pre-commit` hook).

Those scripts are located in `test/lint` and a handy wrapper script has
been created at the root of the project for quick manual run:

This commit also adds a neat build badge on README 
parent 73aa994e
# GitLab CI configuration file
# To run this locally (requires `gitlab-runner`):
# $ gitlab-runner exec docker <job_name>
image: docker:latest image: docker:latest
stages: stages:
...@@ -20,33 +25,26 @@ variables: ...@@ -20,33 +25,26 @@ variables:
- master - master
- branches - branches
tags: tags:
- lintstage - lintstage
lint es_input: lint config-files:
<<: *lint_definition <<: *lint_definition
script: before_script:
- apk add --update --no-cache libxml2-utils - apk add --update --no-cache libxml2-utils
- xmllint --noout --relaxng board/recalbox/fsoverlay/recalbox/scripts/es_input.rng board/recalbox/fsoverlay/recalbox/share_init/system/.emulationstation/es_input.cfg script: test/lint/config-files
lint buildroot packages: lint buildroot:
<<: *lint_definition <<: *lint_definition
image: python:2-alpine image: python:2-alpine
script: script: test/lint/buildroot
- buildroot/utils/check-package package/**/*.hash custom/package/**/*.hash
- buildroot/utils/check-package package/**/*.mk custom/package/**/*.mk lint commits:
- buildroot/utils/check-package package/**/ custom/package/**/ <<: *lint_definition
image: node:8
#lint commits: before_script:
# <<: *lint_definition - npm install -g @commitlint/cli @commitlint/config-conventional
# image: node:8 script: test/lint/commits
# script: allow_failure: true
# - npm install -g @commitlint/cli @commitlint/config-conventional
# - if [[ ${CI_COMMIT_REF_NAME} = "master" ]]; then
# commitlint --from=257ace67f316d96d0f49de8f349d06d6aa306515;
# else
# git fetch origin master;
# commitlint --from=origin/master;
# fi
# Build # Build
...@@ -24,7 +24,7 @@ Please use **Issues** in corresponding projects to report a bug or request a fea ...@@ -24,7 +24,7 @@ Please use **Issues** in corresponding projects to report a bug or request a fea
- []( recalbox forum. You will find support there. - []( recalbox forum. You will find support there.
# How to build # How to build ![Build status](
### General steps ### General steps
# This script easily runs the full test suite on developer machines
# It should be POSIX-compliant, since we cannot know on which shell it will run
set -e # Exit non-zero if any command fails
RECALBOX_ROOT=$(realpath $(dirname $(readlink -f "$0")))
echo "=== Checking Buildroot files ==="
echo "=== Checking configuration files ==="
echo "=== Checking commit messages ==="
RECALBOX_ROOT=$(realpath $(dirname $(readlink -f "$0"))/../..)
if ! [ -x ${CHECK_PACKAGE_BIN} ]; then
echo "ERROR: Buildroot submodule has probably not been checked out yet. Please do it with:"
echo " $ git submodule init"
exit 1
${RECALBOX_ROOT}/package/**/*.hash ${RECALBOX_ROOT}/custom/package/**/*.hash \
${RECALBOX_ROOT}/package/**/*.mk ${RECALBOX_ROOT}/custom/package/**/*.mk \
${RECALBOX_ROOT}/package/**/ ${RECALBOX_ROOT}/custom/package/**/
if ! which commitlint > /dev/null; then
echo "ERROR: 'commitlint' is required. Please install it, using at your convenience:"
echo " $ npm install -g @commitlint/cli @commitlint/config-conventional"
echo " $ yarn global add @commitlint/cli @commitlint/config-conventional"
exit 1
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ x${CI_COMMIT_REF_NAME} = xmaster -o x${CURRENT_BRANCH} = xmaster ]; then
commitlint --from=HEAD~5
if [ -n "${GITLAB_CI}" ]; then
git fetch -q origin master
commitlint --from=origin/master
commitlint --from=master
if ! which xmllint > /dev/null; then
echo "ERROR: 'xmllint' is required. Please install and try again."
exit 1
RECALBOX_ROOT=$(realpath $(dirname $(readlink -f "$0"))/../..)
xmllint --noout --relaxng \
${RECALBOX_ROOT}/board/recalbox/fsoverlay/recalbox/scripts/es_input.rng \
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment