Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appetite for abstraction to other build environments #502

Open
Nava2 opened this issue Dec 30, 2024 · 6 comments
Open

Appetite for abstraction to other build environments #502

Nava2 opened this issue Dec 30, 2024 · 6 comments

Comments

@Nava2
Copy link
Contributor

Nava2 commented Dec 30, 2024

We use non-Github Actions CI pipelines for our build systems. We'd love to be able to contribute and leverage the existing tooling within the Gradle GitHub actions within other CI tools.

I wonder if there is appetite to refactor components of the GitHub actions to be published as npm packages and abstract the GitHub actions aspects away such that the common code can be reused within other environments.

I'd be willing to take on some of this refactoring as we would be able to reuse caching particularly in our environments!

Nava2 added a commit to Nava2/gradle-actions that referenced this issue Jan 9, 2025
This adds a new pattern for abstracting away the "github action"-specific code within the github actions. The
overall intention is to perform this change for all of the `@actions/xxx` libraries in use to enable
implementation of these features within other environments (e.g. Jenkins, BuildKite, GitLab).

Part of gradle#502.
Nava2 added a commit to Nava2/gradle-actions that referenced this issue Jan 9, 2025
Following #18, we finish replacing all usages. This was split to enable easier
review and acknowledge there's a couple small behaviour changes using `true.toString()` for example.

Part of gradle#502.
Nava2 added a commit to Nava2/gradle-actions that referenced this issue Jan 9, 2025
In order to support more environments, we abstract away `@actions/core`'s logging functionality
behind it's own type. This allows replacement with environment-specific versions.

Note: This PR does not replace all, there is a follow-up to finish replacing. The intention is
to have the new content reviewed vs. the "find and replace" PR following.

Part of gradle#502.
Nava2 added a commit to Nava2/gradle-actions that referenced this issue Jan 9, 2025
Following #TODO, we replace all usages of logging calls with their equivalent abstracted versions.

Part of gradle#502.
Nava2 added a commit to Nava2/gradle-actions that referenced this issue Jan 9, 2025
Following #18, we finish replacing all usages. This was split to enable easier
review and acknowledge there's a couple small behaviour changes using `true.toString()` for example.

Part of gradle#502.
Nava2 added a commit to Nava2/gradle-actions that referenced this issue Jan 9, 2025
In order to support more environments, we abstract away `@actions/core`'s logging functionality
behind it's own type. This allows replacement with environment-specific versions.

Note: This PR does not replace all, there is a follow-up to finish replacing. The intention is
to have the new content reviewed vs. the "find and replace" PR following.

Part of gradle#502.
Nava2 added a commit to Nava2/gradle-actions that referenced this issue Jan 9, 2025
Following #TODO, we replace all usages of logging calls with their equivalent abstracted versions.

Part of gradle#502.
Nava2 added a commit to Nava2/gradle-actions that referenced this issue Jan 9, 2025
In order to support more environments, we abstract away `@actions/core`'s logging functionality
behind it's own type. This allows replacement with environment-specific versions.

Note: This PR does not replace all, there is a follow-up to finish replacing. The intention is
to have the new content reviewed vs. the "find and replace" PR following.

Part of gradle#502.
Nava2 added a commit to Nava2/gradle-actions that referenced this issue Jan 9, 2025
Following #TODO, we replace all usages of logging calls with their equivalent abstracted versions.

Part of gradle#502.
Nava2 added a commit to Nava2/gradle-actions that referenced this issue Jan 10, 2025
Following #18, we finish replacing all usages. This was split to enable easier
review and acknowledge there's a couple small behaviour changes using `true.toString()` for example.

Part of gradle#502.
Nava2 added a commit to Nava2/gradle-actions that referenced this issue Jan 10, 2025
In order to support more environments, we abstract away `@actions/core`'s logging functionality
behind it's own type. This allows replacement with environment-specific versions.

Note: This PR does not replace all, there is a follow-up to finish replacing. The intention is
to have the new content reviewed vs. the "find and replace" PR following.

Part of gradle#502.
Nava2 added a commit to Nava2/gradle-actions that referenced this issue Jan 10, 2025
Following #TODO, we replace all usages of logging calls with their equivalent abstracted versions.

Part of gradle#502.
@bigdaz
Copy link
Member

bigdaz commented Jan 14, 2025

