[Git][ghc/ghc][wip/sjakobi/T27521] ci: Reduce lint job setup costs
Simon Jakobi pushed to branch wip/sjakobi/T27521 at Glasgow Haskell Compiler / GHC Commits: 923cb5f5 by Simon Jakobi at 2026-07-22T14:52:00+02:00 ci: Reduce lint job setup costs Avoid fetching unnecessary history and submodules for lightweight lint jobs. Run changelog validation without Hadrian. Trust runner-owned checkouts so Git commands work when the container user differs from the checkout owner, e.g. in the lint-author job. Closes #27521. Assisted-by: gpt-5.6-sol via Codex CLI - - - - - 1 changed file: - .gitlab-ci.yml Changes: ===================================== .gitlab-ci.yml ===================================== @@ -134,6 +134,9 @@ workflow: stage: tool-lint tags: - lint + before_script: + # The checkout may be owned by the runner rather than the container user. + - git config --global --add safe.directory "$CI_PROJECT_DIR" rules: - *drafts-can-fail-lint - when: always @@ -251,18 +254,21 @@ ghc-linters: lint-changelog: stage: tool-lint image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb13:$DOCKER_REV" - extends: .lint-params + extends: .lint variables: - BUILD_FLAVOUR: default CHANGELOG_EXPECT_MR: "$CI_MERGE_REQUEST_IID" + GIT_DEPTH: 1 + GIT_SUBMODULE_STRATEGY: none + before_script: + - export PATH="/opt/toolchain/bin:$PATH" + - git config --global --add safe.directory "$CI_PROJECT_DIR" script: # Cancel the job if there is a no-changelog label - | [[ ",${CI_MERGE_REQUEST_LABELS}," == *",no-changelog,"* ]] && exit 0 # Check that the MR adds at least one changelog entry - - git fetch "$CI_MERGE_REQUEST_PROJECT_URL" "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" - - base="$(git merge-base FETCH_HEAD $CI_COMMIT_SHA)" - - added=$(git diff --name-only --diff-filter=A "$base..$CI_COMMIT_SHA" -- 'changelog.d/' | grep -v '^changelog.d/config$' || true) + - git fetch --depth=1 "$CI_MERGE_REQUEST_PROJECT_URL" "$CI_MERGE_REQUEST_DIFF_BASE_SHA" + - added=$(git diff --name-only --diff-filter=A "$CI_MERGE_REQUEST_DIFF_BASE_SHA..$CI_COMMIT_SHA" -- 'changelog.d/' | grep -v '^changelog.d/config$' || true) - | if [ -z "$added" ]; then echo "ERROR: No changelog entry found in changelog.d/" @@ -271,9 +277,23 @@ lint-changelog: exit 1 fi - echo "Found changelog entries:" $added - # Build changelog-d and validate all entries (checks required fields, section names, MR number) - - .gitlab/ci.sh configure - - .gitlab/ci.sh run_hadrian test --test-root-dirs="testsuite/tests/linters" --only=changelog-d + # Build changelog-d with the bootstrap compiler and validate all entries + # (checks required fields, section names, and the MR number). + - | + changelog_build_dir="$(mktemp -d)" + ghc -Werror \ + -package base \ + -package bytestring \ + -package Cabal-syntax \ + -package containers \ + -package directory \ + -package filepath \ + -package pretty \ + -outputdir "$changelog_build_dir" \ + -o "$changelog_build_dir/changelog-d" \ + utils/changelog-d/ChangelogD.hs + "$changelog_build_dir/changelog-d" \ + changelog.d/ --validate --expect-mr "$CHANGELOG_EXPECT_MR" dependencies: [] rules: - if: '$CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/' @@ -285,6 +305,9 @@ lint-changelog: lint-linters: image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" extends: .lint + variables: + GIT_DEPTH: 1 + GIT_SUBMODULE_STRATEGY: none script: - mypy testsuite/tests/linters/regex-linters/*.py dependencies: [] @@ -293,6 +316,9 @@ lint-linters: lint-testsuite: image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb13:$DOCKER_REV" extends: .lint + variables: + GIT_DEPTH: 1 + GIT_SUBMODULE_STRATEGY: none script: - make -Ctestsuite list_broken TEST_HC=$GHC dependencies: [] @@ -301,6 +327,9 @@ lint-testsuite: typecheck-testsuite: image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV" extends: .lint + variables: + GIT_DEPTH: 1 + GIT_SUBMODULE_STRATEGY: none script: - mypy testsuite/driver/runtests.py dependencies: [] @@ -323,14 +352,13 @@ typecheck-testsuite: - _build/stageBoot/bin/lint-submodule-refs . $(git rev-list $base..$CI_COMMIT_SHA) dependencies: [] -# We allow the submodule checker to fail when run on merge requests (to -# accommodate, e.g., haddock changes not yet upstream) but not on `master` or -# Marge jobs. +# Check that commits in an MR were not authored with the identity that CI uses +# when it needs to create commits itself. This only needs Git history. lint-author: image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb13:$DOCKER_REV" - extends: .lint-params + extends: .lint variables: - BUILD_FLAVOUR: default + GIT_SUBMODULE_STRATEGY: none script: - git fetch "$CI_MERGE_REQUEST_PROJECT_URL" $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - base="$(git merge-base FETCH_HEAD $CI_COMMIT_SHA)" View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/923cb5f55cad42720742b7eccfb23dc8... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/923cb5f55cad42720742b7eccfb23dc8... You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
participants (1)
-
Simon Jakobi (@sjakobi2)