mbox series

[v2,0/5] Add GitLab CI to check for whitespace errors

Message ID 20240502193840.105355-1-jltobler@gmail.com (mailing list archive)
Headers show
Series Add GitLab CI to check for whitespace errors | expand

Message

Justin Tobler May 2, 2024, 7:38 p.m. UTC
Hello again,

This is the second version of my patch series to add a GitLab CI job to
check for whitespace errors. The main differnece with this version is
that it first generalizes the existing GitHub whitespace check CI job
allowing the GitLab one to reuse it.

To validate that these changes do not break the existing GitHub CI, here
are some links to a successful run and a failed run:

- https://github.com/gitgitgadget/git/actions/runs/8929081916
- https://github.com/gitgitgadget/git/actions/runs/8928887225

To validate that these changes also work on GitLab CI, here some
additional links to a succdessful run and a failed run:

- https://gitlab.com/gitlab-org/git/-/jobs/6768304381
- https://gitlab.com/gitlab-org/git/-/jobs/6768282645

Thanks,
-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 v1:
1:  924d3eb23c = 1:  924d3eb23c ci: pre-collapse GitLab CI sections
-:  ---------- > 2:  c8d8b444dc github-ci: fix link to whitespace error
-:  ---------- > 3:  6b44b21dda ci: separate whitespace check script
-:  ---------- > 4:  87dfd1d5a9 ci: make the whitespace report optional
2:  624e68a8d2 ! 5:  175b300e91 gitlab-ci: add whitespace error check
    @@ Metadata
      ## Commit message ##
         gitlab-ci: add whitespace error check
     
    -    To check for whitespace errors introduced by a set of changes, there is
    -    the `.github/workflows/check-whitespace.yml` GitHub action. This script
    -    executes `git log --check` over a range containing the new commits and
    -    parses the output to generate a markdown formatted artifact that
    -    summarizes detected errors with GitHub links to the affected commits and
    -    blobs.
    -
    -    Since this script is rather specific to GitHub actions, a more general
    -    and simple `ci/check-whitespace.sh` is added instead that functions the
    -    same, but does not generate the markdown file for the action summary.
    -    From this, a new GitLab CI job is added to support the whitespace error
    -    check.
    +    GitLab CI does not have a job to check for whitespace errors introduced
    +    by a set of changes. Reuse the existing generic `whitespace-check.sh` to
    +    create the job for GitLab pipelines.
     
         Note that the `$CI_MERGE_REQUEST_TARGET_BRANCH_SHA` variable is only
         available in GitLab merge request pipelines and therefore the CI job is
    @@ .gitlab-ci.yml: static-analysis:
     +  before_script:
     +    - ./ci/install-docker-dependencies.sh
     +  script:
    -+    - ./ci/check-whitespace.sh $CI_MERGE_REQUEST_TARGET_BRANCH_SHA
    ++    - ./ci/check-whitespace.sh "$CI_MERGE_REQUEST_TARGET_BRANCH_SHA"
     +  rules:
     +    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
    -
    - ## ci/check-whitespace.sh (new) ##
    -@@
    -+#! /bin/sh
    -+#
    -+# Check that commits after a specified point do not contain new or modified
    -+# lines with whitespace errors.
    -+#
    -+
    -+baseSha=${1}
    -+
    -+git log --check --pretty=format:"---% h% s" ${baseSha}..
    -+if test $? -ne 0
    -+then
    -+	echo "A whitespace issue was found in one or more of the commits."
    -+	echo "Run the following command to resolve whitespace issues:"
    -+	echo "\tgit rebase --whitespace=fix ${baseSha}"
    -+	exit 2
    -+fi

Comments

Junio C Hamano May 2, 2024, 9:45 p.m. UTC | #1
Justin Tobler <jltobler@gmail.com> writes:

> This is the second version of my patch series to add a GitLab CI job to
> check for whitespace errors. The main differnece with this version is
> that it first generalizes the existing GitHub whitespace check CI job
> allowing the GitLab one to reuse it.

Will queue.  Thanks.  The extraction and reuse of a common script is
excellent.
Justin Tobler May 3, 2024, 3:39 p.m. UTC | #2
On 24/05/02 02:45PM, Junio C Hamano wrote:
> Justin Tobler <jltobler@gmail.com> writes:
> 
> > This is the second version of my patch series to add a GitLab CI job to
> > check for whitespace errors. The main differnece with this version is
> > that it first generalizes the existing GitHub whitespace check CI job
> > allowing the GitLab one to reuse it.
> 
> Will queue.  Thanks.  The extraction and reuse of a common script is
> excellent.

Thanks! I will send a V3 here shortly which makes some small suggested
edits.

-Justin