From 61cd13a2b0c753d4b6a84263064570a3a8668396 Mon Sep 17 00:00:00 2001 From: Shawn Kuang Date: Mon, 23 Oct 2023 09:59:25 -0700 Subject: [PATCH 1/5] Update Test workflows - 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. --- .github/workflows/build.yaml | 3 --- .github/workflows/test.yaml | 28 +++++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index b7da39e3..27399da4 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -19,9 +19,6 @@ on: schedule: - cron: "0 10 * * *" # 10am UTC = 2am PST - pull_request: - types: [ labeled, closed ] - workflow_dispatch: inputs: unity_version: diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ee73831c..1ab036cc 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -66,8 +66,32 @@ jobs: echo "include_test_modules=" >> $GITHUB_OUTPUT echo "exclude_test_modules=" >> $GITHUB_OUTPUT echo "exclude_tests=" >> $GITHUB_OUTPUT + + 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/cancel-action@0.2 + + - 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 }} @@ -124,9 +148,7 @@ jobs: 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$" + cat test_output/test*/*_test.log | { grep "^Test .* FAILED$" || true; } - name: Return Unity license if: always() From e1de34b18452fbf766c544c3f737b1e4b857865c Mon Sep 17 00:00:00 2001 From: Shawn Kuang Date: Mon, 23 Oct 2023 10:30:52 -0700 Subject: [PATCH 2/5] Add info for failed nunit tests --- .github/workflows/test.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 1ab036cc..9893668c 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -143,12 +143,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: | + # 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 | { grep "^Test .* FAILED$" || true; } + cat test_output/test*/test*/results.xml | { grep '^ * Date: Mon, 23 Oct 2023 10:36:03 -0700 Subject: [PATCH 3/5] add no-op --- .github/workflows/test.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 9893668c..53fdbf2b 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -69,11 +69,14 @@ jobs: 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 From 928dbc112ce0621ba381f0c1fc72ec0b754103c9 Mon Sep 17 00:00:00 2001 From: Shawn Kuang Date: Mon, 23 Oct 2023 11:56:34 -0700 Subject: [PATCH 4/5] supress error when no integration test log or nunit test log --- .github/workflows/test.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 53fdbf2b..e7e2993d 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -153,8 +153,8 @@ jobs: run: | # 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 | { grep "^Test .* FAILED$" || true; } - cat test_output/test*/test*/results.xml | { grep '^ * Date: Mon, 23 Oct 2023 15:41:15 -0700 Subject: [PATCH 5/5] Add comment --- .github/workflows/test.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index e7e2993d..67d39a78 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -67,6 +67,7 @@ jobs: 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 :