Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions .github/workflows/validate-pr-metadata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,27 @@ jobs:
if: contains(steps.changed-files.outputs.modified_files, 'number-systems/')
run: ./test-sdc.sh number-systems
shell: bash
- name: test implement-cowsay
id: test-implement-cowsay
if: contains(steps.changed-files.outputs.modified_files, 'implement-cowsay/')
run: ./test-sdc.sh implement-cowsay
shell: bash
- name: make output comment
if: steps.test-individual-shell-tools.outputs.attempted == 'y' || steps.test-jq.outputs.attempted == 'y' || steps.test-shell-pipelines.outputs.attempted == 'y' || steps.test-number-systems.outputs.attempted == 'y'
if: steps.test-individual-shell-tools.outputs.attempted == 'y' || steps.test-jq.outputs.attempted == 'y' || steps.test-shell-pipelines.outputs.attempted == 'y' || steps.test-number-systems.outputs.attempted == 'y' || steps.test-implement-cowsay.outputs.attempted == 'y'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE_URL: ${{ github.event.pull_request.html_url }}
run: |
gh pr comment $ISSUE_URL --body-file testoutput.txt
- name: add appropriate labels
if: steps.test-individual-shell-tools.outputs.complete == 'y' || steps.test-jq.outputs.complete == 'y' || steps.test-shell-pipelines.outputs.complete == 'y'
if: steps.test-individual-shell-tools.outputs.complete == 'y' || steps.test-jq.outputs.complete == 'y' || steps.test-shell-pipelines.outputs.complete == 'y' || steps.test-implement-cowsay.outputs.complete == 'y'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE_URL: ${{ github.event.pull_request.html_url }}
run: |
gh pr edit $ISSUE_URL --add-label "Complete"
gh pr edit $ISSUE_URL --remove-label "Needs Review"
- name: fail if not complete
if: (steps.test-individual-shell-tools.outputs.attempted == 'y' || steps.test-jq.outputs.attempted == 'y' || steps.test-shell-pipelines.outputs.attempted == 'y') && !(steps.test-individual-shell-tools.outputs.complete == 'y' || steps.test-jq.outputs.complete == 'y' || steps.test-shell-pipelines.outputs.complete == 'y')
if: (steps.test-individual-shell-tools.outputs.attempted == 'y' || steps.test-jq.outputs.attempted == 'y' || steps.test-shell-pipelines.outputs.attempted == 'y' || steps.test-implement-cowsay.outputs.attempted == 'y') && !(steps.test-individual-shell-tools.outputs.complete == 'y' || steps.test-jq.outputs.complete == 'y' || steps.test-shell-pipelines.outputs.complete == 'y' || steps.test-implement-cowsay.outputs.complete == 'y')
run: |
exit -1
10 changes: 10 additions & 0 deletions expect/implement-cowsay/cow-grass.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
________________
| Grass, delicious |
================
\
\
^__^
(oo)\_______
(__)\ )\/\
||----w |
|| ||
22 changes: 22 additions & 0 deletions expect/implement-cowsay/turtle-fish.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
______________
| Fish are cool! |
==============
\
\
\
\
___-------___
_-~~ ~~-_
_-~ /~-_
/^\__/^\ /~ \ / \
/| O|| O| / \_______________/ \
| |___||__| / / \ \
| \ / / \ \
| (_______) /______/ \_________ \
| / / \ / \
\ \^\\ \ / \ /
\ || \______________/ _-_ //\__//
\ ||------_-~~-_ ------------- \ --/~ ~\ || __/
~-----||====/~ |==================| |/~~~~~
(_(__/ ./ / \_\ \.
(_(___/ \_____)_)
47 changes: 47 additions & 0 deletions test-sdc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,53 @@ elif [[ "$1" == "number-systems" ]]; then
fi
echo "Please let a volunteer check the answers for part 2." >> testoutput.txt
cat testoutput.txt
elif [[ "$1" == "implement-cowsay" ]]; then
if [ -v GITHUB_OUTPUT ]; then
echo "attempted=y" >> "$GITHUB_OUTPUT"
fi
if [[ -e .cowsay-venv ]]; then
echo ".cowsay-venv already exists - couldn't test cowsay" >> testoutput.txt
else
if [ ! -e implement-cowsay/requirements.txt ]; then
echo "Expected implement-cowsay/requirements.txt to exist but it didn't" >> testoutput.txt
else
python3 -m venv .cowsay-venv
. .cowsay-venv/bin/activate
pip3 install -r implement-cowsay/requirements.txt

all_ok=true

python3 implement-cowsay/cow.py Grass, delicious > test.tmp
cmp test.tmp expect/implement-cowsay/cow-grass.txt
if [ $? -ne 0 ]; then
echo "Unexpected cowsay output for Grass, delicious" >> testoutput.txt
all_ok=false
fi

python3 implement-cowsay/cow.py --animal turtle "Fish are cool!" > test.tmp
cmp test.tmp expect/implement-cowsay/turtle-fish.txt
if [ $? -ne 0 ]; then
echo "Unexpected cowsay output for Fish are cool!" >> testoutput.txt
all_ok=false
fi

python3 implement-cowsay/cow.py --help | grep dragon
if [ $? -ne 0 ]; then
echo "Expected python3 cow.py --help to include dragon as it's one of the animal options" >> testoutput.txt
all_ok=false
fi

grep dragon implement-cowsay/cow.py > /dev/null
if [ $? -eq 0 ]; then
echo "Didn't expect cow.py to include the word dragon - you should pull in the animal options from the library not write them yourself" >> testoutput.txt
all_ok=false
fi

if [[ "${all_ok}" == "true" && -v GITHUB_OUTPUT ]]; then
echo "completed=y" >> "$GITHUB_OUTPUT"
fi
fi
fi
else
echo "Please run this with a valid test directory name as argument"
fi