From f617e36639923701034d38eaf36eafecbf0af279 Mon Sep 17 00:00:00 2001 From: Jason Naylor Date: Tue, 26 Mar 2024 15:05:04 -0700 Subject: [PATCH] Add CI check for whitespace (calling the git workflow for it) Change-Id: I8e6678c9917ae5ef11fa790c9880f72bbc93a5c1 --- .github/workflows/whitespace.yml | 76 ++++++++++++++++++++++++ Src/AssemblyInfoForUiIndependentTests.cs | 2 +- 2 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/whitespace.yml diff --git a/.github/workflows/whitespace.yml b/.github/workflows/whitespace.yml new file mode 100644 index 0000000000..df66dd2fbd --- /dev/null +++ b/.github/workflows/whitespace.yml @@ -0,0 +1,76 @@ +name: check-whitespace + +on: + pull_request: + types: [opened, synchronize] + +# Avoid unnecessary builds +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + check-whitespace: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: git log --check + id: check_out + run: | + baseSha=${{ github.event.pull_request.base.sha }} + problems=() + commit= + commitText= + commitTextmd= + + # Store the output of git log in a variable + log_output=$(git log --check --pretty=format:"---% h% s" ${baseSha}..) + + # Use a for loop to iterate over lines of log_output + IFS=$'\n' + for line in $log_output; do + case "${line}" in + "--- "*) + commit="${line#--- }" + commitText="${commit}" + commitTextmd="[${commit}](https://github.com/${{ github.repository }}/commit/${commit})" + ;; + "") + ;; + *) + if test -n "${commit}"; then + problems+=("1) --- ${commitTextmd}") + echo "" + echo "--- ${commitText}" + commit= + fi + case "${line}" in + *:[1-9]*:) # contains file and line number information + dash=${line%%:*} + dashend=${line#*:} + dashend=${dashend%:*} + problems+=("[${line}](https://github.com/${{ github.repository }}/blob/${{github.event.pull_request.head.ref}}/${dash}#L${dashend}) ${commit}") + ;; + *) + problems+=("\`${line}\`") + ;; + esac + echo "${line}" + ;; + esac + done + + if test ${#problems[*]} -gt 0; then + echo "⚠️ Please review the Summary output for further information." + echo "### :x: A whitespace issue was found in one or more of the commits." >$GITHUB_STEP_SUMMARY + echo "" >>$GITHUB_STEP_SUMMARY + echo "Errors:" >>$GITHUB_STEP_SUMMARY + for i in "${problems[@]}"; do + echo "${i}" >>$GITHUB_STEP_SUMMARY + done + + exit 2 + fi diff --git a/Src/AssemblyInfoForUiIndependentTests.cs b/Src/AssemblyInfoForUiIndependentTests.cs index e827eb58a9..4714c389e3 100644 --- a/Src/AssemblyInfoForUiIndependentTests.cs +++ b/Src/AssemblyInfoForUiIndependentTests.cs @@ -11,7 +11,7 @@ // reference System.Windows.Forms et al. // Cleanup all singletons after running tests -[assembly: CleanupSingletons] +[assembly: CleanupSingletons] // Redirect HKCU if environment variable BUILDAGENT_SUBKEY is set [assembly: RedirectHKCU]