diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bd9ce1d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM rust:1.81 +WORKDIR /app + +COPY . . + +RUN cargo install sprocket + +ENTRYPOINT ["sprocket"] +CMD ["--help"] diff --git a/LICENSE b/LICENSE-APACHE similarity index 99% rename from LICENSE rename to LICENSE-APACHE index 261eeb9..71d3ac1 100644 --- a/LICENSE +++ b/LICENSE-APACHE @@ -1,3 +1,4 @@ + Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -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. @@ -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. \ No newline at end of file diff --git a/LICENSE-MIT b/LICENSE-MIT new file mode 100644 index 0000000..3320ee1 --- /dev/null +++ b/LICENSE-MIT @@ -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. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..9d09aee --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +Repository Header Image +
+ +# 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 +``` diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..7cf656e --- /dev/null +++ b/action.yml @@ -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 }} diff --git a/assets/header-action.png b/assets/header-action.png new file mode 100644 index 0000000..7721bd1 Binary files /dev/null and b/assets/header-action.png differ diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..ab5a555 --- /dev/null +++ b/entrypoint.sh @@ -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