]> git.ipfire.org Git - thirdparty/git.git/commit
ci: run style check on GitHub and GitLab
authorKarthik Nayak <karthik.188@gmail.com>
Tue, 23 Jul 2024 08:21:09 +0000 (10:21 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 23 Jul 2024 16:56:50 +0000 (09:56 -0700)
commitbce7e52d4e70a8d8d824596654bac85545bf9d07
treef45ec1a91a1421884596ef6c4dbfb0d2e94ace71
parent1993918b9fe13cde1a2eaaba07cb6d0c96134373
ci: run style check on GitHub and GitLab

We don't run style checks on our CI, even though we have a
'.clang-format' setup in the repository. Let's add one, the job will
validate only against the new commits added and will only run on merge
requests. Since we're introducing it for the first time, let's allow
this job to fail, so we can validate if this is useful and eventually
enforce it.

For GitHub, we allow the job to pass by adding 'continue-on-error: true'
to the workflow. This means the job would show as passed, even if the
style check failed. To know the status of the job, users have to
manually check the logs.

For GitLab, we allow the job to pass by adding 'allow_failure: true', to
the job. Unlike GitHub, here the job will show as failed with a yellow
warning symbol, but the pipeline would still show as passed.

Also for GitLab, we use the 'CI_MERGE_REQUEST_TARGET_BRANCH_SHA'
variable by default to obtain the base SHA of the merged pipeline (which
is only available for merged pipelines [1]). Otherwise we use the
'CI_MERGE_REQUEST_DIFF_BASE_SHA' variable.

[1]: https://docs.gitlab.com/ee/ci/variables/predefined_variables.html#predefined-variables-for-merge-request-pipelines

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
.github/workflows/check-style.yml [new file with mode: 0644]
.gitlab-ci.yml
ci/install-dependencies.sh
ci/run-style-check.sh [new file with mode: 0755]