Skip to content

Make CI Configuration Branch-Agnostic and Reusable #31

@thorwhalen

Description

@thorwhalen

Summary

The current CI configuration (see actions and example CI hardcodes the master branch in several places, such as:

uses: i2mint/isee/actions/install-packages@master

and

if: "!contains(github.event.head_commit.message, '[skip ci]') && github.ref == 'refs/heads/master'"

This approach makes the CI non-reusable across projects where the default branch may be named differently (e.g., main, dev, etc.). To address this, we propose a solution that allows branch specification to be more flexible, enabling reusability and adaptability for different repository configurations.

Problem Statement

Hardcoding the branch name as master introduces the following limitations:
1. Incompatibility with projects using different default branch names, such as main or dev.
2. Difficulty in maintaining and reusing CI across multiple repositories without customization.
3. Inability to adapt to changes in the default branch of a repository over time.

Proposed Solutions

To address these limitations, we propose implementing a flexible system for specifying branches. This system can be a combination of the following solutions:

1.	Specify CI-triggering branch as a variable:

Allow the branch to be defined in the env section or as an input variable, making it easy to change across different repositories. Example:

env:
  DEFAULT_BRANCH: main
2.	Support multiple branch names:

Enable specifying an array of branch names, where the CI uses the first one found. This approach would allow fallbacks. Example:

env:
  TRIGGER_BRANCHES: ["main", "master"]
3.	Default to the repository’s default branch:

Detect the repository’s default branch dynamically during the CI run and use that as the trigger. This would make the CI even more robust. For example, a reserved variable like $default_branch could represent the repository’s default branch, and the CI would resolve it at runtime.

4.	Combine approaches for maximum flexibility:

Allow users to define branches in a hierarchical manner, e.g., supporting a mix of explicit branch names and the dynamic $default_branch. Example:

env:
  BRANCH_PREFERENCES: ["main", "master", "$default_branch"]

Implementation Considerations

•	Backward Compatibility: The default branch variable should have a sensible fallback (e.g., defaulting to master if unspecified).
•	Performance: Detecting the default branch dynamically should be efficient and not impact CI runtime significantly.
•	User Experience: Provide clear documentation and examples to make configuring branch preferences intuitive.

Benefits

•	Increased reusability of the CI configuration across repositories.
•	Easier adaptation to repositories with non-standard default branch names.
•	Improved maintainability by avoiding hardcoded branch names.
•	Future-proofing the CI to handle potential changes in branch naming conventions.

Next Steps

1.	Discuss and finalize the preferred implementation strategy (variable-based, detection-based, or a blend).
2.	Develop and test the changes to support branch-agnostic configurations.
3.	Update documentation with clear instructions and examples.

Let us know your thoughts and preferences on the proposed solutions!

This issue template lays out the problem clearly, proposes multiple solutions, and highlights the benefits.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions