From ee970103652831d09c0b26af5d82a6288ec4b397 Mon Sep 17 00:00:00 2001 From: per1234 Date: Sun, 7 Sep 2025 17:08:39 -0700 Subject: [PATCH] Avoid excessive indentation in shell commands The project's GitHub Actions workflows and tasks contain complex shell command lines. With the use of the line continuation operator, these commands can be split into multiple code lines. This improves readability by providing a visualization of the command structure. It also improves maintainability by making diffs for changes to these commands more clear. The readability can be further improved by indentation of the subsequent lines of the command in a manner that visually conveys the structure. Previously, in cases where multiple commands are chained via control or list operators, the subsequent commands were indented relative to the prior command in the chain. Although this did help to visually convey the structure, it also resulted in excessive levels of indentation. It also resulted in some visual ambiguity between indentation used for arguments to a command, and that for subsequent commands in the chain. For these reasons, the determination was made to not indent the subsequent commands in the chain. The structure is communicated by placing the operator linking the commands on a dedicated line. --- .github/workflows/check-certificates.yml | 60 ++++++++++++++---------- Taskfile.yml | 14 +++--- 2 files changed, 42 insertions(+), 32 deletions(-) diff --git a/.github/workflows/check-certificates.yml b/.github/workflows/check-certificates.yml index 0428c2d65..2e48dd8d7 100644 --- a/.github/workflows/check-certificates.yml +++ b/.github/workflows/check-certificates.yml @@ -100,7 +100,9 @@ jobs: -legacy \ -noout \ -passin env:CERTIFICATE_PASSWORD - ) || ( + ) \ + || \ + ( echo "::error::Verification of ${{ matrix.certificate.identifier }} failed!!!" exit 1 ) @@ -124,39 +126,45 @@ jobs: run: | if [[ ${{ matrix.certificate.type }} == "pkcs12" ]]; then EXPIRATION_DATE="$( - ( + ( openssl pkcs12 \ - -in ${{ env.CERTIFICATE_PATH }} \ - -clcerts \ - -legacy \ - -nodes \ - -passin env:CERTIFICATE_PASSWORD - ) | ( + -in ${{ env.CERTIFICATE_PATH }} \ + -clcerts \ + -legacy \ + -nodes \ + -passin env:CERTIFICATE_PASSWORD + ) \ + | \ + ( openssl x509 \ - -noout \ - -enddate - ) | ( + -noout \ + -enddate + ) \ + | \ + ( grep \ - --max-count=1 \ - --only-matching \ - --perl-regexp \ - 'notAfter=(\K.*)' - ) + --max-count=1 \ + --only-matching \ + --perl-regexp \ + 'notAfter=(\K.*)' + ) )" elif [[ ${{ matrix.certificate.type }} == "x509" ]]; then EXPIRATION_DATE="$( - ( + ( openssl x509 \ - -in ${{ env.CERTIFICATE_PATH }} \ - -noout \ - -enddate - ) | ( + -in ${{ env.CERTIFICATE_PATH }} \ + -noout \ + -enddate + ) \ + | \ + ( grep \ - --max-count=1 \ - --only-matching \ - --perl-regexp \ - 'notAfter=(\K.*)' - ) + --max-count=1 \ + --only-matching \ + --perl-regexp \ + 'notAfter=(\K.*)' + ) )" fi diff --git a/Taskfile.yml b/Taskfile.yml index fcd6d7b1e..13c213035 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -12,9 +12,11 @@ vars: DEFAULT_GO_MODULE_PATH: ./ DEFAULT_GO_PACKAGES: | $( \ - go list ./... | \ - grep --invert-match 'github.com/arduino/arduino-lint/internal/rule/schema/schemadata' | \ - tr '\n' ' ' \ + go list ./... \ + | \ + grep --invert-match 'github.com/arduino/arduino-lint/internal/rule/schema/schemadata' \ + | \ + tr '\n' ' ' \ || \ echo '"ERROR: Unable to discover Go packages"' \ ) @@ -589,9 +591,9 @@ tasks: cmds: - | if [[ "{{.OS}}" == "Windows_NT" ]] && which cygpath &>/dev/null; then - # Even though the shell handles POSIX format absolute paths as expected, external applications do not. - # So paths passed to such applications must first be converted to Windows format. - cygpath -w "{{.RAW_PATH}}" + # Even though the shell handles POSIX format absolute paths as expected, external applications do not. + # So paths passed to such applications must first be converted to Windows format. + cygpath -w "{{.RAW_PATH}}" else echo "{{.RAW_PATH}}" fi