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

Version Override #213

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ Documenting All Changes to the Skelebot Project

---

## v1.27.3
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will need to be updated from master now

#### Changed
- **Version** | Added the ability to set the version in the config yaml and have it override the VERSION file value

---

## v1.27.2
#### Changed
- **Scaffolding** | Fixed minor bug in scaffolding output text
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.27.2
1.27.3
6 changes: 6 additions & 0 deletions docs/versioning.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ By default the project will start with version 0.1.0 (initial pre-release versio
> skelebot bump [major, minor, patch]
```

The value from the `VERSION` file can be overridden by specifiying the value in the config yaml file directly. This allows different env configs to specify their own version if needed.

```
version: 1.0.0
```

More information on semantic versioning (when to bump major, minor, and patch) can be found on [semver.org](https://semver.org/).

---
Expand Down
3 changes: 2 additions & 1 deletion skelebot/objects/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Config(SkeleYaml):
'name': And(str, error='\'name\' must be a String'),
Optional('env'): And(str, error='\'env\' must be a String'),
Optional('description'): And(str, error='\'description\' must be a String'),
Optional('version'): And(str, error='\'version\' must be a String'),
Optional('maintainer'): And(str, error='\'maintainer\' must be a String'),
Optional('contact'): And(str, error='\'contact\' must be a String'),
Optional('host'): And(str, error='\'host\' must be a String'),
Expand Down Expand Up @@ -188,7 +189,7 @@ def load(cls, config):
cls.validate(config)
values = {}
for attr, value in config.items():
if (attr in vars(Config)) and (attr != "components") and (attr != "version"):
if (attr in vars(Config) and (attr != "components")):
if (attr == "jobs"):
values[attr] = Job.loadList(value)
elif (attr == "params"):
Expand Down
3 changes: 2 additions & 1 deletion skelebot/systems/generators/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ def loadConfig(env=None):

config = Config.load(readYaml(env))
config.env = env
config.version = loadVersion()
if (config.version is None):
config.version = loadVersion()
return config

def saveConfig(config):
Expand Down
1 change: 1 addition & 0 deletions test/files/skelebot-test.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
version: "0.0.1"
ephemeral: true
ignores:
- 'data/'
Expand Down
2 changes: 2 additions & 0 deletions test/test_objects_config_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def validate_error(self, attr, reset, expected):

try:
sb.objects.config.Config.validate(config)
self.fail("Validation Did Not Raise Error")
except SchemaError as error:
self.assertEqual(error.code, "'{attr}' must be {expected}".format(attr=attr, expected=expected))

Expand All @@ -57,6 +58,7 @@ def test_invalid_mising(self):

def test_invalid(self):
self.validate_error('name', 123, 'a String')
self.validate_error('version', 1.2, 'a String')
self.validate_error('env', 123, 'a String')
self.validate_error('description', 123, 'a String')
self.validate_error('maintainer', 123, 'a String')
Expand Down
10 changes: 5 additions & 5 deletions test/test_systems_generators_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ class TestYaml(unittest.TestCase):
def setUp(self):
self.path = os.getcwd()

def validateYaml(self, config, isTestEnv=False):
def validateYaml(self, config, version, isTestEnv=False):
self.assertEqual(config.name, "test")
self.assertEqual(config.description, "test cases")
self.assertEqual(config.version, "6.6.6")
self.assertEqual(config.version, version)
self.assertEqual(config.maintainer, "Mega Man")
self.assertEqual(config.contact, "[email protected]")
self.assertEqual(config.language, "Python")
Expand Down Expand Up @@ -65,7 +65,7 @@ def test_loadConfig_with_yaml(self, mock_getcwd, mock_expanduser):
mock_expanduser.return_value = "{path}/test/plugins".format(path=self.path)
mock_getcwd.return_value = "{path}/test/files".format(path=self.path)
config = sb.systems.generators.yaml.loadConfig()
self.validateYaml(config)
self.validateYaml(config, "6.6.6")

# Test to ensure that the config loads from skelebot.yaml properly even if a bad plugin is found and quarantined
@mock.patch('skelebot.components.componentFactory.print')
Expand All @@ -92,7 +92,7 @@ def test_loadConfig_with_env(self, mock_getcwd, mock_expanduser):
mock_expanduser.return_value = "{path}/test/plugins".format(path=self.path)
mock_getcwd.return_value = "{path}/test/files".format(path=self.path)
config = sb.systems.generators.yaml.loadConfig("test")
self.validateYaml(config, True)
self.validateYaml(config, "0.0.1", True)

# Test to ensure that the config loads from skelebot.yaml and overwrites with skelebot-test.yaml properly
@mock.patch('os.path.expanduser')
Expand Down Expand Up @@ -147,7 +147,7 @@ def test_saveConfig(self, mock_getcwd, mock_expanduser):

sb.systems.generators.yaml.saveConfig(config)
config = sb.systems.generators.yaml.loadConfig()
self.validateYaml(config)
self.validateYaml(config, "6.6.6")


if __name__ == '__main__':
Expand Down