Magnus pushed to branch wip/mangoiv/clone-shallow-default at Glasgow Haskell Compiler / GHC

Commits:

2 changed files:

Changes:

  • .gitlab-ci.yml
    ... ... @@ -17,8 +17,7 @@ variables:
    17 17
       # Bump to invalidate GitLab CI cache.
    
    18 18
       CACHE_REV: 12
    
    19 19
     
    
    20
    -  # Disable shallow clones; they break our linting rules
    
    21
    -  GIT_DEPTH: 0
    
    20
    +  GIT_DEPTH: 1
    
    22 21
     
    
    23 22
       # Always start with a fresh clone to avoid non-hermetic builds
    
    24 23
       GIT_STRATEGY: clone
    
    ... ... @@ -267,6 +266,7 @@ ghc-linters:
    267 266
       extends: .lint-params
    
    268 267
       variables:
    
    269 268
         BUILD_FLAVOUR: default
    
    269
    +    GIT_DEPTH: 0
    
    270 270
       script:
    
    271 271
         - .gitlab/ci.sh configure
    
    272 272
         - timeout 10m .gitlab/ci.sh run_hadrian test --test-root-dirs="testsuite/tests/linters"
    
    ... ... @@ -282,7 +282,6 @@ lint-changelog:
    282 282
       extends: .lint-ghc-toolchain
    
    283 283
       variables:
    
    284 284
         CHANGELOG_EXPECT_MR: "$CI_MERGE_REQUEST_IID"
    
    285
    -    GIT_DEPTH: 1
    
    286 285
         GIT_SUBMODULE_STRATEGY: none
    
    287 286
       script:
    
    288 287
         - .gitlab/ci.sh lint_changelog
    
    ... ... @@ -297,7 +296,6 @@ lint-changelog:
    297 296
     lint-linters:
    
    298 297
       extends: .lint-python
    
    299 298
       variables:
    
    300
    -    GIT_DEPTH: 1
    
    301 299
         GIT_SUBMODULE_STRATEGY: none
    
    302 300
       script:
    
    303 301
         - mypy testsuite/tests/linters/regex-linters/*.py
    
    ... ... @@ -307,7 +305,6 @@ lint-linters:
    307 305
     lint-testsuite:
    
    308 306
       extends: .lint-ghc-toolchain
    
    309 307
       variables:
    
    310
    -    GIT_DEPTH: 1
    
    311 308
         GIT_SUBMODULE_STRATEGY: none
    
    312 309
       script:
    
    313 310
         - make -Ctestsuite list_broken TEST_HC=$(which ghc)
    
    ... ... @@ -317,7 +314,6 @@ lint-testsuite:
    317 314
     typecheck-testsuite:
    
    318 315
       extends: .lint-python
    
    319 316
       variables:
    
    320
    -    GIT_DEPTH: 1
    
    321 317
         GIT_SUBMODULE_STRATEGY: none
    
    322 318
       script:
    
    323 319
         - mypy testsuite/driver/runtests.py
    
    ... ... @@ -330,6 +326,7 @@ typecheck-testsuite:
    330 326
       extends: .lint-params
    
    331 327
       variables:
    
    332 328
         BUILD_FLAVOUR: default
    
    329
    +    GIT_DEPTH: 0
    
    333 330
         GIT_SUBMODULE_DEPTH: 0 # full history
    
    334 331
       script:
    
    335 332
         - .gitlab/ci.sh configure
    
    ... ... @@ -346,6 +343,7 @@ typecheck-testsuite:
    346 343
     lint-author:
    
    347 344
       extends: .lint-python
    
    348 345
       variables:
    
    346
    +    GIT_DEPTH: 0
    
    349 347
         GIT_SUBMODULE_STRATEGY: none
    
    350 348
       script:
    
    351 349
         - git fetch "$CI_MERGE_REQUEST_PROJECT_URL" $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
    
    ... ... @@ -362,7 +360,6 @@ lint-ci-config:
    362 360
       extends: .lint
    
    363 361
       # We don't need history/submodules in this job
    
    364 362
       variables:
    
    365
    -    GIT_DEPTH: 1
    
    366 363
         GIT_SUBMODULE_STRATEGY: none
    
    367 364
       before_script:
    
    368 365
         - echo "experimental-features = nix-command flakes" >> /etc/nix/nix.conf
    

  • testsuite/driver/perf_notes.py
    ... ... @@ -433,6 +433,12 @@ def baseline_commit_log(commit: Union[GitHash,GitRef]) -> List[GitHash]:
    433 433
     # including the input commit. The output commits are all commit hashes.
    
    434 434
     # str -> [str]
    
    435 435
     def commit_log(commitOrRange, n=None):
    
    436
    +    # default gitlab git cloning is shallow: for git perf notes we still need to be able
    
    437
    +    # to catch up on history. This unshallows the repository and fetches a blobless tree.
    
    438
    +    is_shallow = subprocess.check_output( ['git', 'rev-parse', '--is-shallow-repository']).decode().strip() == 'true'
    
    439
    +    if is_shallow:
    
    440
    +        subprocess.check_call(['git', 'fetch', '--unshallow', '--filter=blob:none', 'origin', '+refs/notes/*:refs/notes/*'])
    
    441
    +
    
    436 442
         nArgs = ['-n' + str(n)] if n != None else []
    
    437 443
         output = subprocess.check_output(['git', 'log', '--format=%H'] + nArgs + [commitOrRange]).decode()
    
    438 444
         hashes = list(filter(is_commit_hash, output.split('\n')))