Skip to content

Commit

Permalink
Add in examples for unit test. Closes #6.
Browse files Browse the repository at this point in the history
  • Loading branch information
vsmalladi committed Apr 25, 2024
1 parent 16aceff commit 9a647ae
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 2 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: unit test
on: [push, pull_request]

defaults:
run:
# This is needed for miniconda, see:
# https://github.com/marketplace/actions/setup-miniconda#important.
shell: bash -l {0}

jobs:
miniwdl_check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install miniwdl
run: |
python -m pip install --upgrade pip
pip3 install miniwdl
pip3 install pytest-workflow
- name: Run unit tests
# Use --symlink to limit disk usage.
run: >-
pytest --keep-workflow-wd-on-fail
--symlink tests/
- name: Check miniwdl log in case of failure.
if: ${{ failure() }}
# Get the last 1000 lines of the miniwdl log to catch the error.
run: bash -c 'tail -n 1000 /tmp/pytest_workflow_*/*/log.out'
- name: Check job stderr messages in case of failure
if: ${{ failure() }}
run: >-
bash -c '
for file in $(find /tmp -name stderr);
do echo $file; cat $file; done'
- name: Check job stdout messages in case of failure
if: ${{ failure() }}
run: >-
bash -c '
for file in $(find /tmp -name stdout);
do echo $file; cat $file; done'
4 changes: 2 additions & 2 deletions hello.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ task hello {
String name
}

command <<<
command {
echo 'hello ${name}!'
>>>
}

output {
File response = stdout()
Expand Down
4 changes: 4 additions & 0 deletions tests/inputs/hello.inputs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "Test"
}

5 changes: 5 additions & 0 deletions tests/test.hello.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- name: hello
command: miniwdl run -i tests/inputs/hello.inputs.json -d test-output/ --task hello hello.wdl
stdout: # Options for testing stdout (optional)
contains: # List of strings which should be in stdout (optional)
- "hello Test!"

0 comments on commit 9a647ae

Please sign in to comment.