Commit 5c939d80 authored by Andrei Muresan's avatar Andrei Muresan
Browse files

Added Shellcheck integration

Also did some minor pipeline optimizations to hopefully shorten average pipeline run times
parent 80240392
......@@ -17,6 +17,23 @@ lint:
script:
- apk add make clang
- ./scripts/ci-lint.sh
rules:
- changes:
- "**/*.cxx"
- "**/*.h*"
# Checks shell scripts for common errors and other gotchas
lint:shellcheck:
stage: lint
tags:
- docker-runner
image: koalaman/shellcheck-alpine
script:
- apk add make
- ./scripts/ci-shellcheck.sh
rules:
- changes:
- "scripts/*"
# Builds & publishes container image used for doc generation to the project's container registry
build:docgen_image:
......@@ -31,8 +48,9 @@ build:docgen_image:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
- docker push "$DOCGEN_IMAGE:$CI_COMMIT_REF_SLUG"
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
- changes:
- Dockerfile.docgen
- Dockerfile.docgen
# Builds & publishes VANWFTK container image the project's container registry
build:vanwftk_image:
......@@ -71,6 +89,13 @@ docs:generate:
artifacts:
paths:
- 'public'
rules:
- changes:
- "code/*"
- "docs/*"
- "**/*.md"
- "Doxyfile"
- if: '$CI_COMMIT_BRANCH == "master"'
# Publishes generated docs to GitLab Pages (only from master branch)
pages:
......@@ -83,7 +108,8 @@ pages:
artifacts:
paths:
- 'public'
dependencies:
- docs:generate
needs:
- job: "docs:generate"
artifacts: true
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
......@@ -39,6 +39,9 @@ format:
lint:
find code -name '*.cxx' -or -name '*.h*' | xargs clang-format --dry-run -Werror -ferror-limit=1
shellcheck:
find scripts -name '*.sh' | xargs shellcheck
.PHONY: docs
docs:
mkdir -p public/doxygen
......
......@@ -10,10 +10,16 @@ Refer to the [Docker](#docker) section below for instructions on setting up and
# Code Style
### C++
This project integrates with `clang-format` to ensure that the source code adheres to the [LLVM Coding Standards](https://llvm.org/docs/CodingStandards.html) for C++.
Install `clang-format` locally via Homebrew (MacOS) or your preferred package manager. Run `make lint` to detect any style errors, or just run `make format` before making a commit to let the tool automatically format your code. The CI pipeline running for every commit will reject code that does not pass the linting step, ensuring that all of the code merged to the `master` branch follows the standard style.
### Scripts
Shell scripts located under the `scripts/` directory are also linted with [Shellcheck](https://github.com/koalaman/shellcheck), which catches all kinds of mistakes that may cause unexpected issues. You may check your scripts locally using `make shellcheck` (assuming Shellcheck is installed), or via its [web client](https://www.shellcheck.net/).
# Docker
## Prerequisites
......
#!/bin/sh
make shellcheck
LINT_SUCCESS="$?"
[ "$LINT_SUCCESS" -ne 0 ] && printf "\n\nPipeline job failed: Shell scripts contain warnings/errors\n"
exit "$LINT_SUCCESS"
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