Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
-
700a1dd1
by Simon Jakobi at 2026-07-23T11:21:20-04:00
3 changed files:
Changes:
| ... | ... | @@ -134,6 +134,10 @@ workflow: |
| 134 | 134 | stage: tool-lint
|
| 135 | 135 | tags:
|
| 136 | 136 | - lint
|
| 137 | + before_script:
|
|
| 138 | + # Allow Git to read from the runner-owned checkout. This is needed
|
|
| 139 | + # for example by the lint-author job.
|
|
| 140 | + - git config --global --add safe.directory "$CI_PROJECT_DIR"
|
|
| 137 | 141 | rules:
|
| 138 | 142 | - *drafts-can-fail-lint
|
| 139 | 143 | - when: always
|
| ... | ... | @@ -251,29 +255,16 @@ ghc-linters: |
| 251 | 255 | lint-changelog:
|
| 252 | 256 | stage: tool-lint
|
| 253 | 257 | image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb13:$DOCKER_REV"
|
| 254 | - extends: .lint-params
|
|
| 258 | + extends: .lint
|
|
| 255 | 259 | variables:
|
| 256 | - BUILD_FLAVOUR: default
|
|
| 257 | 260 | CHANGELOG_EXPECT_MR: "$CI_MERGE_REQUEST_IID"
|
| 261 | + GIT_DEPTH: 1
|
|
| 262 | + GIT_SUBMODULE_STRATEGY: none
|
|
| 263 | + before_script:
|
|
| 264 | + - export PATH="/opt/toolchain/bin:$PATH"
|
|
| 265 | + - git config --global --add safe.directory "$CI_PROJECT_DIR"
|
|
| 258 | 266 | script:
|
| 259 | - # Cancel the job if there is a no-changelog label
|
|
| 260 | - - |
|
|
| 261 | - [[ ",${CI_MERGE_REQUEST_LABELS}," == *",no-changelog,"* ]] && exit 0
|
|
| 262 | - # Check that the MR adds at least one changelog entry
|
|
| 263 | - - git fetch "$CI_MERGE_REQUEST_PROJECT_URL" "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME"
|
|
| 264 | - - base="$(git merge-base FETCH_HEAD $CI_COMMIT_SHA)"
|
|
| 265 | - - added=$(git diff --name-only --diff-filter=A "$base..$CI_COMMIT_SHA" -- 'changelog.d/' | grep -v '^changelog.d/config$' || true)
|
|
| 266 | - - |
|
|
| 267 | - if [ -z "$added" ]; then
|
|
| 268 | - echo "ERROR: No changelog entry found in changelog.d/"
|
|
| 269 | - echo "Please add a changelog entry file describing your user-facing changes."
|
|
| 270 | - echo "If this MR does not need a changelog entry, apply the 'no-changelog' label."
|
|
| 271 | - exit 1
|
|
| 272 | - fi
|
|
| 273 | - - echo "Found changelog entries:" $added
|
|
| 274 | - # Build changelog-d and validate all entries (checks required fields, section names, MR number)
|
|
| 275 | - - .gitlab/ci.sh configure
|
|
| 276 | - - .gitlab/ci.sh run_hadrian test --test-root-dirs="testsuite/tests/linters" --only=changelog-d
|
|
| 267 | + - .gitlab/ci.sh lint_changelog
|
|
| 277 | 268 | dependencies: []
|
| 278 | 269 | rules:
|
| 279 | 270 | - if: '$CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/'
|
| ... | ... | @@ -285,6 +276,9 @@ lint-changelog: |
| 285 | 276 | lint-linters:
|
| 286 | 277 | image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV"
|
| 287 | 278 | extends: .lint
|
| 279 | + variables:
|
|
| 280 | + GIT_DEPTH: 1
|
|
| 281 | + GIT_SUBMODULE_STRATEGY: none
|
|
| 288 | 282 | script:
|
| 289 | 283 | - mypy testsuite/tests/linters/regex-linters/*.py
|
| 290 | 284 | dependencies: []
|
| ... | ... | @@ -293,6 +287,9 @@ lint-linters: |
| 293 | 287 | lint-testsuite:
|
| 294 | 288 | image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb13:$DOCKER_REV"
|
| 295 | 289 | extends: .lint
|
| 290 | + variables:
|
|
| 291 | + GIT_DEPTH: 1
|
|
| 292 | + GIT_SUBMODULE_STRATEGY: none
|
|
| 296 | 293 | script:
|
| 297 | 294 | - make -Ctestsuite list_broken TEST_HC=$GHC
|
| 298 | 295 | dependencies: []
|
| ... | ... | @@ -301,6 +298,9 @@ lint-testsuite: |
| 301 | 298 | typecheck-testsuite:
|
| 302 | 299 | image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV"
|
| 303 | 300 | extends: .lint
|
| 301 | + variables:
|
|
| 302 | + GIT_DEPTH: 1
|
|
| 303 | + GIT_SUBMODULE_STRATEGY: none
|
|
| 304 | 304 | script:
|
| 305 | 305 | - mypy testsuite/driver/runtests.py
|
| 306 | 306 | dependencies: []
|
| ... | ... | @@ -323,14 +323,13 @@ typecheck-testsuite: |
| 323 | 323 | - _build/stageBoot/bin/lint-submodule-refs . $(git rev-list $base..$CI_COMMIT_SHA)
|
| 324 | 324 | dependencies: []
|
| 325 | 325 | |
| 326 | -# We allow the submodule checker to fail when run on merge requests (to
|
|
| 327 | -# accommodate, e.g., haddock changes not yet upstream) but not on `master` or
|
|
| 328 | -# Marge jobs.
|
|
| 326 | +# Check that commits in an MR were not authored with the identity that CI uses
|
|
| 327 | +# when it needs to create commits itself. This only needs Git history.
|
|
| 329 | 328 | lint-author:
|
| 330 | 329 | image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb13:$DOCKER_REV"
|
| 331 | - extends: .lint-params
|
|
| 330 | + extends: .lint
|
|
| 332 | 331 | variables:
|
| 333 | - BUILD_FLAVOUR: default
|
|
| 332 | + GIT_SUBMODULE_STRATEGY: none
|
|
| 334 | 333 | script:
|
| 335 | 334 | - git fetch "$CI_MERGE_REQUEST_PROJECT_URL" $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
|
| 336 | 335 | - base="$(git merge-base FETCH_HEAD $CI_COMMIT_SHA)"
|
| ... | ... | @@ -57,6 +57,7 @@ Common Modes: |
| 57 | 57 | save_cache Preserve the cabal cache
|
| 58 | 58 | build_hadrian Build GHC via the Hadrian build system
|
| 59 | 59 | test_hadrian Test GHC via the Hadrian build system
|
| 60 | + lint_changelog Check that an MR adds a valid changelog entry
|
|
| 60 | 61 | |
| 61 | 62 | Environment variables affecting the build:
|
| 62 | 63 | |
| ... | ... | @@ -971,6 +972,49 @@ function lint_author(){ |
| 971 | 972 | done
|
| 972 | 973 | }
|
| 973 | 974 | |
| 975 | +function lint_changelog() {
|
|
| 976 | + # Cancel the job if there is a no-changelog label.
|
|
| 977 | + if [[ ",${CI_MERGE_REQUEST_LABELS:-}," == *",no-changelog,"* ]]; then
|
|
| 978 | + exit 0
|
|
| 979 | + fi
|
|
| 980 | + |
|
| 981 | + # Check that the MR adds at least one changelog entry.
|
|
| 982 | + git fetch --depth=1 \
|
|
| 983 | + "$CI_MERGE_REQUEST_PROJECT_URL" \
|
|
| 984 | + "$CI_MERGE_REQUEST_DIFF_BASE_SHA"
|
|
| 985 | + |
|
| 986 | + local added
|
|
| 987 | + added=$(git diff --name-only --diff-filter=A \
|
|
| 988 | + "$CI_MERGE_REQUEST_DIFF_BASE_SHA..$CI_COMMIT_SHA" -- \
|
|
| 989 | + 'changelog.d/' | grep -v '^changelog.d/config$' || true)
|
|
| 990 | + |
|
| 991 | + if [ -z "$added" ]; then
|
|
| 992 | + error "No changelog entry found in changelog.d/"
|
|
| 993 | + echo "Please add a changelog entry file describing your user-facing changes."
|
|
| 994 | + echo "If this MR does not need a changelog entry, apply the 'no-changelog' label."
|
|
| 995 | + exit 1
|
|
| 996 | + fi
|
|
| 997 | + echo "Found changelog entries: $added"
|
|
| 998 | + |
|
| 999 | + # Build changelog-d with the bootstrap compiler and validate all entries
|
|
| 1000 | + # (checks required fields, section names, and the MR number).
|
|
| 1001 | + local changelog_build_dir
|
|
| 1002 | + changelog_build_dir="$(mktemp -d)"
|
|
| 1003 | + "$GHC" -Werror \
|
|
| 1004 | + -package base \
|
|
| 1005 | + -package bytestring \
|
|
| 1006 | + -package Cabal-syntax \
|
|
| 1007 | + -package containers \
|
|
| 1008 | + -package directory \
|
|
| 1009 | + -package filepath \
|
|
| 1010 | + -package pretty \
|
|
| 1011 | + -outputdir "$changelog_build_dir" \
|
|
| 1012 | + -o "$changelog_build_dir/changelog-d" \
|
|
| 1013 | + utils/changelog-d/ChangelogD.hs
|
|
| 1014 | + "$changelog_build_dir/changelog-d" \
|
|
| 1015 | + changelog.d/ --validate --expect-mr "$CHANGELOG_EXPECT_MR"
|
|
| 1016 | +}
|
|
| 1017 | + |
|
| 974 | 1018 | function abi_of(){
|
| 975 | 1019 | DIR=$(realpath $1)
|
| 976 | 1020 | mkdir -p "$OUT"
|
| ... | ... | @@ -1085,6 +1129,7 @@ case ${1:-help} in |
| 1085 | 1129 | perf_test) run_perf_test ;;
|
| 1086 | 1130 | abi_test) abi_test ;;
|
| 1087 | 1131 | cabal_test) cabal_test ;;
|
| 1132 | + lint_changelog) lint_changelog ;;
|
|
| 1088 | 1133 | lint_author) shift; lint_author "$@" ;;
|
| 1089 | 1134 | compare_interfaces_of) shift; compare_interfaces_of "$@" ;;
|
| 1090 | 1135 | clean) clean ;;
|
| ... | ... | @@ -89,6 +89,8 @@ checkPrograms = |
| 89 | 89 | , CheckProgram "lint:notes" noteLinterProgPath noteLinterSourcePath noteLinterExtra lintNotes (const stage0Boot) id
|
| 90 | 90 | , CheckProgram "lint:codes" codeLinterProgPath codeLinterSourcePath codeLinterExtra lintCodes id id
|
| 91 | 91 | , CheckProgram "lint:whitespace" whitespaceLinterProgPath whitespaceLinterSourcePath whitespaceLinterExtra lintWhitespace (const stage0Boot) (filter (/= lintersCommon))
|
| 92 | + -- N.B. The lint:changelog build is replicated by lint_changelog in
|
|
| 93 | + -- .gitlab/ci.sh. Keep its package dependencies in sync with this target.
|
|
| 92 | 94 | , CheckProgram "lint:changelog" changelogDProgPath changelogDSourcePath changelogDExtra changelogD (const stage0Boot) id
|
| 93 | 95 | ]
|
| 94 | 96 |