Skip to content

Add GitLab CI to check for whitespace errors

Justin Tobler git 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest5 patches 7 repliesIn review
  2. v25 patches 10 repliesSuperseded
  3. v12 patches 10 repliesSuperseded

Changes in v3 from the cover letter

- In 35e293e6 (Merge branch 'ps/ci-test-with-jgit' into next, 2024-05-01), install-docker-dependencies.sh script was merged into install-dependencies.sh and removed. Thus this patch series now depends on that change and is updated to use the other script.
- Changed the shebang to "#!/usr/bin/env bash".
- Made the argument count validation more strict.
- Fixed a typo.

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5ci: pre-collapse GitLab CI sectionsci/lib.sh+1 -10 replies
2/5github-ci: fix link to whitespace error.github/workflows/check-whitespace.yml+12 -110 replies
3/5ci: separate whitespace check script.github/workflows/check-whitespace.yml ci/check-whitespace.sh+78 -640 replies
4/5ci: make the whitespace report optionalci/check-whitespace.sh+33 -120 replies
5/5gitlab-ci: add whitespace error check.gitlab-ci.yml+9 -07 replies

Reviews trailers per patch

None of the 5 patches has a Reviewed-by or Acked-by.

PatchPatrick Steinhardt
1/5
2/5
3/5Helped-by
4/5
5/5

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/5] Add GitLab CI to check for whitespace errors

Hello again,

This is the third version of my patch series to add a GitLab CI job to check for whitespace errors.

Changes since V2:

- In 35e293e6 (Merge branch 'ps/ci-test-with-jgit' into next, 2024-05-01), install-docker-dependencies.sh script was merged into install-dependencies.sh and removed. Thus this patch series now depends on that change and is updated to use the other script.
- Changed the shebang to "#!/usr/bin/env bash".
- Made the argument count validation more strict.
- Fixed a typo.

GitHub CI:

- https://github.com/gitgitgadget/git/actions/runs/8941666020?pr=1727
- https://github.com/gitgitgadget/git/actions/runs/8941721282?pr=1727

GitLab CI:

- https://gitlab.com/gitlab-org/git/-/jobs/6776032414
- https://gitlab.com/gitlab-org/git/-/jobs/6776038234

Thanks for the reviews,
-Justin

Justin Tobler (5):
ci: pre-collapse GitLab CI sections
github-ci: fix link to whitespace error
ci: separate whitespace check script
ci: make the whitespace report optional
gitlab-ci: add whitespace error check

 .github/workflows/check-whitespace.yml | 67 ++----------------
 .gitlab-ci.yml                         |  9 +++
 ci/check-whitespace.sh                 | 95 ++++++++++++++++++++++++++
 ci/lib.sh                              |  2 +-
 4 files changed, 109 insertions(+), 64 deletions(-)
 create mode 100755 ci/check-whitespace.sh

Range-diff against v2:

1:  924d3eb23c = 1:  924d3eb23c ci: pre-collapse GitLab CI sections
2:  c8d8b444dc = 2:  c8d8b444dc github-ci: fix link to whitespace error
3:  6b44b21dda ! 3:  933e0c33f9 ci: separate whitespace check script
    @@ .github/workflows/check-whitespace.yml: jobs:
     
      ## ci/check-whitespace.sh (new) ##
     @@
    -+#!/bin/bash
    ++#!/usr/bin/env bash
     +
     +baseCommit=$1
     +outputFile=$2

4: 87dfd1d5a9 ! 4: 374735c60f ci: make the whitespace report optional
@@ Commit message

## ci/check-whitespace.sh ##
@@
- #!/bin/bash
+ #!/usr/bin/env bash
+#
+# Check that commits after a specified point do not contain new or modified +# lines with whitespace errors. An optional formatted summary can be generated
@@ ci/check-whitespace.sh
outputFile=$2
url=$3

-+if test "$#" -eq 0 || test "$#" -gt 3
++if test "$#" -ne 1 && test "$#" -ne 3
+then
+ echo "USAGE: $0 <BASE_COMMIT> [<OUTPUT_FILE> <URL>]"
+ exit 1
@@ ci/check-whitespace.sh: then
+ echo "Run the following command to resolve whitespace issues:"
+ echo "git rebase --whitespace=fix ${goodParent}"
+
-+ # If target output file is provided, write formatted ouput.
++ # If target output file is provided, write formatted output.
+ if test -n "$outputFile"
+ then
+ echo "🛑 Please review the Summary output for further information."
5: 175b300e91 ! 5: a7deaeadc7 gitlab-ci: add whitespace error check
@@ .gitlab-ci.yml: static-analysis:
+check-whitespace:
+ image: ubuntu:latest
+ before_script:
-+ - ./ci/install-docker-dependencies.sh
++ - ./ci/install-dependencies.sh
+ script:
+ - ./ci/check-whitespace.sh "$CI_MERGE_REQUEST_TARGET_BRANCH_SHA"
+ rules:

Signature · 1 line
2.45.0