Skip to content

Suggestions for improvement #2

@Systemic-Void

Description

@Systemic-Void

While the workflow is very good, there are a few areas that could be refined for even greater simplicity and resilience.

1. Simplify Package Building with fpm

The workflow uses fpm (Effing Package Management) to build the RPM package but constructs the Debian package manually using dpkg-deb and writing scripts from scratch. The manual process is very verbose (over 100 lines).

  • Suggestion: Use fpm to build both the .deb and .rpm packages. fpm is perfectly capable of creating .deb packages and can handle dependencies, maintainer scripts (postinst, postrm), and file ownership just as well.

  • Benefit: This would dramatically reduce the code size and complexity of the build-packages job, making it easier to maintain. The configuration for both package types would be nearly identical and centralized in one fpm command per architecture.

2. Reduce Code Duplication (DRY Principle)

The helper functions find_main_executable and install_icon are defined twice: once in the Build DEB package step and again in the Build RPM package step.

  • Suggestion: Define these helper functions once at the beginning of the build-packages job and export them so they are available to all subsequent steps within that job.

    - name: Define helper functions
      run: |
        echo 'find_main_executable() { ... }' >> $GITHUB_ENV
        echo 'export -f find_main_executable' >> $GITHUB_ENV
        echo 'install_icon() { ... }' >> $GITHUB_ENV
        echo 'export -f install_icon' >> $GITHUB_ENV
  • Benefit: This follows the "Don't Repeat Yourself" (DRY) principle, making the code cleaner and ensuring that any future changes to these functions only need to be made in one place.

3. Enhance Script Reliability

The shell scripts within the run blocks could be made more resilient to unexpected errors.

  • Suggestion: Add set -e at the beginning of multi-line scripts. This command ensures that the script will exit immediately if any command fails. For example, in the check-version job, if the curl or jq command fails, the script currently proceeds with empty variables, which can lead to confusing failures later on.

    # In the 'check-version' job
    id: check
    run: |
      set -e
      X64_RESPONSE=$(curl -s "...")
      # ... rest of the script
  • Benefit: This practice leads to faster, more obvious failures, which simplifies troubleshooting.

4. Consolidate API Calls

The check-version job makes two separate curl requests to the Cursor API, one for each architecture. It then assumes that the version and commitSha are identical in both responses.

  • Suggestion: While the assumption is likely safe, a more robust approach would be to make one API call (e.g., for x64), extract the version, and then construct the ARM64 download URL or verify that the version matches. This depends on whether the API guarantees version parity between architectures. If it does, the current approach is fine, but a comment acknowledging the assumption would be helpful.

  • Benefit: This slightly reduces network traffic and removes the implicit assumption about the API's behavior from the code's logic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions