-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: GitHub action for sprocket check and lint (#1)
* feat: GitHub action for sprocket check and lint
- Loading branch information
1 parent
ee251e7
commit 81d437a
Showing
7 changed files
with
136 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |