Skip to content

Commit

Permalink
fix: don't print empty lines with default logging (#5238)
Browse files Browse the repository at this point in the history
- Check if Stdout and Stderr have elements before printing them.
- Run the super-linter action in a dedicated step using default logging to
  inspect how the output looks during CI.
  • Loading branch information
ferrarimarco committed Feb 5, 2024
1 parent d7790e4 commit 20ded71
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
${{ env.CONTAINER_IMAGE_ID }}
target: "${{ matrix.images.target }}"

- name: Test Local Action
- name: Test Local Action (debug log)
uses: ./
env:
ACTIONS_RUNNER_DEBUG: true
Expand All @@ -120,6 +120,16 @@ jobs:
sudo cat super-linter.log
sudo rm -v super-linter.log
- name: Test Local Action (default log)
uses: ./
env:
VALIDATE_ALL_CODEBASE: false
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEFAULT_BRANCH: main
GITLEAKS_CONFIG_FILE: .gitleaks-ignore-tests.toml
FILTER_REGEX_EXCLUDE: ".*(/test/linters/|CHANGELOG.md).*"
TYPESCRIPT_STANDARD_TSCONFIG_FILE: ".github/linters/tsconfig.json"

- name: Run Test Suite
run: make test

Expand Down
4 changes: 2 additions & 2 deletions lib/functions/buildFileList.sh
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ function BuildFileList() {

local STDOUT_BUILD_FILE_LIST
# Get raw output so we can strip quotes from the data we load
if ! STDOUT_BUILD_FILE_LIST="$(jq --raw-output '.[].Stdout[:-1]' <<<"${RESULTS_OBJECT}")"; then
if ! STDOUT_BUILD_FILE_LIST="$(jq --raw-output '.[] | select(.Stdout[:-1] | length > 0) | .Stdout[:-1]' <<<"${RESULTS_OBJECT}")"; then
fatal "Error when loading stdout when building the file list: ${STDOUT_BUILD_FILE_LIST}"
fi

Expand All @@ -168,7 +168,7 @@ function BuildFileList() {
fi

local STDERR_BUILD_FILE_LIST
if ! STDERR_BUILD_FILE_LIST="$(jq --raw-output '.[].Stderr[:-1]' <<<"${RESULTS_OBJECT}")"; then
if ! STDERR_BUILD_FILE_LIST="$(jq --raw-output '.[] | select(.Stderr[:-1] | length > 0) | .Stderr[:-1]' <<<"${RESULTS_OBJECT}")"; then
fatal "Error when loading stderr when building the file list:\n${STDERR_BUILD_FILE_LIST}"
fi

Expand Down
4 changes: 2 additions & 2 deletions lib/functions/worker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ function LintCodebase() {

local STDOUT_LINTER
# Get raw output so we can strip quotes from the data we load. Also, strip the final newline to avoid adding it two times
if ! STDOUT_LINTER="$(jq --raw-output '.[].Stdout[:-1]' <<<"${RESULTS_OBJECT}")"; then
if ! STDOUT_LINTER="$(jq --raw-output '.[] | select(.Stdout[:-1] | length > 0) | .Stdout[:-1]' <<<"${RESULTS_OBJECT}")"; then
fatal "Error when loading stdout for ${FILE_TYPE}:\n${STDOUT_LINTER}"
fi

Expand All @@ -199,7 +199,7 @@ function LintCodebase() {
fi

local STDERR_LINTER
if ! STDERR_LINTER="$(jq --raw-output '.[].Stderr[:-1]' <<<"${RESULTS_OBJECT}")"; then
if ! STDERR_LINTER="$(jq --raw-output '.[] | select(.Stderr[:-1] | length > 0) | .Stderr[:-1]' <<<"${RESULTS_OBJECT}")"; then
fatal "Error when loading stderr for ${FILE_TYPE}:\n${STDERR_LINTER}"
fi

Expand Down
4 changes: 2 additions & 2 deletions lib/linter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ fi
debug "RESULTS_OBJECT when running linters:\n${RESULTS_OBJECT}"

# Get raw output so we can strip quotes from the data we load. Also, strip the final newline to avoid adding it two times
if ! STDOUT_LINTERS="$(jq --raw-output '.[].Stdout[:-1]' <<<"${RESULTS_OBJECT}")"; then
if ! STDOUT_LINTERS="$(jq --raw-output '.[] | select(.Stdout[:-1] | length > 0) | .Stdout[:-1]' <<<"${RESULTS_OBJECT}")"; then
fatal "Error when loading stdout when running linters:\n${STDOUT_LINTERS}"
fi

Expand All @@ -840,7 +840,7 @@ else
debug "Stdout when running linters is empty"
fi

if ! STDERR_LINTERS="$(jq --raw-output '.[].Stderr[:-1]' <<<"${RESULTS_OBJECT}")"; then
if ! STDERR_LINTERS="$(jq --raw-output '.[] | select(.Stderr[:-1] | length > 0) | .Stderr[:-1]' <<<"${RESULTS_OBJECT}")"; then
fatal "Error when loading stderr for ${FILE_TYPE}:\n${STDERR_LINTERS}"
fi

Expand Down

0 comments on commit 20ded71

Please sign in to comment.