Skip to content
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
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,27 @@ with:
inputs_files: "inputs/bwa.json,inputs/star.wdl"
```

### `format` | `format check`

Checks that all WDL files are formatted correctly.

#### Inputs

To set your format configuration (e.g. indentation) a `sprocket.toml` should be committed to your repository. See [Configuration](#configuration) for more information.

##### `ignore-patterns`

**Optional** Comma separated list of patterns to append to the `.sprocketignore` file in the root of the repository.

#### Example usage

```yaml
uses: stjude-rust-labs/sprocket-action@main
with:
action: format
ignore-patterns: template,test
```

## Configuration

The Sprocket GitHub action will load a `sprocket.toml` in the root of your repository, and that can be used to have the same settings in your local development environment as your CI environment. All optional inputs to this GitHub Action (aside from `action` and `skip-config-search`) can be supplied in your TOML instead.
Expand Down
87 changes: 53 additions & 34 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ if [ -n "$INPUT_CONFIG" ]; then
fi
config_args="$skip_config $config_path"

if [ $INPUT_ACTION = "check" ] || [ $INPUT_ACTION = "lint" ]; then
echo "Checking WDL files."
if [ "$INPUT_ACTION" = "check" ] || [ "$INPUT_ACTION" = "lint" ]; then
echo "Checking WDL files using 'sprocket check'"
lint=""
if [ $INPUT_LINT = "true" ] || [ $INPUT_ACTION = "lint" ]; then
if [ $INPUT_LINT = "true" ] || [ "$INPUT_ACTION" = "lint" ]; then
lint="--lint"
fi
if [ $INPUT_ALL_RULES = "true" ]; then
Expand All @@ -38,7 +38,7 @@ if [ $INPUT_ACTION = "check" ] || [ $INPUT_ACTION = "lint" ]; then
exceptions=""
if [ -n "$INPUT_EXCEPT" ]; then
echo "Excepted rule(s) provided."
for exception in $(echo $INPUT_EXCEPT | sed 's/,/ /g')
for exception in ${INPUT_EXCEPT//,/ /}
do
exceptions="$exceptions -e $exception"
done
Expand All @@ -57,7 +57,7 @@ if [ $INPUT_ACTION = "check" ] || [ $INPUT_ACTION = "lint" ]; then
exclusions=${INPUT_PATTERNS}
if [ -n "$exclusions" ]; then
echo "Exclusions provided. Appending to .sprocketignore"
for exclusion in $(echo $exclusions | sed 's/,/ /g')
for exclusion in ${exclusions//,/ /}
do
echo "$exclusion" >> .sprocketignore
done
Expand All @@ -68,15 +68,14 @@ if [ $INPUT_ACTION = "check" ] || [ $INPUT_ACTION = "lint" ]; then

EXITCODE=0

echo "Checking WDL files using \`sprocket check\`."
set -x
sprocket -v $config_args check $lint $warnings $notes $exceptions || EXITCODE=$(($? || EXITCODE))
set +x

echo "status=$EXITCODE" >> $GITHUB_OUTPUT
exit $EXITCODE
elif [ $INPUT_ACTION = "validate" ]; then
echo "Validating inputs"
elif [ "$INPUT_ACTION" = "validate" ]; then
echo "Validating inputs using 'sprocket validate'"

EXITCODE=0

Expand All @@ -89,38 +88,58 @@ elif [ $INPUT_ACTION = "validate" ]; then
for index in "${!input_files[@]}"
do
set -x
sprocket -v $config_args validate "${wdl_files[index]}" "${input_files[index]}" || EXITCODE=$(($? || EXITCODE))
sprocket -v $config_args validate "${wdl_files[index]}" "${input_files[index]}" \
|| EXITCODE=$(($? || EXITCODE))
set +x
done

echo "status=$EXITCODE" >> $GITHUB_OUTPUT
exit $EXITCODE
elif [ $INPUT_ACTION = "run" ]; then
echo "Action \`run\` is unsupported."
exit 1
elif [ $INPUT_ACTION = "format" ]; then
echo "Action \`format\` is currently unsupported."
exit 1
elif [ $INPUT_ACTION = "analyzer" ]; then
echo "Action \`analyzer\` is unsupported."
exit 1
elif [ $INPUT_ACTION = "explain" ]; then
echo "Action \`explain\` is unsupported."
exit 1
elif [ $INPUT_ACTION = "completions" ]; then
echo "Action \`completions\` is unsupported."
exit 1
elif [ $INPUT_ACTION = "config" ]; then
echo "Action \`config\` is unsupported."
exit 1
elif [ $INPUT_ACTION = "dev" ]; then
echo "Action \`dev\` is unsupported."
exit 1
elif [ $INPUT_ACTION = "inputs" ]; then
echo "Action \`inputs\` is unsupported."
exit 1
elif [ "$INPUT_ACTION" = "run" ]; then
echo "Action 'run' is unsupported."
EXITCODE=1
elif [ "$INPUT_ACTION" = "format" ] || [ "$INPUT_ACTION" = "format check" ]; then
echo "Checking formatting using 'sprocket format check'"

exclusions=${INPUT_PATTERNS}
if [ -n "$exclusions" ]; then
echo "Exclusions provided. Appending to .sprocketignore"
for exclusion in ${exclusions//,/ /}
do
echo "$exclusion" >> .sprocketignore
done

echo " [***] Ignore File [***]"
cat .sprocketignore
fi

EXITCODE=0

set -x
sprocket -v $config_args format check || EXITCODE=$(($? || EXITCODE))
set +x
elif [ "$INPUT_ACTION" = "analyzer" ]; then
echo "Action 'analyzer' is unsupported."
EXITCODE=1
elif [ "$INPUT_ACTION" = "explain" ]; then
echo "Action 'explain' is unsupported."
EXITCODE=1
elif [ "$INPUT_ACTION" = "completions" ]; then
echo "Action 'completions' is unsupported."
EXITCODE=1
elif [ "$INPUT_ACTION" = "config" ]; then
echo "Action 'config' is unsupported."
EXITCODE=1
elif [ "$INPUT_ACTION" = "dev" ]; then
echo "Action 'dev' is unsupported."
EXITCODE=1
elif [ "$INPUT_ACTION" = "inputs" ]; then
echo "Action 'inputs' is unsupported."
EXITCODE=1
else
echo "Invalid action. Exiting."
exit 1
EXITCODE=1
fi

echo "status=$EXITCODE" >> $GITHUB_OUTPUT
exit $EXITCODE
Loading