Skip to content

Commit

Permalink
feat: add exclude paths option
Browse files Browse the repository at this point in the history
  • Loading branch information
adthrasher committed Sep 17, 2024
1 parent aa6b2b6 commit 6dddc86
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ This action uses [Sprocket](https://github.com/stjude-rust-labs/sprocket) to val
## Inputs
## lint
**Optional** Whether to run linting in addition to validation. Boolean, valid choices: ["true", "false"]
## exclude-paths
**Optional** Comma separated list of patterns to exclude when searching for WDL files.

## Example usage
uses: actions/sprocket-action@v1
with:
lint: true
lint: true
exclude-paths: template,test
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ inputs:
description: "Whether to lint the WDL document"
required: false
default: "false"
exclude-paths:
description: 'Comma separated list of patterns to exclude from Sprocket check.'
required: false
default: ''
outputs:
status:
description: "The status of the check"
Expand All @@ -15,3 +19,4 @@ runs:
entrypoint: "/app/entrypoint.sh"
args:
- ${{ inputs.lint == 'true' && '--lint' || '' }}
- ${{ inputs.exclude-paths }}
33 changes: 18 additions & 15 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
#!/bin/bash

lint=$1
exclusions=$2

errors=0
ret=0
if [ ! -z "$exclusions" ]; then
echo "Exclusions provided. Writing to .sprocket.yml."
echo -n "" > .sprocket.yml
for exclusion in $(echo $exclusions | sed 's/,/ /')
do
echo "$exclusion" >> .sprocket.yml
done
fi

EXITCODE=0

echo "Checking WDL files using \`sprocket lint\`."
for file in $(find $GITHUB_WORKSPACE -name "*.wdl")
do
echo " [***] $file [***]"
ret=$(sprocket check $lint $file)
if [ $ret -ne 0 ]
then
echo "$file has errors" >> $GITHUB_OUTPUT
errors=1
if [ $(echo $file | grep -cvf .sprocket.yml) -eq 0 ]; then
echo " [***] Excluding $file [***]"
continue
fi
echo " [***] $file [***]"
sprocket check $lint $file || EXITCODE=$(($? || EXITCODE))
done

if [ $errors -eq 0 ]
then
echo "No errors found" >> $GITHUB_OUTPUT
exit 0
else
exit 1
fi
echo "status=$EXITCODE" >> $GITHUB_OUTPUT
exit $EXITCODE

0 comments on commit 6dddc86

Please sign in to comment.