mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
Fix checking C code formatting
Apparently, scripts/validate-c is not working in CI (or maybe
maintainers ignored the failures from it) -- current C code
gets some changes if we run indent on it.
This commit fixes this, simplifying things along the way.
In particular:
1. Remove "validate" make target, add "cfmt" target that just runs
indent on all *.c files in the repository (NOTE that *.h files
are not included, as before).
This may help a contributor to fix their code -- they just need
to run "make cfmt" now instead of running "make validate" and
copy-pasting the indent command and options from the hint.
2. Split GHA validate/misc into validate/release and validate/cfmt.
The latter checks that the sources are not changed after "make cfmt".
3. Adds a few more options to indent. This was mostly motivated by
trying to save the existing formatting, minimizing the amount of
changes indent produces.
The new options are:
* -il0: sets the offset for goto labels to 0 (currently all labels
but one are not indented -- let's keep it that way);
* -ppi2: sets the indentation for nested preprocessor directives
to 2 spaces (same as it is done in "SYS_memfd_create" defines);
* -cp1: sets the indentation between #else / #endif and the
following comment to 1 space.
4. Reformat the code using the new indent options.
5. Remove the now-unused script/{.validate,validate-c}.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -126,7 +126,7 @@ jobs:
|
||||
run: make cross
|
||||
|
||||
|
||||
misc:
|
||||
cfmt:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: checkout
|
||||
@@ -136,8 +136,23 @@ jobs:
|
||||
- name: install deps
|
||||
run: |
|
||||
sudo apt -qq update
|
||||
sudo apt -qq install libseccomp-dev indent
|
||||
- name: make validate
|
||||
run: make validate
|
||||
sudo apt -qq install indent
|
||||
- name: cfmt
|
||||
run: |
|
||||
make cfmt
|
||||
git diff --exit-code
|
||||
|
||||
|
||||
release:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: install deps
|
||||
run: |
|
||||
sudo apt -qq update
|
||||
sudo apt -qq install libseccomp-dev
|
||||
- name: make release
|
||||
run: make release
|
||||
|
||||
Reference in New Issue
Block a user