Skip to content

Commit ecee195

Browse files
avargitster
authored andcommitted
CI: have "static-analysis" run a "make ci-static-analysis" target
Make it easier to run the CI logic locally by creating "ci-static-analysis" target. Now the "check-coccicheck" logic added in 0860a76 (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 0e7696c (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 c234e8a (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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 4704e8e commit ecee195

File tree

4 files changed

+30
-32
lines changed

4 files changed

+30
-32
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,7 @@ jobs:
317317
steps:
318318
- uses: actions/checkout@v2
319319
- run: ci/install-dependencies.sh
320-
- run: ci/run-static-analysis.sh
321-
- run: ci/check-directional-formatting.bash
320+
- run: make ci-static-analysis
322321
sparse:
323322
needs: ci-config
324323
if: needs.ci-config.outputs.enabled == 'yes'

Makefile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3013,6 +3013,20 @@ coccicheck: $(addsuffix .patch,$(filter-out %.pending.cocci,$(wildcard contrib/c
30133013
# See contrib/coccinelle/README
30143014
coccicheck-pending: $(addsuffix .patch,$(wildcard contrib/coccinelle/*.pending.cocci))
30153015

3016+
.PHONY: check-coccicheck
3017+
check-coccicheck: coccicheck
3018+
$(QUIET_CHECK)for cocci_patch in contrib/coccinelle/*.patch; do \
3019+
if test -s "$$cocci_patch"; then \
3020+
echo "Coccinelle suggests the following changes in '$$cocci_patch':"; \
3021+
cat "$$cocci_patch"; \
3022+
fail=UnfortunatelyYes; \
3023+
fi \
3024+
done; \
3025+
if test -n "$$fail"; then \
3026+
echo "error: Coccinelle suggested some changes"; \
3027+
exit 1; \
3028+
fi
3029+
30163030
.PHONY: coccicheck coccicheck-pending
30173031

30183032
### Installation rules
@@ -3448,3 +3462,17 @@ $(FUZZ_PROGRAMS): all
34483462
$(XDIFF_OBJS) $(EXTLIBS) git.o $@.o $(LIB_FUZZING_ENGINE) -o $@
34493463

34503464
fuzz-all: $(FUZZ_PROGRAMS)
3465+
3466+
### CI "check" targets
3467+
#
3468+
# These targets are run from the CI, see .github/workflows/main.yml,
3469+
# but can also be run manually to run the same assertions locally.
3470+
3471+
.PHONY: ci-check-directional-formatting
3472+
ci-check-directional-formatting:
3473+
$(QUIET_CHECK)ci/check-directional-formatting.bash
3474+
3475+
.PHONY: ci-static-analysis
3476+
ci-static-analysis: ci-check-directional-formatting
3477+
ci-static-analysis: check-coccicheck
3478+
ci-static-analysis: hdr-check

ci/run-static-analysis.sh

Lines changed: 0 additions & 30 deletions
This file was deleted.

shared.mak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ ifndef V
6868
QUIET_HDR = @echo ' ' HDR $(<:hcc=h);
6969
QUIET_RC = @echo ' ' RC $@;
7070
QUIET_SPATCH = @echo ' ' SPATCH $<;
71+
QUIET_CHECK = @echo ' ' CHECK $@;
7172

7273
## Used in "Documentation/Makefile"
7374
QUIET_ASCIIDOC = @echo ' ' ASCIIDOC $@;

0 commit comments

Comments
 (0)