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:
`run_linters`.

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
stages:
......@@ -22,31 +27,24 @@ variables:
tags:
- lintstage
lint es_input:
lint config-files:
<<: *lint_definition
script:
before_script:
- 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
image: python:2-alpine
script:
- buildroot/utils/check-package package/**/*.hash custom/package/**/*.hash
- buildroot/utils/check-package package/**/*.mk custom/package/**/*.mk
- buildroot/utils/check-package package/**/Config.in custom/package/**/Config.in
#lint commits:
# <<: *lint_definition
# image: node:8
# script:
# - 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
script: test/lint/buildroot
lint commits:
<<: *lint_definition
image: node:8
before_script:
- npm install -g @commitlint/cli @commitlint/config-conventional
script: test/lint/commits
allow_failure: true
# Build
......
......@@ -24,7 +24,7 @@ Please use **Issues** in corresponding projects to report a bug or request a fea
- [forum.recalbox.com](https://forum.recalbox.com): recalbox forum. You will find support there.
# How to build
# How to build ![Build status](https://gitlab.com/recalbox/recalbox/badges/master/pipeline.svg?style=flat-square)
### General steps
......
#!/bin/sh
# 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 ==="
${RECALBOX_ROOT}/test/lint/buildroot
echo "=== Checking configuration files ==="
${RECALBOX_ROOT}/test/lint/config-files
echo "=== Checking commit messages ==="
${RECALBOX_ROOT}/test/lint/commits
#!/bin/sh
RECALBOX_ROOT=$(realpath $(dirname $(readlink -f "$0"))/../..)
CHECK_PACKAGE_BIN=${RECALBOX_ROOT}/buildroot/utils/check-package
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
fi
${CHECK_PACKAGE_BIN} \
${RECALBOX_ROOT}/package/**/*.hash ${RECALBOX_ROOT}/custom/package/**/*.hash \
${RECALBOX_ROOT}/package/**/*.mk ${RECALBOX_ROOT}/custom/package/**/*.mk \
${RECALBOX_ROOT}/package/**/Config.in ${RECALBOX_ROOT}/custom/package/**/Config.in
#!/bin/sh
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
fi
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
else
if [ -n "${GITLAB_CI}" ]; then
git fetch -q origin master
commitlint --from=origin/master
else
commitlint --from=master
fi
fi
#!/bin/sh
if ! which xmllint > /dev/null; then
echo "ERROR: 'xmllint' is required. Please install and try again."
exit 1
fi
RECALBOX_ROOT=$(realpath $(dirname $(readlink -f "$0"))/../..)
xmllint --noout --relaxng \
${RECALBOX_ROOT}/board/recalbox/fsoverlay/recalbox/scripts/es_input.rng \
${RECALBOX_ROOT}/board/recalbox/fsoverlay/recalbox/share_init/system/.emulationstation/es_input.cfg
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