Merge branch 'style' into 'master'
ci: style enforcement See merge request World/Phosh/squeekboard!506
This commit is contained in:
@ -42,14 +42,16 @@ build_deb:
|
|||||||
stage: build
|
stage: build
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- "*.deb"
|
- '*.deb'
|
||||||
script:
|
script:
|
||||||
- rm -f ../*.deb
|
- rm -f ../*.deb
|
||||||
- apt-get -y build-dep .
|
- apt-get -y build-dep .
|
||||||
- apt-get -y install devscripts
|
- apt-get -y install devscripts
|
||||||
- REV=$(git log -1 --format=%h)
|
- REV=$(git log -1 --format=%h)
|
||||||
- VER=$(dpkg-parsechangelog -SVersion)
|
- VER=$(dpkg-parsechangelog -SVersion)
|
||||||
- 'DEBFULLNAME="Librem5 CI" EMAIL="librem5-builds@lists.community.puri.sm" dch -v"$VER+librem5ci$CI_PIPELINE_ID.$REV" "$MSG"'
|
- DEBFULLNAME="Librem5 CI"
|
||||||
|
- EMAIL="librem5-builds@lists.community.puri.sm"
|
||||||
|
- dch -v"$VER+librem5ci$CI_PIPELINE_ID.$REV" "$MSG"
|
||||||
- debuild -i -us -uc -b
|
- debuild -i -us -uc -b
|
||||||
- cp ../*.deb .
|
- cp ../*.deb .
|
||||||
|
|
||||||
@ -59,14 +61,16 @@ build_deb:arm64:
|
|||||||
stage: build
|
stage: build
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- "*.deb"
|
- '*.deb'
|
||||||
script:
|
script:
|
||||||
- rm -f ../*.deb
|
- rm -f ../*.deb
|
||||||
- apt-get -y build-dep .
|
- apt-get -y build-dep .
|
||||||
- apt-get -y install devscripts
|
- apt-get -y install devscripts
|
||||||
- REV=$(git log -1 --format=%h)
|
- REV=$(git log -1 --format=%h)
|
||||||
- VER=$(dpkg-parsechangelog -SVersion)
|
- VER=$(dpkg-parsechangelog -SVersion)
|
||||||
- 'DEBFULLNAME="Librem5 CI" EMAIL="librem5-builds@lists.community.puri.sm" dch -v"$VER+librem5ci$CI_PIPELINE_ID.$REV" "$MSG"'
|
- DEBFULLNAME="Librem5 CI"
|
||||||
|
- EMAIL="librem5-builds@lists.community.puri.sm"
|
||||||
|
- dch -v"$VER+librem5ci$CI_PIPELINE_ID.$REV" "$MSG"
|
||||||
- debuild -i -us -uc -b
|
- debuild -i -us -uc -b
|
||||||
- cp ../*.deb .
|
- cp ../*.deb .
|
||||||
|
|
||||||
@ -89,7 +93,17 @@ test:
|
|||||||
- apt-get -y build-dep .
|
- apt-get -y build-dep .
|
||||||
- apt-get -y install clang-tidy
|
- apt-get -y install clang-tidy
|
||||||
- ninja -C _build test
|
- ninja -C _build test
|
||||||
- tools/style-check _build
|
- tools/style-check_build _build
|
||||||
|
except:
|
||||||
|
variables:
|
||||||
|
- $PKG_ONLY == "1"
|
||||||
|
|
||||||
|
test_style:
|
||||||
|
stage: test
|
||||||
|
needs: []
|
||||||
|
script:
|
||||||
|
- apt-get -y build-dep .
|
||||||
|
- tools/style-check_source
|
||||||
except:
|
except:
|
||||||
variables:
|
variables:
|
||||||
- $PKG_ONLY == "1"
|
- $PKG_ONLY == "1"
|
||||||
|
|||||||
1
debian/control
vendored
1
debian/control
vendored
@ -27,6 +27,7 @@ Build-Depends:
|
|||||||
libwayland-dev (>= 1.16),
|
libwayland-dev (>= 1.16),
|
||||||
lsb-release,
|
lsb-release,
|
||||||
python3,
|
python3,
|
||||||
|
python3-ruamel.yaml,
|
||||||
rustc,
|
rustc,
|
||||||
wayland-protocols (>= 1.14),
|
wayland-protocols (>= 1.14),
|
||||||
Standards-Version: 4.1.3
|
Standards-Version: 4.1.3
|
||||||
|
|||||||
@ -120,6 +120,16 @@ User interface modules should:
|
|||||||
|
|
||||||
### Style
|
### Style
|
||||||
|
|
||||||
|
Note that some portions, like the .gitlab-ci.yml file have accummulated enough style/whitespace conflicts that an enforced style checker is now applied.
|
||||||
|
|
||||||
|
To fix your contributions before submitting a change, use:
|
||||||
|
|
||||||
|
```
|
||||||
|
./tools/style-check_source --apply
|
||||||
|
```
|
||||||
|
|
||||||
|
* * *
|
||||||
|
|
||||||
Code submitted should roughly match the style of surrounding code. Things that will *not* be accepted are ones that often lead to errors:
|
Code submitted should roughly match the style of surrounding code. Things that will *not* be accepted are ones that often lead to errors:
|
||||||
|
|
||||||
- skipping brackets `{}` after every `if()`, `else`, and similar ([SCI CERT C: EXP19-C](https://wiki.sei.cmu.edu/confluence/display/c/EXP19-C.+Use+braces+for+the+body+of+an+if%2C+for%2C+or+while+statement))
|
- skipping brackets `{}` after every `if()`, `else`, and similar ([SCI CERT C: EXP19-C](https://wiki.sei.cmu.edu/confluence/display/c/EXP19-C.+Use+braces+for+the+body+of+an+if%2C+for%2C+or+while+statement))
|
||||||
|
|||||||
@ -1,13 +1,15 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Enforces style check for the C parts of the project.
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
echo "Please pass directory to check."
|
echo "Please pass build directory to check."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd "$1"
|
cd "$1"
|
||||||
|
|
||||||
clang-tidy --checks=-clang-diagnostic-missing-braces,readability-braces-around-statements, \
|
clang-tidy --checks=-clang-diagnostic-missing-braces,readability-braces-around-statements, \
|
||||||
--warnings-as-errors=readability-braces-around-statements \
|
--warnings-as-errors=readability-braces-around-statements \
|
||||||
-extra-arg=-Wno-unknown-warning-option \
|
-extra-arg=-Wno-unknown-warning-option \
|
||||||
../src/*.c ../eek/*.c ../eekboard/*.c
|
../src/*.c ../eek/*.c ../eekboard/*.c
|
||||||
|
|
||||||
12
tools/style-check_source
Executable file
12
tools/style-check_source
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Enforces style check for the project.
|
||||||
|
THIS=$(realpath $0)
|
||||||
|
TOOLS=$(dirname $THIS)
|
||||||
|
cd $TOOLS/..
|
||||||
|
|
||||||
|
# The CI file seems to be touched regularly, and causing problems often,
|
||||||
|
# unlike layout files.
|
||||||
|
./tools/yamlfmt ./.gitlab-ci.yml $1
|
||||||
36
tools/yamlfmt
Executable file
36
tools/yamlfmt
Executable file
@ -0,0 +1,36 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
"""Checks YAML files for correct formatting.
|
||||||
|
Usage: yamlfmt.py [--apply] file.yaml
|
||||||
|
"""
|
||||||
|
|
||||||
|
import ruamel.yaml
|
||||||
|
import sys
|
||||||
|
|
||||||
|
args = sys.argv[:]
|
||||||
|
try:
|
||||||
|
args.remove('--apply')
|
||||||
|
want_apply = True
|
||||||
|
except ValueError:
|
||||||
|
want_apply = False
|
||||||
|
|
||||||
|
path = args[1]
|
||||||
|
|
||||||
|
with open(path) as f:
|
||||||
|
contents = f.read()
|
||||||
|
yml = ruamel.yaml.round_trip_load(contents)
|
||||||
|
formatted = ruamel.yaml.round_trip_dump(yml, block_seq_indent=2)
|
||||||
|
well_formatted = formatted == contents
|
||||||
|
|
||||||
|
if not well_formatted:
|
||||||
|
print('The yaml file is not correctly formatted:', path)
|
||||||
|
if want_apply:
|
||||||
|
print('Correcting', path)
|
||||||
|
with open(path, 'w') as f:
|
||||||
|
f.write(formatted)
|
||||||
|
else:
|
||||||
|
print('Please use the following correction:')
|
||||||
|
print('----------corrected', path)
|
||||||
|
print(formatted)
|
||||||
|
print('----------end corrected', path)
|
||||||
|
sys.exit(1)
|
||||||
Reference in New Issue
Block a user