Browse Source

Add a Gitlab job for verifying the Bash formatting

This is done using [shfmt](https://github.com/mvdan/sh), with the following
settings:

* Bash syntax
* 4 spaces indentation
* Require indented switch statements
* Keep column alignment padding
* Allow binary operators to start on a new line

Changelog: None
Signed-off-by: Ole Petter <ole.orhagen@northern.tech>
2.4.x
Ole Petter 4 years ago
parent
commit
49dbcf3877
No known key found for this signature in database GPG Key ID: A7100375167A7B21
  1. 47
      .gitlab-ci.yml

47
.gitlab-ci.yml

@ -52,6 +52,53 @@ build:
paths:
- image.tar
test:format:
stage: test
needs: []
image: alpine:3.13
before_script:
- apk update
- apk upgrade
- apk add --update bash git shfmt
- shfmt -version
script:
- /bin/bash
- SCRIPTS=$(find modules configs scripts -type f
-not -name "*.md"
-not -wholename "scripts/test/*")
# shfmt
## Language=Bash
# -ln bash
## Indent=4 spaces
# -i 4
## List files who differ in formatting
# -l
## Redirect operators should be followed by a space
# -sr
## Indent switch statements
# -ci
## Keep column alignment padding
# -kp
## Binary operators like &&, || may start a new line
# -bn
## Overwrite the source files
# -w
- |
shfmt \
-ln bash \
-i 4 \
-l \
-sr \
-ci \
-kp \
-bn \
-w \
${SCRIPTS}
# Print diff
- git diff HEAD
# Actual test: exits with non zero status if diff
- git diff-index --quiet HEAD
.template_convert_raspbian: &convert_raspbian
stage: convert
needs:

Loading…
Cancel
Save