Skip to content

Commit

Permalink
fix: handle the failure case
Browse files Browse the repository at this point in the history
  • Loading branch information
matzuk committed Sep 5, 2024
1 parent ffc37f9 commit bcdc0ef
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ jobs:
platform: "android"
name: "android_3_0"

- name: Show failure message for Marathon Cloud action
- name: Show failure message
if: failure()
run: |
echo "❌ Marathon Cloud action-invoke failed. Please check the following:"
echo "1. Ensure that you have updated lib/index.js. See README for updating details."
exit 1
check_output_android:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -80,11 +81,12 @@ jobs:
name: android_output
path: output

- name: Show failure message for Marathon Cloud action
- name: Show failure message
if: failure()
run: |
echo "❌ Marathon Cloud action-invoke failed. Please check the following:"
echo "1. Ensure that you have updated lib/index.js. See README for updating details."
exit 1
check_output_failed_android:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -129,11 +131,12 @@ jobs:
name: android_failed_output
path: output

- name: Show failure message for Marathon Cloud action
- name: Show failure message
if: failure()
run: |
echo "❌ Marathon Cloud action-invoke failed. Please check the following:"
echo "1. Ensure that you have updated lib/index.js. See README for updating details."
exit 1
check_ios:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -178,8 +181,9 @@ jobs:
name: ios_output
path: output

- name: Show failure message for Marathon Cloud action
- name: Show failure message
if: failure()
run: |
echo "❌ Marathon Cloud action-invoke failed. Please check the following:"
echo "1. Ensure that you have updated lib/index.js. See README for updating details."
exit 1
28 changes: 24 additions & 4 deletions src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async function main() {
const xctestplanTargetName = core.getInput("xctestplanTargetName");
const xctestrunEnv = core.getInput("xctestrunEnv");
const xctestrunTestEnv = core.getInput("xctestrunTestEnv");
const ignoreTestFailures = core.getInput("ignoreTestFailures");
const ignoreTestFailures = core.getInput("ignoreTestFailures").toLowerCase() === 'true';
const resultFile = "result.json";
const pullFiles = core.getInput("pullFiles");

Expand All @@ -52,7 +52,7 @@ async function main() {
xctestplanTargetName,
xctestrunEnv,
xctestrunTestEnv,
ignoreTestFailures,
"",
resultFile,
pullFiles,
);
Expand All @@ -77,7 +77,7 @@ async function main() {
xctestplanTargetName,
xctestrunEnv,
xctestrunTestEnv,
ignoreTestFailures,
"",
resultFile,
pullFiles,
);
Expand All @@ -92,7 +92,23 @@ async function main() {
}

core.info("marathon-cloud run command starts...");
await exec("marathon-cloud", args);
let exitCode = 0;
let errorMessage: string | null = null;

try {
exitCode = await exec("marathon-cloud", args);
} catch (error: any) {
exitCode = error?.code ?? 1; // Default to 1 if there's no specific exit code
errorMessage = error.message || "Unknown error during marathon-cloud execution";
}

if (exitCode !== 0) {
if (!ignoreTestFailures) {
core.warning("Test failures detected, but continuing to download files...");
} else {
core.warning("Test failures detected, but continuing as ignoreTestFailures is set to true.");
}
}

// Check if output is empty and skip the remaining part if it is
if (!output) {
Expand All @@ -119,6 +135,10 @@ async function main() {
);
core.info("marathon-cloud download command starts...");
await exec("marathon-cloud", downloadArgs);

if (errorMessage && !ignoreTestFailures) {
core.setFailed(errorMessage);
}
} catch (e: any) {
core.warning(`marathon-cloud invoke failed: ${e}`);
core.setFailed(e);
Expand Down

0 comments on commit bcdc0ef

Please sign in to comment.