tauri-action icon indicating copy to clipboard operation
tauri-action copied to clipboard

retry arg

Open louis030195 opened this issue 1 year ago • 2 comments

keep having failed build that seem non deterministic

https://github.com/mediar-ai/screenpipe/actions/workflows/release-app.yml

usually:

  • runner running out of disk space (ubuntu)
  • some disk issue with mac x86_64
  • windows random issue

having a way to retry would save me probably at least 1h a week because i release 3 version a day on average

louis030195 avatar Sep 04 '24 17:09 louis030195

failed to notarize on macos also, usually retry and it works

this feature would save me so much time

louis030195 avatar Oct 22 '24 17:10 louis030195

Here's a suggested change using the diff markdown syntax for adding a retry argument to the tauri-action:

diff --git a/src/index.ts b/src/index.ts
index 1234567..abcdef0 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -24,6 +24,7 @@ async function run(): Promise<void> {
     const includeDebug = core.getBooleanInput('includeDebug');
     const includeUpdaterJson = core.getBooleanInput('includeUpdaterJson');
     const updaterJsonKeepUniversal = core.getBooleanInput('updaterJsonKeepUniversal');
+    const retryAttempts = parseInt(core.getInput('retryAttempts') || '1', 10);
     const tauriScript = core.getInput('tauriScript');
     const args = stringArgv(core.getInput('args'));
     const bundleIdentifier = core.getInput('bundleIdentifier');
@@ -76,14 +77,22 @@ async function run(): Promise<void> {
     const releaseArtifacts: Artifact[] = [];
     const debugArtifacts: Artifact[] = [];
     if (includeRelease) {
-      releaseArtifacts.push(
-        ...(await buildProject(projectPath, false, buildOptions, initOptions)),
-      );
+      for (let attempt = 1; attempt <= retryAttempts; attempt++) {
+        try {
+          releaseArtifacts.push(
+            ...(await buildProject(projectPath, false, buildOptions, initOptions)),
+          );
+          break;
+        } catch (error) {
+          if (attempt === retryAttempts) throw error;
+          console.log(`Build attempt ${attempt} failed, retrying...`);
+        }
+      }
     }
     if (includeDebug) {
-      debugArtifacts.push(
-        ...(await buildProject(projectPath, true, buildOptions, initOptions)),
-      );
+      // Similar retry logic for debug build
+      // ...
+    }
     const artifacts = releaseArtifacts.concat(debugArtifacts);

     if (artifacts.length === 0) {

This change introduces a new retryAttempts input parameter and implements a retry mechanism for the build process. It will attempt to build the project up to the specified number of times before giving up.

To use this new feature, you would add a new input to your GitHub Action workflow:

- uses: tauri-apps/tauri-action@v0
  with:
    # ... other inputs ...
    retryAttempts: 3

This would allow the build to retry up to 3 times if it fails.

louis030195 avatar Oct 22 '24 17:10 louis030195

https://github.com/tauri-apps/tauri-action/pull/964 implemented this for just the tauri build step for now. Maybe we'll add it to the upload step too but we'll see.

FabianLars avatar Dec 10 '24 18:12 FabianLars