@Nava2 Thanks for your interest in the project. Indeed it could be useful to be able to apply similar logic to other CI platforms. However, there are features of GitHub Actions that we depend on that mean this isn't so simple.

I can see value in abstracting away from the direct use of GitHub APIs for logging and other features, but before commencing this project I think it would be helpful to consider some of the core features that we rely on in GitHub Actions.

A primary use case for setup-gradle is to save and restore content in Gradle User Home. The current implementation leverages some properties of the GitHub Actions cache that are likely not present in other systems.

So as a first step to making the setup-gradle action applicable in other environments, I think it would be good to consider how we could adopt the caching mechanism to leverage other storage backends, like Amazon S3. This would be very useful for existing users of GitHub Actions, and would likely ease the complete migration of setup-gradle to other CI platforms.

Are you interested in helping push things forward in that direction?

@Nava2
Copy link
Contributor Author

Nava2 commented Jan 14, 2025

@Nava2 Thanks for your interest in the project. Indeed it could be useful to be able to apply similar logic to other CI platforms. However, there are features of GitHub Actions that we depend on that mean this isn't so simple.

I can see value in abstracting away from the direct use of GitHub APIs for logging and other features, but before commencing this project I think it would be helpful to consider some of the core features that we rely on in GitHub Actions.

Is there specific ones of concern? Reimplementing the cache save/restore is definitely more effort but doesn't seem particularly sophisticated in my very ignorant and open minded view 😅

A primary use case for setup-gradle is to save and restore content in Gradle User Home. The current implementation leverages some properties of the GitHub Actions cache that are likely not present in other systems.

Which features in particular are you referencing? I think with enough elbow grease anything could technically be implemented.

So as a first step to making the setup-gradle action applicable in other environments, I think it would be good to consider how we could adopt the caching mechanism to leverage other storage backends, like Amazon S3. This would be very useful for existing users of GitHub Actions, and would likely ease the complete migration of setup-gradle to other CI platforms.

We're exactly aligned. With a proper abstraction layer in place, this seems like a reasonable thing to try and implement. Without a layer, it gets tough.

Are you interested in helping push things forward in that direction?

Absolutely, I've been chipping away at abstracting the environment in a fork for awhile now. It's not too difficult to do easily without impacting the GitHub actions version.

@Nava2
Copy link
Contributor Author

Nava2 commented Jan 14, 2025

https://github.com/Nava2/gradle-actions/pull/18/files here is an example of some abstraction

@bigdaz
Copy link
Member

bigdaz commented Jan 14, 2025

Which features in particular are you referencing? I think with enough elbow grease anything could technically be implemented.

some properties of the GitHub Actions cache

Implementing this won't be a simple matter of adapting to a different API, but will require re-design and re-implementation of some of the features.

I'd like to have a plan for implementing caching on a regular key-value store before investing much effort into the simpler process of abstraction away basic APIs. And if we have a plan then we could implement something on top of S3 (or another store): this would be hugely beneficial to current users of setup-gradle, since the GHA implementation can be quite limited.

@Nava2
Copy link
Contributor Author

Nava2 commented Jan 14, 2025

Which features in particular are you referencing? I think with enough elbow grease anything could technically be implemented.

some properties of the GitHub Actions cache

Implementing this won't be a simple matter of adapting to a different API, but will require re-design and re-implementation of some of the features.

I'd like to have a plan for implementing caching on a regular key-value store before investing much effort into the simpler process of abstraction away basic APIs. And if we have a plan then we could implement something on top of S3 (or another store): this would be hugely beneficial to current users of setup-gradle, since the GHA implementation can be quite limited.

Ah, apologies that original link wasn't directly linking on mobile. I see where you're coming from.

It seems like for each case listed there's some possibilities:

  • Immutable entries: once a cache entry is written for a key, it cannot be overwritten or changed.

Pardon my ignorance, but this seems like a good thing for consistency purposes 😅

This seems a bit more tricky to implement and a little surprising. Though, could also decide to abstract and avoid this feature.

Seems like some providers have this support:

Seems reasonable -- more than I even expected 🤔

All in, I'm aligned that a proper design would be beneficial to ensuring we're iterating with a purpose.

@Starlight220
Copy link

Docker's build cache supports a variety of these backends, perhaps something there can be used as a reference.

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

No branches or pull requests

3 participants