Skip to content

Commit

Permalink
Update Test and Build workflow (#648)
Browse files Browse the repository at this point in the history
- Prevent unintended labels from triggering test workflow
- Prevent pull request from triggering build workflows since test
  workflow would build EDM4U.
- Prevent test workflow from emitting error message just because
  `grep` command did not get any failed tests.
  • Loading branch information
chkuang-g authored Nov 2, 2023
1 parent 2e7948c commit 7782c4c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ on:
schedule:
- cron: "0 10 * * *" # 10am UTC = 2am PST

pull_request:
types: [ labeled, closed ]

workflow_dispatch:
inputs:
unity_version:
Expand Down
37 changes: 33 additions & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,36 @@ jobs:
echo "include_test_modules=" >> $GITHUB_OUTPUT
echo "exclude_test_modules=" >> $GITHUB_OUTPUT
echo "exclude_tests=" >> $GITHUB_OUTPUT
# This is currently checking for invalid trigger only.
if [[ "${{ github.event_name }}" == "schedule" ]]; then
# Do nothing for now
:
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
if [[ "${{ github.event.action }}" == "labeled" && "${{ github.event.label.name }}" == "tests-requested" ]]; then
# Do nothing for now
:
elif [[ "${{ github.event.action }}" == "closed" && "${{ github.event.pull_request.merged == true}}" == "true" ]]; then
# Do nothing for now
:
else
echo "invalid_trigger=1" >> $GITHUB_OUTPUT
fi
else
echo "invalid_trigger=1" >> $GITHUB_OUTPUT
fi
fi
- name: Cancel workflow
if: ${{ steps.set_outputs.outputs.invalid_trigger }}
uses: andymckay/[email protected]

- name: Wait for workflow cancellation
if: ${{ steps.set_outputs.outputs.invalid_trigger }}
run: |
sleep 300
exit 1 # fail out if the cancellation above somehow failed.
- name: Print output
run: |
echo outputs.unity_version : ${{ steps.set_outputs.outputs.unity_version }}
Expand Down Expand Up @@ -119,14 +147,15 @@ jobs:
continue-on-error: true
run: cat test_output/test*IntegrationTestsBatchMode/*.log

- name: Obtain Failed tests
- name: Obtain Failed tests from Integration tests and NUnit tests
if: always()
shell: bash
continue-on-error: true
run: |
cat test_output/test*/*_test.log | grep "^Test .* PASSED$"
cat test_output/test*/*_test.log | grep "^Test .* FAILED$"
cat test_output/test*/*_test.log | grep "^Test .* SKIPPED$"
# Quick and dirty way to get all failed tests in granular level.
# TODO: better parser for more information, ex. error message.
{ cat test_output/test*/*_test.log || true; } | { grep "^Test .* FAILED$" || true; }
{ cat test_output/test*/test*/results.xml || true; } | { grep '^ *<test-case.*result="Failed"' || true; } | sed 's/^.* name="\([^\"]*\)".*$/Test \1: FAILED/'
- name: Return Unity license
if: always()
Expand Down

0 comments on commit 7782c4c

Please sign in to comment.