ci: harden release artifact uploads (#3816)

This commit is contained in:
Carlos Florêncio
2026-09-19 12:35:51 +01:00
committed by GitHub
parent b85e228d2d
commit e3ed7bfd5d
10 changed files with 688 additions and 6 deletions
@@ -172,6 +172,48 @@ class ReleaseWorkflowContractTest(unittest.TestCase):
self.assertIn(archive, package)
self.assertLess(package.index(validation), package.index(archive))
def assert_required_artifact_upload_retries(
self, job_name: str, step_prefix: str
) -> None:
block = job_block(job_name)
for attempt in (1, 2, 3):
step_id = f"{step_prefix}_{attempt}"
self.assertEqual(block.count(f"id: {step_id}"), 1)
if attempt > 1:
self.assertIn(
f"if: steps.{step_prefix}_{attempt - 1}.outcome == 'failure'",
block,
)
self.assertEqual(block.count("if-no-files-found: error"), 3)
self.assertEqual(block.count("overwrite: true"), 2)
self.assertIn("sleep 30", block)
self.assertIn("sleep 60", block)
self.assertIn("attempt 1/3 failed; retrying in 30 seconds.", block)
self.assertIn("attempt 2/3 failed; retrying in 60 seconds.", block)
normalized = " ".join(block.split())
self.assertIn(
f"if: >- steps.{step_prefix}_1.outcome == 'failure' && "
f"steps.{step_prefix}_2.outcome == 'failure' && "
f"steps.{step_prefix}_3.outcome == 'failure'",
normalized,
)
def test_required_artifact_uploads_retry_and_desktop_matrix_isolated(self) -> None:
self.assert_required_artifact_upload_retries("build-web", "upload_web_bundle")
self.assert_required_artifact_upload_retries(
"build-bundles", "upload_runtime_bundle"
)
self.assert_required_artifact_upload_retries(
"build-desktop", "upload_desktop_artifacts"
)
desktop = job_block("build-desktop")
self.assertIn("fail-fast: false", desktop)
self.assertIn(
"needs.build-desktop.result == 'success'", job_block("publish-release")
)
def test_stable_jobs_continue_past_skipped_nightly_branch_only_after_successful_needs(
self,
) -> None:
+155 -5
View File
@@ -745,12 +745,61 @@ jobs:
VITE_KANDEV_API_PORT: ""
VITE_KANDEV_DEBUG: ""
run: pnpm -C apps --filter @kandev/web build
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
- name: Upload web bundle (attempt 1)
id: upload_web_bundle_1
continue-on-error: true
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: web-bundle
path: apps/web/dist
if-no-files-found: error
include-hidden-files: true
- name: Wait before web bundle upload retry (attempt 2)
if: steps.upload_web_bundle_1.outcome == 'failure'
run: |
echo "::warning::web-bundle upload attempt 1/3 failed; retrying in 30 seconds."
sleep 30
- name: Upload web bundle (attempt 2)
id: upload_web_bundle_2
if: steps.upload_web_bundle_1.outcome == 'failure'
continue-on-error: true
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: web-bundle
path: apps/web/dist
if-no-files-found: error
include-hidden-files: true
overwrite: true
- name: Wait before web bundle upload retry (attempt 3)
if: steps.upload_web_bundle_2.outcome == 'failure'
run: |
echo "::warning::web-bundle upload attempt 2/3 failed; retrying in 60 seconds."
sleep 60
- name: Upload web bundle (attempt 3)
id: upload_web_bundle_3
if: steps.upload_web_bundle_2.outcome == 'failure'
continue-on-error: true
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: web-bundle
path: apps/web/dist
if-no-files-found: error
include-hidden-files: true
overwrite: true
- name: Fail after web bundle upload retries
if: >-
steps.upload_web_bundle_1.outcome == 'failure' &&
steps.upload_web_bundle_2.outcome == 'failure' &&
steps.upload_web_bundle_3.outcome == 'failure'
run: |
echo "::error::web-bundle upload failed after 3 attempts." >&2
exit 1
build-bundles:
name: Build platform bundle (${{ matrix.platform }})
needs: [prepare, nightly-prepare, build-web]
@@ -874,17 +923,70 @@ jobs:
shasum -a 256 "kandev-${{ matrix.platform }}.zip" > "kandev-${{ matrix.platform }}.zip.sha256"
fi
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
- name: Upload runtime bundle (attempt 1)
id: upload_runtime_bundle_1
continue-on-error: true
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: bundle-${{ matrix.platform }}
# The zip entries match nothing on the four non-Windows platforms.
# if-no-files-found is left at its default so a missing tarball is
# still an error.
path: |
dist/kandev-${{ matrix.platform }}.tar.gz
dist/kandev-${{ matrix.platform }}.tar.gz.sha256
dist/kandev-${{ matrix.platform }}.zip
dist/kandev-${{ matrix.platform }}.zip.sha256
if-no-files-found: error
- name: Wait before runtime bundle upload retry (attempt 2)
if: steps.upload_runtime_bundle_1.outcome == 'failure'
run: |
echo "::warning::${{ matrix.platform }} runtime bundle upload attempt 1/3 failed; retrying in 30 seconds."
sleep 30
- name: Upload runtime bundle (attempt 2)
id: upload_runtime_bundle_2
if: steps.upload_runtime_bundle_1.outcome == 'failure'
continue-on-error: true
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: bundle-${{ matrix.platform }}
path: |
dist/kandev-${{ matrix.platform }}.tar.gz
dist/kandev-${{ matrix.platform }}.tar.gz.sha256
dist/kandev-${{ matrix.platform }}.zip
dist/kandev-${{ matrix.platform }}.zip.sha256
if-no-files-found: error
overwrite: true
- name: Wait before runtime bundle upload retry (attempt 3)
if: steps.upload_runtime_bundle_2.outcome == 'failure'
run: |
echo "::warning::${{ matrix.platform }} runtime bundle upload attempt 2/3 failed; retrying in 60 seconds."
sleep 60
- name: Upload runtime bundle (attempt 3)
id: upload_runtime_bundle_3
if: steps.upload_runtime_bundle_2.outcome == 'failure'
continue-on-error: true
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: bundle-${{ matrix.platform }}
path: |
dist/kandev-${{ matrix.platform }}.tar.gz
dist/kandev-${{ matrix.platform }}.tar.gz.sha256
dist/kandev-${{ matrix.platform }}.zip
dist/kandev-${{ matrix.platform }}.zip.sha256
if-no-files-found: error
overwrite: true
- name: Fail after runtime bundle upload retries
if: >-
steps.upload_runtime_bundle_1.outcome == 'failure' &&
steps.upload_runtime_bundle_2.outcome == 'failure' &&
steps.upload_runtime_bundle_3.outcome == 'failure'
run: |
echo "::error::${{ matrix.platform }} runtime bundle upload failed after 3 attempts." >&2
exit 1
build-desktop:
name: Build desktop app (${{ matrix.platform }})
@@ -898,6 +1000,7 @@ jobs:
needs.build-bundles.result == 'success'
}}
strategy:
fail-fast: false
matrix:
include:
- platform: macos-arm64
@@ -1428,10 +1531,57 @@ jobs:
fi
ls -lh "$out_dir"
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
- name: Upload desktop artifacts (attempt 1)
id: upload_desktop_artifacts_1
continue-on-error: true
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: desktop-${{ matrix.platform }}
path: dist/desktop-artifacts/*
if-no-files-found: error
- name: Wait before desktop artifact upload retry (attempt 2)
if: steps.upload_desktop_artifacts_1.outcome == 'failure'
run: |
echo "::warning::${{ matrix.platform }} desktop artifact upload attempt 1/3 failed; retrying in 30 seconds."
sleep 30
- name: Upload desktop artifacts (attempt 2)
id: upload_desktop_artifacts_2
if: steps.upload_desktop_artifacts_1.outcome == 'failure'
continue-on-error: true
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: desktop-${{ matrix.platform }}
path: dist/desktop-artifacts/*
if-no-files-found: error
overwrite: true
- name: Wait before desktop artifact upload retry (attempt 3)
if: steps.upload_desktop_artifacts_2.outcome == 'failure'
run: |
echo "::warning::${{ matrix.platform }} desktop artifact upload attempt 2/3 failed; retrying in 60 seconds."
sleep 60
- name: Upload desktop artifacts (attempt 3)
id: upload_desktop_artifacts_3
if: steps.upload_desktop_artifacts_2.outcome == 'failure'
continue-on-error: true
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: desktop-${{ matrix.platform }}
path: dist/desktop-artifacts/*
if-no-files-found: error
overwrite: true
- name: Fail after desktop artifact upload retries
if: >-
steps.upload_desktop_artifacts_1.outcome == 'failure' &&
steps.upload_desktop_artifacts_2.outcome == 'failure' &&
steps.upload_desktop_artifacts_3.outcome == 'failure'
run: |
echo "::error::${{ matrix.platform }} desktop artifact upload failed after 3 attempts." >&2
exit 1
# ---------------------------------------------------------------------------
# Docker base image — split per arch onto native runners, then stitched into