Skip to content

Reuse artifacts generated for other branches when appropriate #57

Description

@AlexTMjugador

Related problem

Currently, the action caching logic is tuned to err on the safe side in some complex situations, isolating the artifacts generated in previous runs per branch.

The rationale behind the isolation is that each branch may contain a totally unrelated commit history, so it'd be incorrect for the action to reuse artifacts from potentially unrelated packs in different branches (e.g., the pack.png file from the pack at branch a should not be confused with the pack.png file from the pack at branch b, if b is the mainline for a different pack).

However, in several practical scenarios inter-branch artifact reuse is correct and possible. For example, feature branches share a common ancestor commit with the mainline, so the artifact generated for that ancestor can be safely reused for the feature branch.

If implemented right, this idea has the potential of substantially speeding up practical workflows.

Proposed solution

Change the last artifact retrieval and storage algorithm:

  • When looking for the previous artifact, first look for an artifact in the current branch, like it is done now. If that fails, for the branch this workflow is running on, find other branches that share a common ancestor commit, and take note of that ancestor commit. Then find the artifact related to that commit (exactly how is a good question). If there are several branches that share an ancestor, prefer the one that has diverged less (i.e., has the shortest distance to the ancestor).
  • When storing the previous artifact, save in the cache any information needed to implement this previous point, apart from the system ID.

Alternative solutions

  • Add action inputs to manually select what branches are okay to reuse. I think that is not a proper solution because it'd shift the problem to end-users, and be prone to issues if branch policies are not strictly enforced.

Additional context

This was suggested by Mergu#0001 on Discord: https://discord.com/channels/85364538328768512/831829590502408193/1033822435822284820

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions