Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add output parameters 'violations_count' and 'serious_violations_count' #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: 'GitHub Action for SwiftLint'
description: 'A tool to enforce Swift style and conventions'
author: 'Norio Nomura <[email protected]>'
outputs:
violations_count:
description: 'Number of found violations'
serious_violations_count:
description: 'Number of serious violations'
runs:
using: 'docker'
image: 'Dockerfile'
Expand Down
12 changes: 11 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ function convertToGitHubActionsLoggingCommands() {
sed -E 's/^(.*):([0-9]+):([0-9]+): (warning|error|[^:]+): (.*)/::\4 file=\1,line=\2,col=\3::\5/'
}

function parseOutputsParameters() {
input_value=$( cat )
violations=$(echo "$input_value" | grep -E '::warning|::error' -c)
errors=$(echo "$input_value" | grep -E 'error' -c)
echo "$input_value"
echo "::set-output name=violations_count::$violations"
echo "::set-output name=serious_violations_count::$errors"
}


if ! ${WORKING_DIRECTORY+false};
then
cd ${WORKING_DIRECTORY}
Expand All @@ -31,4 +41,4 @@ then
fi
fi

set -o pipefail && swiftlint "$@" -- $changedFiles | stripPWD | convertToGitHubActionsLoggingCommands
set -o pipefail && swiftlint "$@" -- $changedFiles | stripPWD | convertToGitHubActionsLoggingCommands | parseOutputsParameters