gitlab-ci: Ensure that all commits on a branch are submodule-linted
authorBen Gamari <ben@smart-cactus.org>
Sat, 8 Jun 2019 20:44:55 +0000 (16:44 -0400)
committerBen Gamari <ben@smart-cactus.org>
Sat, 8 Jun 2019 20:44:55 +0000 (16:44 -0400)
The previous commit reworked things such that the submodule linter would
only run on the head commit. However, the linter only checks the
submodules which are touched by the commits it is asked to lint.
Consequently it would be possible for a bad submodule to sneak through.

Thankfully, we can use the handy CI_COMMIT_BEFORE_SHA attribute to
find the base commit of the push.

.gitlab-ci.yml

index 570ea48..e8a5a28 100644 (file)
@@ -108,8 +108,8 @@ lint-submods-mr:
 lint-submods-branch:
   extends: .lint-submods
   script:
-    - "echo Linting submodule changes for $CI_COMMIT_SHA"
-    - submodchecker .git $CI_COMMIT_SHA
+    - "echo Linting submodule changes between $CI_COMMIT_BEFORE_SHA..$CI_COMMIT_SHA"
+    - submodchecker .git $(git rev-list $CI_COMMIT_BEFORE_SHA..$CI_COMMIT_SHA)
   only:
     refs:
       - master