Skip to content

Conversation

mjcheetham
Copy link
Member

Most of the logic of this GitHub Action is portable to other CI systems, apart from those functions in @actions/core and @actions/cache.

Introduce an abstraction ICore and a corresponding implementation for GitHub Actions that is just a very thin layer over the @actions/* module functions.

The only logic change here is the introduce of this block:

    if (!core.isCacheAvailable()) {
      useCache = false
    }

Other CI systems may not support caching, so we add a check for this and disable the caching behaviour if not available. For the GitHub Actions implementation of ICore, we could just return true, but there is also an isFeatureAvailable() function in @actions/cache that we should probably have always been checking.

In a future PR I plan to add a very simple 'shim' or wrapper to expose an Azure Pipelines task.

@mjcheetham mjcheetham requested a review from dscho August 28, 2025 17:19
Copy link
Member

@dscho dscho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, apart from the failures to build the tests ;-)

src/__tests__/git.test.ts(36,48): error TS2554: Expected 3-4 arguments, but got 2.
src/__tests__/git.test.ts(69,48): error TS2554: Expected 3-4 arguments, but got 2.

@mjcheetham mjcheetham marked this pull request as ready for review August 29, 2025 11:07
Introduce a simple abstraction of the @actions/core module, such that we
can provide a different implementation in the future (for Azure
Pipelines, for example).

Rename 'run' to 'setup' (which is the sibling to 'cleanup'), and add a
new 'run' function that takes only an ICore implementation, using
@actions/core.

Signed-off-by: Matthew John Cheetham <[email protected]>
In a similar way to @actions/core, we abstract the @actions/cache
functions.

Signed-off-by: Matthew John Cheetham <[email protected]>
Move the shared orchestration logic of the action out of main.ts into a
new file src/action.ts. The main.ts file now just calls through to the
run() function, with an ICore instance using @actions/core and
@actions/cache.

Signed-off-by: Matthew John Cheetham <[email protected]>
@mjcheetham mjcheetham requested a review from dscho August 29, 2025 11:18
Move any usages of @actions/* packages out of the `src/` subdirectory,
and just inline the ActionsCore implementation in the main.ts file.

Also there's no need to actually use ActionsCore in the git.test.ts
tests, since we're mocking anyway. Just provide an inline no-op
implementation.

Signed-off-by: Matthew John Cheetham <[email protected]>
@rimrul
Copy link
Member

rimrul commented Aug 31, 2025

In a future PR I plan to add a very simple 'shim' or wrapper to expose an Azure Pipelines task.

Didn't we move away from Azure Pipelines? Is this a microsoft/git thing? Is this just the CI system that's easiest to produce a proof of concept use of the abstraction for?

@dscho
Copy link
Member

dscho commented Aug 31, 2025

In a future PR I plan to add a very simple 'shim' or wrapper to expose an Azure Pipelines task.

Didn't we move away from Azure Pipelines?

Yes, we did. Back when we started this move, the official communication was that Azure DevOps users are highly encouraged to move to GitHub. For... reasons... this seems to have changed.

Is this a microsoft/git thing?

Yes. For... reasons... microsoft/git will need to be built in Azure Pipelines again.

Is this just the CI system that's easiest to produce a proof of concept use of the abstraction for?

It's more like this is the reason for the abstraction.

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