Skip to content

Commit

Permalink
Update ci-dev workflow (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nullpointer authored Feb 10, 2024
1 parent 82062f8 commit 51df71c
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 6 deletions.
12 changes: 8 additions & 4 deletions .gdunit4_action/unit-test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) {
Expand Down
40 changes: 39 additions & 1 deletion .github/workflows/ci-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: >-
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 51df71c

Please sign in to comment.