Skip to content

Add SauceLabs build pruning script #3297

@jleach

Description

@jleach

Summary

All feature branch builds are now pushed to SauceLabs (SL), causing build accumulation. We need a script to prune stale PR builds once they've been superseded by a release candidate on main.

Background

Our CI (ship-to-saucelabs action) uploads builds to SauceLabs with the following tagging scheme:

  • PR builds: tagged pr, pr-<number>
  • Main branch builds: tagged rc

Build names include github.run_number (e.g. BCWallet-1234.ipa). Uploads target both iOS and Android across two build types (bc-wallet, single-app), so there are 4 artifacts per CI run.

API endpoint: https://api.us-west-1.saucelabs.com/v1/storage/ (auth via SAUCE_USERNAME + SAUCE_ACCESS_KEY).

Requirements

Pruning Logic

  1. Query SauceLabs storage API for all files tagged rc
  2. Extract the greatest build number (from the filename, e.g. BCWallet-1234.ipa1234)
  3. Query all files tagged pr
  4. Delete any pr-tagged file whose build number is less than the max rc build number

Script

  • Language: Node.js
  • Location: scripts/prune-saucelabs/ (with its own package.json)
  • Auth: Read SAUCE_USERNAME and SAUCE_ACCESS_KEY from environment variables
  • Dry-run by default: The script should default to dry-run mode (list what would be deleted). Require an explicit --execute flag to actually delete.
  • Logging: Print a summary of what was found and what was (or would be) deleted
  • Platforms: Prune both iOS (.ipa) and Android (.aab) builds

Future Work (out of scope for this issue)

  • Add a scheduled GitHub Action to run this script periodically

Acceptance Criteria

  • Script lives at scripts/prune-saucelabs/
  • Defaults to dry-run; --execute flag performs actual deletion
  • Correctly identifies max rc build number and prunes older pr builds
  • Handles both iOS and Android artifacts
  • Works with SauceLabs v1 storage API
  • Logs clearly what it finds and what it deletes (or would delete)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions