Skip to content

Commit

Permalink
feat: GitHub action for sprocket check and lint (#1)
Browse files Browse the repository at this point in the history
* feat: GitHub action for sprocket check and lint
  • Loading branch information
adthrasher authored Sep 18, 2024
1 parent ee251e7 commit 81d437a
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 2 deletions.
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM rust:1.81
WORKDIR /app

COPY . .

RUN cargo install sprocket

ENTRYPOINT ["sprocket"]
CMD ["--help"]
5 changes: 3 additions & 2 deletions LICENSE → LICENSE-APACHE
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
Expand Down Expand Up @@ -186,7 +187,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2024-Present St. Jude Children's Research Hospital

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -198,4 +199,4 @@
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
21 changes: 21 additions & 0 deletions LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024-Present St. Jude Children's Research Hospital

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<img style="margin: 0px" alt="Repository Header Image" src="./assets/header-action.png" />
<hr/>

# Sprocket GitHub Action
This action uses [Sprocket](https://github.com/stjude-rust-labs/sprocket) to validate and optionally lint WDL documents.

## Inputs
### `lint`
**Optional** Whether to run linting in addition to validation. Boolean, valid choices: ["true", "false"]
### `exclude-patterns`
**Optional** Comma separated list of patterns to exclude when searching for WDL files.
### `deny-warnings`
**Optional** If specified, Sprocket `check` will fail if any `warnings` are produced.
### `deny-notes`
**Optional** If specified, Sprocket `check` will fail if any `notes` are produced.


## Example usage
```
uses: actions/sprocket-action@v1
with:
lint: true
exclude-patterns: template,test
```
32 changes: 32 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: "Sprocket Check"
author: "St. Jude Cloud Rust Labs"
description: "Check WDL documents for validity using Sprocket"
inputs:
lint:
description: "Whether to lint the WDL document"
required: false
default: 'false'
exclude-patterns:
description: 'Comma separated list of patterns to exclude from Sprocket check.'
required: false
default: ''
deny-warnings:
description: 'Fail the check if there are any warnings.'
required: false
default: 'false'
deny-notes:
description: 'Fail the check if there are any notes.'
required: false
default: 'false'
outputs:
status:
description: "The status of the check"
runs:
using: "docker"
image: "Dockerfile"
entrypoint: "/app/entrypoint.sh"
args:
- ${{ inputs.lint == 'true' && '--lint' || '' }}
- ${{ inputs.deny-warnings == 'true' && '--deny-warnings' || '' }}
- ${{ inputs.deny-notes == 'true' && '--deny-notes' || '' }}
- ${{ inputs.exclude-patterns }}
Binary file added assets/header-action.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 47 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

lint=""
warnings=""
notes=""

while [ "$#" -gt 0 ]; do
arg=$1
case $1 in
-l|--lint) lint="--lint"; shift;;
-w|--deny-warnings) warnings="--deny-warnings"; shift;;
-n|--deny-notes) notes="--deny-notes"; shift;;
''|"") shift;;
*) break;;
esac
done

exclusions=$1

if [ -n "$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
if [ -e ".sprocket.yml" ]
then
if [ $(echo $file | grep -cvf .sprocket.yml) -eq 0 ]
then
echo " [***] Excluding $file [***]"
continue
fi
fi
echo " [***] $file [***]"
sprocket check $lint $warnings $notes $file || EXITCODE=$(($? || EXITCODE))
done

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

0 comments on commit 81d437a

Please sign in to comment.