@@ -317,8 +317,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- run: ci/install-dependencies.sh
- - run: ci/run-static-analysis.sh
- - run: ci/check-directional-formatting.bash
+ - run: make ci-static-analysis
sparse:
needs: ci-config
if: needs.ci-config.outputs.enabled == 'yes'
@@ -3007,6 +3007,20 @@ coccicheck: $(addsuffix .patch,$(filter-out %.pending.cocci,$(wildcard contrib/c
# See contrib/coccinelle/README
coccicheck-pending: $(addsuffix .patch,$(wildcard contrib/coccinelle/*.pending.cocci))
+.PHONY: check-coccicheck
+check-coccicheck: coccicheck
+ $(QUIET_CHECK)for cocci_patch in contrib/coccinelle/*.patch; do \
+ if test -s "$$cocci_patch"; then \
+ echo "Coccinelle suggests the following changes in '$$cocci_patch':"; \
+ cat "$$cocci_patch"; \
+ fail=UnfortunatelyYes; \
+ fi \
+ done; \
+ if test -n "$$fail"; then \
+ echo "error: Coccinelle suggested some changes"; \
+ exit 1; \
+ fi
+
.PHONY: coccicheck coccicheck-pending
### Installation rules
@@ -3442,3 +3456,17 @@ $(FUZZ_PROGRAMS): all
$(XDIFF_OBJS) $(EXTLIBS) git.o $@.o $(LIB_FUZZING_ENGINE) -o $@
fuzz-all: $(FUZZ_PROGRAMS)
+
+### CI "check" targets
+#
+# These targets are run from the CI, see .github/workflows/main.yml,
+# but can also be run manually to run the same assertions locally.
+
+.PHONY: ci-check-directional-formatting
+ci-check-directional-formatting:
+ $(QUIET_CHECK)ci/check-directional-formatting.bash
+
+.PHONY: ci-static-analysis
+ci-static-analysis: ci-check-directional-formatting
+ci-static-analysis: check-coccicheck
+ci-static-analysis: hdr-check
deleted file mode 100755
@@ -1,30 +0,0 @@
-#!/bin/sh
-#
-# Perform various static code analysis checks
-#
-
-. ${0%/*}/lib.sh
-
-make coccicheck
-
-set +x
-
-fail=
-for cocci_patch in contrib/coccinelle/*.patch
-do
- if test -s "$cocci_patch"
- then
- echo "$(tput setaf 1)Coccinelle suggests the following changes in '$cocci_patch':$(tput sgr0)"
- cat "$cocci_patch"
- fail=UnfortunatelyYes
- fi
-done
-
-if test -n "$fail"
-then
- echo "$(tput setaf 1)error: Coccinelle suggested some changes$(tput sgr0)"
- exit 1
-fi
-
-make hdr-check ||
-exit 1
@@ -68,6 +68,7 @@ ifndef V
QUIET_HDR = @echo ' ' HDR $(<:hcc=h);
QUIET_RC = @echo ' ' RC $@;
QUIET_SPATCH = @echo ' ' SPATCH $<;
+ QUIET_CHECK = @echo ' ' CHECK $@;
## Used in "Documentation/Makefile"
QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $@;
Make it easier to run the CI logic locally by creating "ci-static-analysis" target. Now the "check-coccicheck" logic added in 0860a7641ba (travis-ci: fail if Coccinelle static analysis found something to transform, 2018-07-23) can be easily tested outside of CI, and likewise the sanity check added in 0e7696c64db (ci: disallow directional formatting, 2021-11-04). These targets could be improved, the "hdr-check" target will re-do all of its work every time it's run, and could with a change similar to my c234e8a0ecf (Makefile: make the "sparse" target non-.PHONY, 2021-09-23). The same goes for the new "ci-check-directional-formatting" target. But without those improvements being able to easily run a 1=1 equivalent of the checks we do in CI during a local build is already an improvement. Subsequent commits will expand on this ability. This change will also make the CI check faster, since we can take advantage of parallelism. The "make coccicheck" takes a very long time, and at the tail end we might only have one job pegging 100% of one CPU core for a long time. Now any extra cores will be free to run the rest of the targets under "ci-static-analysis". Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> --- .github/workflows/main.yml | 3 +-- Makefile | 28 ++++++++++++++++++++++++++++ ci/run-static-analysis.sh | 30 ------------------------------ shared.mak | 1 + 4 files changed, 30 insertions(+), 32 deletions(-) delete mode 100755 ci/run-static-analysis.sh