Skip to content

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Add activate command #127

wants to merge 3 commits into from

Conversation

Badlazzor
Copy link
Contributor

No description provided.

var activateCmd = &cobra.Command{ //nolint:gochecknoglobals
Use: "activate",
Short: "Activate various bitrise plugins",
Long: `Activate Gradle, Bazel, etc. Plugins
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
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
Copy link
Collaborator

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

Copy link
Contributor Author

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.

Copy link
Collaborator

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) {
Copy link
Collaborator

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")
Copy link
Collaborator

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")
Copy link
Collaborator

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 {
Copy link
Collaborator

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?

Copy link
Contributor Author

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
Copy link
Collaborator

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

Copy link
Contributor Author

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 }}")
Copy link
Collaborator

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?

Copy link
Contributor Author

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

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.

2 participants