[commit: ghc] wip/check-submodules: gitlab-ci: Add linter validating that all submodules are released (6e0a518)

git at git.haskell.org git at git.haskell.org
Thu Jan 17 16:12:17 UTC 2019


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/check-submodules
Link       : http://ghc.haskell.org/trac/ghc/changeset/6e0a518d24c7c15c291e8ba69d171b6897cfe683/ghc

>---------------------------------------------------------------

commit 6e0a518d24c7c15c291e8ba69d171b6897cfe683
Author: Ben Gamari <ben at smart-cactus.org>
Date:   Thu Jan 17 11:07:30 2019 -0500

    gitlab-ci: Add linter validating that all submodules are released


>---------------------------------------------------------------

6e0a518d24c7c15c291e8ba69d171b6897cfe683
 .gitlab-ci.yml                      | 11 ++++++++
 .gitlab/linters/check-submodules.py | 54 +++++++++++++++++++++++++++++++++++++
 2 files changed, 65 insertions(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 162c19c..0fa772e 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -45,6 +45,17 @@ ghc-linters:
   tags:
     - lint
 
+check-submodules:
+  stage: lint
+  image: ghcci/linters:0.1
+  script:
+    - |
+      if [ -n "$CI_COMMIT_TAG" -a -n "$RELEASE" ]; then
+        .gitlab/linters/check-submodules
+      fi
+  tags:
+    - lint
+
 ############################################################
 # Validation via Pipelines (hadrian)
 ############################################################
diff --git a/.gitlab/linters/check-submodules.py b/.gitlab/linters/check-submodules.py
new file mode 100755
index 0000000..72862a4
--- /dev/null
+++ b/.gitlab/linters/check-submodules.py
@@ -0,0 +1,54 @@
+"""
+Ensure all submodules point to released (tagged) commits.
+"""
+
+from subprocess import run, PIPE
+import re
+
+def get_submodules():
+    p = run(['git', 'submodule'], stdout=PIPE)
+    for match in re.finditer('^.([0-9a-f]{40}) ([^ ]+) \(([^\)]+)\)',
+                             p.stdout.decode('UTF-8'), re.M):
+        commit = match.group(1)
+        submodule = match.group(2)
+        rev = match.group(3)
+        yield (commit, submodule, rev)
+
+checked_submodules = {
+    'libraries/array',
+    'libraries/binary',
+    'libraries/bytestring',
+    'libraries/Cabal',
+    'libraries/containers',
+    'libraries/deepseq',
+    'libraries/directory',
+    'libraries/filepath',
+    'libraries/haskeline',
+    'libraries/hpc',
+    'libraries/mtl',
+    'libraries/parsec',
+    'libraries/pretty',
+    'libraries/process',
+    'libraries/stm',
+    'libraries/text',
+    'libraries/terminfo',
+    'libraries/time',
+    'libraries/transformers',
+    'libraries/unix',
+    'libraries/Win32'
+}
+
+def main():
+    fail = False
+    for (commit, submodule, rev) in get_submodules():
+        if submodule in check_submodules:
+            if re.match('.*-g[0-9a-f]+', rev):
+                fail = True
+                print('Error: Submodule {submodule} points to non-released commit {commit} (rev={rev})'.format(
+                    commit=commit, submodule=submodule, rev=rev))
+
+    if fail:
+        sys.exit(1)
+
+if __name__ == "__main__":
+    main()



More information about the ghc-commits mailing list