Skip to content

Commit

Permalink
refactor: use environment args (#3)
Browse files Browse the repository at this point in the history
* refactor: use environment args
  • Loading branch information
adthrasher authored Sep 19, 2024
1 parent 81d437a commit 03be138
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 16 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/test-exclusions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Test Exclusions

on:
pull_request:
push:

jobs:
test-exclusions:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Test Local Action (debug log)
uses: ./
env:
LOG_LEVEL: DEBUG
CREATE_LOG_FILE: true
GITHUB_WORKSPACE: test/exclusion-test
with:
exclude-patterns: 'template'
- name: Test Local Action (debug log)
uses: ./
env:
LOG_LEVEL: DEBUG
CREATE_LOG_FILE: true
GITHUB_WORKSPACE: test/exclusion-test
with:
exclude-patterns: 'template'
deny-warnings: 'true'
9 changes: 4 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ 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 }}
env:
INPUT_PATTERNS: ${{ inputs.exclude-patterns }}
INPUT_WARNINGS: ${{ inputs.deny-warnings }}
INPUT_NOTES: ${{ inputs.deny-notes }}
25 changes: 14 additions & 11 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
#!/bin/bash

lint=""

if [ $INPUT_LINT = "true" ]; then
lint="--lint"
fi

warnings=""

if [ ${INPUT_WARNINGS} = "true" ]; then
warnings="--deny-warnings"
fi

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
if [ ${INPUT_NOTES} = "true" ]; then
notes="--deny-notes"
fi

exclusions=$1
exclusions=${INPUT_PATTERNS}

if [ -n "$exclusions" ]; then
echo "Exclusions provided. Writing to .sprocket.yml."
Expand Down
24 changes: 24 additions & 0 deletions test/exclusion-test/ok.wdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#@ except: LineWidth
version 1.1

task foo {
meta {
description: "test task"
outputs: {
out: "output file"
}
}

command <<<
echo "hello" > out
>>>

output {
File out = "out"
}

runtime {
container: "ubuntu@sha256:67541378af7d535606e684a8234d56ca0725b6a4d8b0bbf19cebefed98e06f42"
}
}
Empty file.

0 comments on commit 03be138

Please sign in to comment.