-
Notifications
You must be signed in to change notification settings - Fork 1
Add activate command #127
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
base: main
Are you sure you want to change the base?
Add activate command #127
Conversation
var activateCmd = &cobra.Command{ //nolint:gochecknoglobals | ||
Use: "activate", | ||
Short: "Activate various bitrise plugins", | ||
Long: `Activate Gradle, Bazel, etc. Plugins |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Long: `Activate Gradle, Bazel, etc. Plugins | |
Long: `Activate Gradle, Bazel, etc. plugins |
initGradlecontent, err := ReadActivatedPluginsFromInitGradle(filepath.Join(tmpGradleHomeDir, "init.d", "bitrise-build-cache.init.gradle.kts")) | ||
require.NoError(t, err) | ||
expected := `import io.bitrise.gradle.cache.BitriseBuildCache | ||
import io.bitrise.gradle.cache.BitriseBuildCacheServiceFactory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to test the output config file in a detailed way? We have tests for the config in gradleconfig_test.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic in the activate where we turn mostly boolean flags into 3 way states and that some configurations are not required for dep only additions wouldn't be tested by the gradleconfig tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see the problem, it's that writeGradleInit
is a function, not a struct that can be mocked. I'd extract it to a proper testable package/struct/interface and just assert the preferences it gets from the commands
} | ||
|
||
// Generate init.gradle content. | ||
// Recommended to save the content into $HOME/.gradle/init.d/ instead of | ||
// overwriting the $HOME/.gradle/init.gradle file. | ||
func GenerateInitGradle(endpointURL, authToken string, preferences Preferences, cacheConfigMetadata common.CacheConfigMetadata) (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice cleanup 👍🏻
classpath("io.bitrise.gradle:gradle-analytics:2.1.28") | ||
classpath("io.bitrise.gradle:remote-cache:1.2.19") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to update the version bump automation
maven(url="https://jitpack.io") | ||
} | ||
dependencies { | ||
classpath("io.bitrise.gradle:gradle-analytics:2.1.28") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah these will also have to be updated in the bump automation, I think it's not ideal
return "", fmt.Errorf("generate init.gradle, error: %w", errAuthTokenNotProvided) | ||
} | ||
|
||
if len(endpointURL) < 1 { | ||
if len(preferences.Cache.EndpointURL) < 1 && preferences.Cache.Usage == UsageLevelEnabled { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add the same check for analytics too, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the other endpoints are coming from consts, cache endpoint was overrideable from the CLI.
EndpointURLWithPort string | ||
IsPushEnabled bool | ||
ValidationLevel string | ||
Metadata common.CacheConfigMetadata |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we move this to the top level? All plugins need the metadata
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
|
||
bitrise { | ||
{{- if .AppSlug }} | ||
appSlug.set("{{ .AppSlug }}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not in the metadata?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving the metadata outside and making this part of it
No description provided.