From 51df71cf56643aa1677a621e585fe0c23475af85 Mon Sep 17 00:00:00 2001 From: Nullpointer Date: Sat, 10 Feb 2024 21:22:30 +0100 Subject: [PATCH] Update ci-dev workflow (#14) --- .gdunit4_action/unit-test/index.js | 12 ++++++--- .github/workflows/ci-dev.yml | 40 +++++++++++++++++++++++++++++- action.yml | 2 +- 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/.gdunit4_action/unit-test/index.js b/.gdunit4_action/unit-test/index.js index a7e035d..114123b 100644 --- a/.gdunit4_action/unit-test/index.js +++ b/.gdunit4_action/unit-test/index.js @@ -114,7 +114,7 @@ async function runTests(exeArgs, core) { let retriesCount = 0; - while (retriesCount < retries) { + while (retriesCount <= retries) { const child = spawnSync("xvfb-run", args, { cwd: getProjectPath(), timeout: timeout * 1000 * 60, @@ -126,13 +126,17 @@ async function runTests(exeArgs, core) { exitCode = child.status; if (exitCode === 0) { break; // Exit loop if successful - } - console_warning(`Tests failed with exit code: ${exitCode}. Retrying...`); + } retriesCount++; + if (retriesCount <= retries) { + console_warning(`The tests are failed with exit code: ${exitCode}. Retrying... ${retriesCount} of ${retries}`); + } } if (exitCode !== 0) { - core.setFailed(`Tests failed after ${retries} retries with exit code: ${exitCode}`); + core.setFailed(`The tests was failed after ${retries} retries with exit code: ${exitCode}`); + } else if (retriesCount > 0 && retries > 0) { + core.warning(`The tests was successfully after ${retriesCount} retries with exit code: ${exitCode}`); } return exitCode; } catch (error) { diff --git a/.github/workflows/ci-dev.yml b/.github/workflows/ci-dev.yml index c561156..73198da 100644 --- a/.github/workflows/ci-dev.yml +++ b/.github/workflows/ci-dev.yml @@ -78,12 +78,50 @@ jobs: retries: 3 # We have set the number of repetitions to 3 because Godot mono randomly crashes during C# tests report-name: report_gdUnit4-${{ matrix.version }}_Godot${{ matrix.godot-version }}-${{ matrix.godot-status }}-net.xml + # tests if the action reports test failures the action must fail + action-fail-test: + runs-on: ubuntu-22.04 + strategy: + fail-fast: false + + name: 'GdUnit4 action fail test' + + steps: + - name: 'Checkout gdUnit4-action' + uses: actions/checkout@v4 + with: + lfs: true + + - name: 'Install test project' + shell: bash + run: | + mv -f .github/workflows/resources/* . + + - name: 'Run failing failing test' + id: test-fails + continue-on-error: true + timeout-minutes: 3 + env: + GDUNIT_FAIL: 'true' + uses: ./ + with: + godot-version: 4.2.1 + paths: | + res://tests/ + timeout: 2 + report-name: report_action_fail_gdUnit4.xml + + - if: ${{ steps.test-fails.outcome != 'failure' }} + shell: bash + run: | + echo "The step 'steps.test-fails' must fail but is ${{ steps.test-fails.outcome}}" + exit 1 finalize: if: ${{ !cancelled() }} runs-on: ubuntu-latest name: 'Final Results' - needs: [unit-tests] + needs: [unit-tests, action-fail-test] steps: - run: exit 1 if: >- diff --git a/action.yml b/action.yml index 2c04fea..9f818c2 100644 --- a/action.yml +++ b/action.yml @@ -31,7 +31,7 @@ inputs: retries: description: 'The number of retries if the tests fail.' required: false - default: '1' + default: '0' report-name: description: 'The name of the test report file.' required: false