From d0d511540c4c8fcae8ea40b0831d7c31a2823f75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tibor=20=C5=A0imko?= Date: Fri, 26 Jan 2024 10:09:32 +0100 Subject: [PATCH 1/2] ci(shellcheck): fix exit code propagation (#15) Return properly the exit code status of shellcheck command when looping through shell script files. --- run-tests.sh | 2 +- run.sh | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/run-tests.sh b/run-tests.sh index 19424f9..da182b5 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -28,7 +28,7 @@ check_commitlint () { } check_shellcheck () { - find . -name "*.sh" -exec shellcheck {} \; + find . -name "*.sh" -exec shellcheck {} \+ } check_all () { diff --git a/run.sh b/run.sh index 4c81fc6..d288303 100755 --- a/run.sh +++ b/run.sh @@ -1,4 +1,4 @@ -#/bin/zsh +#!/usr/bin/env bash # This script uses standalone Docker. Run it as follows: # @@ -8,16 +8,16 @@ # # $ root results.root - +# shellcheck disable=SC1091 source /opt/cms/cmsset_default.sh scramv1 project CMSSW CMSSW_5_3_32 -cd CMSSW_5_3_32/src -eval `scramv1 runtime -sh` +cd CMSSW_5_3_32/src || exit +eval "$(scramv1 runtime -sh)" cd ../.. mkdir reana-demo-cms-dimuon-mass-spectrum -cd reana-demo-cms-dimuon-mass-spectrum +cd reana-demo-cms-dimuon-mass-spectrum || exit mkdir DimuonSpectrum2011 -cd DimuonSpectrum2011 +cd DimuonSpectrum2011 || exit cp -a /w/* . scram b cmsRun ./demoanalyzer_cfg.py From 9ef713b430e3fa15060b2827a6a57181684eb41e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tibor=20=C5=A0imko?= Date: Fri, 26 Jan 2024 10:09:32 +0100 Subject: [PATCH 2/2] ci(commitlint): check for the presence of concrete PR number (#15) Enrich commitlint checker in order to check the precise PR number in the commit log headline. --- .github/workflows/ci.yml | 2 +- run-tests.sh | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4114fc9..e4591dc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,7 @@ jobs: - name: Check commit message compliance of the pull request if: github.event_name == 'pull_request' run: | - ./run-tests.sh --check-commitlint ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} ${{ github.event.pull_request.head.sha }} + ./run-tests.sh --check-commitlint ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} ${{ github.event.pull_request.head.sha }} ${{ github.event.pull_request.number }} lint-shellcheck: runs-on: ubuntu-20.04 diff --git a/run-tests.sh b/run-tests.sh index da182b5..d58d132 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -12,13 +12,14 @@ set -o nounset check_commitlint () { from=${2:-master} to=${3:-HEAD} + pr=${4:-[0-9]+} npx commitlint --from="$from" --to="$to" found=0 while IFS= read -r line; do - if echo "$line" | grep -qP "\(\#[0-9]+\)$"; then + if echo "$line" | grep -qP "\(\#$pr\)$"; then true else - echo "✖ PR number missing in $line" + echo "✖ Headline does not end by '(#$pr)' PR number: $line" found=1 fi done < <(git log "$from..$to" --format="%s")