diff --git a/Dockerfile b/Dockerfile index d7ef8f4..bdb03a0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM norionomura/swiftlint:swift-5 +FROM norionomura/swiftlint:0.59.1-slim LABEL version="3.2.1" LABEL repository="https://github.com/norio-nomura/action-swiftlint" LABEL homepage="https://github.com/norio-nomura/action-swiftlint" diff --git a/action.yml b/action.yml index 022170e..a41dbe2 100644 --- a/action.yml +++ b/action.yml @@ -1,6 +1,11 @@ name: 'GitHub Action for SwiftLint' description: 'A tool to enforce Swift style and conventions' author: 'Norio Nomura ' +outputs: + violations_count: + description: 'Number of found violations' + serious_violations_count: + description: 'Number of serious violations' runs: using: 'docker' image: 'Dockerfile' diff --git a/entrypoint.sh b/entrypoint.sh index a01922b..ed34be8 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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} @@ -31,4 +41,5 @@ then fi fi -set -o pipefail && swiftlint "$@" -- $changedFiles | stripPWD | convertToGitHubActionsLoggingCommands +echo "Using swiftlint version: `swiftlint --version`" +set -o pipefail && swiftlint "$@" -- $changedFiles | stripPWD | convertToGitHubActionsLoggingCommands | parseOutputsParameters