mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00
Merge Use parallelism and make --touch when building in GitLab CI for faster CI times
As per https://docs.gitlab.com/ee/ci/pipelines/compute_minutes.html#gitlab-hosted-runner-cost-factors, GitLab CI computes minutes as wall clock time per stage * a constant cost factor derived from the runner type, so using parallelism in `make -j $(nproc)` will reduce the time it takes for GitLab CI to complete without increasing usage of GitLab CI minutes.
When investigating this, I also found out that the test stages needlessly rebuilt large parts of the C code base due to mtimes not being preserved when artifacts are restored from the build stage. Adding `make --touch` updates the mtimes so that the subsequent tests do not need to rebuild binaries needlessly.
The combined changes in this MR reduce the CI time from 13 minutes and 57 seconds (cb0f84e101
of `master`, https://gitlab.com/rlee287/apparmor/-/pipelines/1501017669 on my own fork without Coverity) to 12 minutes and 49 seconds (https://gitlab.com/rlee287/apparmor/-/pipelines/1502723883). This comparison omits the `make -j $(nproc)` addition to cov-build since I do not have a way of testing its effectiveness.
Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1387
Approved-by: John Johansen <john@jjmx.net>
Merged-by: John Johansen <john@jjmx.net>
This commit is contained in:
commit
8d6270e1fe
3 changed files with 19 additions and 4 deletions
|
@ -43,9 +43,9 @@ build-all:
|
||||||
- profiles/
|
- profiles/
|
||||||
script:
|
script:
|
||||||
- *install-c-build-deps
|
- *install-c-build-deps
|
||||||
- cd libraries/libapparmor && ./autogen.sh && ./configure --with-perl --with-python --prefix=/usr && make && cd ../.. || { cat config.log ; exit 1 ; }
|
- cd libraries/libapparmor && ./autogen.sh && ./configure --with-perl --with-python --prefix=/usr && make -j $(nproc) && cd ../.. || { cat config.log ; exit 1 ; }
|
||||||
- make -C parser
|
- make -C parser -j $(nproc)
|
||||||
- make -C binutils
|
- make -C binutils -j $(nproc)
|
||||||
- make -C utils
|
- make -C utils
|
||||||
- make -C changehat/mod_apparmor
|
- make -C changehat/mod_apparmor
|
||||||
- make -C changehat/pam_apparmor
|
- make -C changehat/pam_apparmor
|
||||||
|
@ -58,6 +58,8 @@ test-libapparmor:
|
||||||
- .ubuntu-before_script
|
- .ubuntu-before_script
|
||||||
script:
|
script:
|
||||||
- *install-c-build-deps
|
- *install-c-build-deps
|
||||||
|
# This is to touch the built files in the test stage to avoid needless rebuilding
|
||||||
|
- make -C libraries/libapparmor --touch
|
||||||
- make -C libraries/libapparmor check
|
- make -C libraries/libapparmor check
|
||||||
|
|
||||||
test-parser:
|
test-parser:
|
||||||
|
@ -67,6 +69,9 @@ test-parser:
|
||||||
- .ubuntu-before_script
|
- .ubuntu-before_script
|
||||||
script:
|
script:
|
||||||
- *install-c-build-deps
|
- *install-c-build-deps
|
||||||
|
# This is to touch the built files in the test stage to avoid needless rebuilding
|
||||||
|
- make -C parser --touch
|
||||||
|
- make -C parser -j $(nproc) tst_binaries
|
||||||
- make -C parser check
|
- make -C parser check
|
||||||
|
|
||||||
test-binutils:
|
test-binutils:
|
||||||
|
@ -83,6 +88,9 @@ test-utils:
|
||||||
extends:
|
extends:
|
||||||
- .ubuntu-before_script
|
- .ubuntu-before_script
|
||||||
script:
|
script:
|
||||||
|
# This is to touch the built files in the test stage to avoid needless rebuilding
|
||||||
|
- make -C utils --touch
|
||||||
|
|
||||||
- apt-get install --no-install-recommends -y libc6-dev libjs-jquery libjs-jquery-throttle-debounce libjs-jquery-isonscreen libjs-jquery-tablesorter flake8 python3-coverage python3-notify2 python3-psutil python3-setuptools python3-tk python3-ttkthemes python3-gi
|
- apt-get install --no-install-recommends -y libc6-dev libjs-jquery libjs-jquery-throttle-debounce libjs-jquery-isonscreen libjs-jquery-tablesorter flake8 python3-coverage python3-notify2 python3-psutil python3-setuptools python3-tk python3-ttkthemes python3-gi
|
||||||
|
|
||||||
# See apparmor/apparmor#221
|
# See apparmor/apparmor#221
|
||||||
|
@ -101,6 +109,8 @@ test-mod-apparmor:
|
||||||
extends:
|
extends:
|
||||||
- .ubuntu-before_script
|
- .ubuntu-before_script
|
||||||
script:
|
script:
|
||||||
|
# This is to touch the built files in the test stage to avoid needless rebuilding
|
||||||
|
- make -C changehat/mod_apparmor --touch
|
||||||
- make -C changehat/mod_apparmor check
|
- make -C changehat/mod_apparmor check
|
||||||
|
|
||||||
test-profiles:
|
test-profiles:
|
||||||
|
@ -109,6 +119,8 @@ test-profiles:
|
||||||
extends:
|
extends:
|
||||||
- .ubuntu-before_script
|
- .ubuntu-before_script
|
||||||
script:
|
script:
|
||||||
|
# This is to touch the built files in the test stage to avoid needless rebuilding
|
||||||
|
- make -C profiles --touch
|
||||||
- make -C profiles check-parser
|
- make -C profiles check-parser
|
||||||
- make -C profiles check-abstractions.d
|
- make -C profiles check-abstractions.d
|
||||||
- make -C profiles check-local
|
- make -C profiles check-local
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -59,7 +59,7 @@ coverity: snapshot
|
||||||
mv $(COVERITY_DIR)/build-log.txt $(COVERITY_DIR)/build-log-python-$(subst /,.,$(dir)).txt ;)
|
mv $(COVERITY_DIR)/build-log.txt $(COVERITY_DIR)/build-log-python-$(subst /,.,$(dir)).txt ;)
|
||||||
cov-build --dir $(COVERITY_DIR) -- sh -c \
|
cov-build --dir $(COVERITY_DIR) -- sh -c \
|
||||||
"$(foreach dir, $(filter-out utils profiles tests, $(DIRS)), \
|
"$(foreach dir, $(filter-out utils profiles tests, $(DIRS)), \
|
||||||
$(MAKE) -C $(SNAPSHOT_NAME)/$(dir);) "
|
$(MAKE) -j $$(nproc) -C $(SNAPSHOT_NAME)/$(dir);) "
|
||||||
tar -cvzf $(SNAPSHOT_NAME)-$(COVERITY_DIR).tar.gz $(COVERITY_DIR)
|
tar -cvzf $(SNAPSHOT_NAME)-$(COVERITY_DIR).tar.gz $(COVERITY_DIR)
|
||||||
|
|
||||||
.PHONY: export_dir
|
.PHONY: export_dir
|
||||||
|
|
|
@ -365,6 +365,9 @@ cap_names.h: generated_cap_names.h base_cap_names.h
|
||||||
exit 1; \
|
exit 1; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
.PHONY: tst_binaries
|
||||||
|
tst_binaries: $(TESTS)
|
||||||
|
|
||||||
tst_lib: lib.c parser.h $(filter-out lib.o, ${TEST_OBJECTS})
|
tst_lib: lib.c parser.h $(filter-out lib.o, ${TEST_OBJECTS})
|
||||||
$(CXX) $(TEST_CFLAGS) -o $@ $< $(filter-out $(<:.c=.o), ${TEST_OBJECTS}) $(TEST_LDFLAGS) $(TEST_LDLIBS)
|
$(CXX) $(TEST_CFLAGS) -o $@ $< $(filter-out $(<:.c=.o), ${TEST_OBJECTS}) $(TEST_LDFLAGS) $(TEST_LDLIBS)
|
||||||
tst_%: parser_%.c parser.h $(filter-out parser_%.o, ${TEST_OBJECTS})
|
tst_%: parser_%.c parser.h $(filter-out parser_%.o, ${TEST_OBJECTS})
|
||||||
|
|
Loading…
Add table
Reference in a new issue