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

add support for bumping multiple files. #3

Merged
merged 3 commits into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ cat pkg/version/version.go
- `version_bump_type`
- `version_metadata_path`
- `generic_version_template`
- `addl_version_metadata_paths`

# Outputs
- `release_version`
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/packagrio/bumpr

go 1.13
go 1.18

require (
github.com/Masterminds/semver v1.5.0
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func (c *configuration) Init() error {
c.SetDefault(PACKAGR_SCM, "default")
c.SetDefault(PACKAGR_VERSION_BUMP_TYPE, "patch")
c.SetDefault(PACKAGR_ENGINE_REPO_CONFIG_PATH, "packagr.yml")
c.SetDefault(PACKAGR_ADDL_VERSION_METADATA_PATHS, map[string]string{})

//set the default system config file search path.
//if you want to load a non-standard location system config file (~/capsule.yml), use ReadConfig
Expand Down
22 changes: 22 additions & 0 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ func TestConfiguration_init_ShouldCorrectlyInitializeConfiguration(t *testing.T)
require.Equal(t, "generic", testConfig.GetString(config.PACKAGR_PACKAGE_TYPE), "should populate package_type with generic default")
require.Equal(t, "default", testConfig.GetString(config.PACKAGR_SCM), "should populate scm with default")
require.Equal(t, "patch", testConfig.GetString(config.PACKAGR_VERSION_BUMP_TYPE), "should populate runner with default")
require.Equal(t, map[string]interface{}{}, testConfig.GetStringMap(config.PACKAGR_ADDL_VERSION_METADATA_PATHS), "should populate addl metadata paths from config file")

}

func TestConfiguration_init_EnvVariablesShouldLoadProperly(t *testing.T) {
Expand Down Expand Up @@ -55,3 +57,23 @@ func TestConfiguration_ReadConfig(t *testing.T) {
require.Equal(t, "major", testConfig.GetString(config.PACKAGR_VERSION_BUMP_TYPE), "should populate Engine Version Bump Type from overrides config file")

}

func TestConfiguration_ReadConfig_AddlVersionMetadataPaths(t *testing.T) {
//setup
defer utils.UnsetEnv("PACKAGR_")()
testConfig, _ := config.Create()
testConfig.SetDefault(config.PACKAGR_PACKAGE_TYPE, "generic")
testConfig.SetDefault(config.PACKAGR_SCM, "default")
testConfig.SetDefault(config.PACKAGR_VERSION_BUMP_TYPE, "patch")

//test
err := testConfig.ReadConfig(path.Join("testdata", "addl_version_metadata_paths.yml"))

//assert
require.NoErrorf(t, err, "No error")
require.Equal(t, "golang", testConfig.GetString(config.PACKAGR_PACKAGE_TYPE), "should populate Package Type from overrides config file")
require.Equal(t, "github", testConfig.GetString(config.PACKAGR_SCM), "should populate SCM from overrides config file")
require.Equal(t, "major", testConfig.GetString(config.PACKAGR_VERSION_BUMP_TYPE), "should populate Engine Version Bump Type from overrides config file")
require.Equal(t, map[string]interface{}{"node": []interface{}{"package.json"}}, testConfig.GetStringMap(config.PACKAGR_ADDL_VERSION_METADATA_PATHS), "should populate addl metadata paths from config file")

}
3 changes: 3 additions & 0 deletions pkg/config/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ type Interface interface {
GetInt(key string) int
GetString(key string) string
GetStringSlice(key string) []string
GetStringMapString(key string) map[string]string
GetStringMap(key string) map[string]interface{}
UnmarshalKey(key string, rawVal interface{}, decoder ...viper.DecoderConfigOption) error
ReadConfig(configFilePath string) error
}
Expand All @@ -25,5 +27,6 @@ const PACKAGR_PACKAGE_TYPE = "package_type"
const PACKAGR_SCM = "scm"
const PACKAGR_VERSION_BUMP_TYPE = "version_bump_type"
const PACKAGR_VERSION_METADATA_PATH = "version_metadata_path"
const PACKAGR_ADDL_VERSION_METADATA_PATHS = "addl_version_metadata_paths"
const PACKAGR_ENGINE_REPO_CONFIG_PATH = "engine_repo_config_path"
const PACKAGR_GENERIC_VERSION_TEMPLATE = "generic_version_template"
208 changes: 124 additions & 84 deletions pkg/config/mock/mock_config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions pkg/config/testdata/addl_version_metadata_paths.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package_type: 'golang'
scm: 'github'
version_bump_type: 'major'
addl_version_metadata_paths:
node:
- 'package.json'
Loading