Skip to content

Add GitHub Action for Cartesi setup - #1

Merged
tuler merged 4 commits into
mainfrom
claude/cartesi-tools-github-action-w3pzq1
Aug 7, 2026
Merged

Add GitHub Action for Cartesi setup#1
tuler merged 4 commits into
mainfrom
claude/cartesi-tools-github-action-w3pzq1

Conversation

@tuler

@tuler tuler commented Aug 6, 2026

Copy link
Copy Markdown
Member

Summary

This PR introduces a complete GitHub Action that installs the Cartesi Machine emulator and Cartesi CLI on CI runners, enabling workflows to build, run, and test Cartesi applications.

Key Changes

  • Action Implementation: Created a fully functional GitHub Action (action.yml) with configurable inputs for machine version, CLI version, and checksum verification

  • Core Modules:

    • main.ts: Entry point orchestrating the installation workflow
    • machine.ts: Handles Cartesi Machine emulator installation and setup
    • cli.ts: Manages Cartesi CLI installation
    • images.ts: Manages kernel and rootfs image downloads with checksum verification
    • github.ts: GitHub API client for fetching release assets
    • checksum.ts: SHA-256 verification utilities for downloaded artifacts
    • inputs.ts: Input parsing and validation (versions, checksums, flags)
    • platform.ts: Platform detection (Linux/macOS, amd64/arm64)
    • system.ts: System-level utilities (root detection)
    • constants.ts: Hard-coded security-critical URLs and repository references
  • Testing: Comprehensive test suite covering:

    • Input parsing and validation
    • Checksum verification
    • GitHub release asset discovery
    • Platform detection
    • Dependencies lock file parsing
  • CI/CD:

    • GitHub Actions workflows for testing and building
    • Dependabot configuration for dependency updates
    • Build script for bundling the action into a single distributable file
  • Documentation & Configuration:

    • Detailed README with usage examples and input descriptions
    • Security policy for vulnerability reporting
    • Apache 2.0 license
    • TypeScript configuration with strict type checking
    • Biome configuration for code formatting and linting

Notable Implementation Details

  • Security: All remote URLs are hard-coded in constants.ts to prevent workflow input injection attacks
  • Checksum Verification: Supports both inline checksums and asset digest parsing from GitHub releases
  • Platform Support: Automatically detects OS and architecture, supporting Linux and macOS on amd64 and arm64
  • Caching: Leverages GitHub Actions tool-cache for efficient artifact management
  • Distributed Bundle: The action is bundled into dist/index.js for direct runner execution without requiring Node.js installation

https://claude.ai/code/session_01C2NraPGxBnuRLarrZf5YSL

Installs the Cartesi Machine emulator and the Cartesi CLI on Linux and
macOS runners, on x86_64 and arm64.

- emulator: machine-emulator_<arch>.deb installed through apt-get on
  Linux, cartesi/tap Homebrew formula on macOS
- images: kernel and rootfs images pinned by the emulator release's
  dependencies.lock, installed where the emulator looks for them, and
  exported as CARTESI_IMAGES_PATH
- CLI: @cartesi/cli from npm, alpha dist-tag by default, installed into
  the runner tool cache

Both tools default to the latest release and can be pinned, or skipped
with 'none'.

Security: download sources are hardcoded constants that no input can
redirect, every artifact is verified against a SHA-256 digest, inputs
are validated against strict patterns and passed as argument arrays
rather than through a shell, npm lifecycle scripts are disabled, and
root is used only for apt-get and for copying the images into place.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C2NraPGxBnuRLarrZf5YSL
@tuler
tuler requested a review from endersonmaia August 6, 2026 21:00
claude added 3 commits August 6, 2026 21:13
Migrates the configuration to the v2 schema (files.includes with
negated patterns, linter.rules.preset) and applies the v2 import
sorting, which orders inline type imports by name.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C2NraPGxBnuRLarrZf5YSL
Homebrew refuses to load formulae from third-party taps until they are
trusted. Naming cartesi/tap/cartesi-machine on the install command line
auto-trusts that formula, but it is a metapackage, so the install still
aborted on its dependency:

  Refusing to load formula cartesi/tap/cartesi-machine-emulator from
  untrusted tap cartesi/tap.

Trust the individual formulae being installed, rather than the whole tap,
so trust does not extend to formulae the tap may add later. Homebrew
versions without the trust concept fail the command harmlessly; brew
install remains the real gate.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C2NraPGxBnuRLarrZf5YSL
Releasing is now `git tag v1.2.3 && git push origin v1.2.3`. The workflow
verifies dist/ matches src/ at the tagged commit, runs lint, typecheck and
tests, creates the GitHub release (freezing the tag and generating a release
attestation), and force-moves the floating v1 and v1.2 tags.

The floating tags deliberately get no release attached, which is what keeps
them movable while immutable releases are enabled, and only those two refs
are pushed -- `git push --tags` would also try to force-push the frozen
release tags.

The trigger is a tag push rather than `release: published`: events produced
with GITHUB_TOKEN do not start further workflow runs, so a workflow that
created the release could never hand off to one that moves the tags.

Also adds workflow_dispatch to CI so the suite can be run on demand, and
keeps local biome runs from tripping over untracked editor settings.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C2NraPGxBnuRLarrZf5YSL
@tuler

tuler commented Aug 6, 2026

Copy link
Copy Markdown
Member Author

Another alternative was two separate actions: setup-emulator-action, and setup-cli-action. But I think this is good enough. More packages might exist in the future (like rollups-node), so having one repo for each will be too much work to maintain.

@tuler
tuler merged commit b73bf8c into main Aug 7, 2026
24 of 25 checks passed
@tuler
tuler deleted the claude/cartesi-tools-github-action-w3pzq1 branch August 7, 2026 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants