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 build-version option for building specific versions of ECS #851

Merged
merged 5 commits into from
May 15, 2020

Conversation

marshallmain
Copy link
Contributor

@marshallmain marshallmain commented May 14, 2020

Closes #837
This provides an easy way to use the upgraded tooling in master to build any version of the ECS schemas. The new build-version command line option accepts both tags, such as v1.5.0, and commit hashes, such as 1454f8b. This makes it easy to use new tooling features related to custom schemas with a stable released version of the official schema.

Copy link
Contributor

@webmat webmat left a comment

Choose a reason for hiding this comment

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

Thanks Marshall, this will be super helpful!

There's a few changes I'd like, to make sure the feature is easy to understand for users.

@@ -79,12 +87,12 @@ def argument_parser():
parser.add_argument('--subset', nargs='+',
help='render a subset of the schema')
parser.add_argument('--out', action='store', help='directory to store the generated files')
parser.add_argument('--build-version', action='store', help='version of official ECS schemas to use')
Copy link
Contributor

Choose a reason for hiding this comment

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

The wording here is confusing. I think we should simply use a Git centric --ref instead.

While the goal is indeed to be able to build on top of specific versions, the implementation is actually just loading git refs. Aligning the wording will make sure users understand when it doesn't work (e.g. "oh there's no git ref of that name") and will make it clear that it can be used in other awesome ways, like building on top of a feature branch.

Comment on lines 15 to 25
versions = ['master', 'v1.5.0']
self.ecs_nested_schemas = []
self.ecs_flat_schemas = []
for version in versions:
tree = ecs_helpers.get_git_tree(version)
schemas = schema_reader.load_schemas_from_git(tree)
intermediate_schemas = schema_reader.create_schema_dicts(schemas)
schema_reader.assemble_reusables(intermediate_schemas)
(nested, flat) = schema_reader.generate_nested_flat(intermediate_schemas)
self.ecs_nested_schemas.append(nested)
self.ecs_flat_schemas.append(flat)
Copy link
Contributor

Choose a reason for hiding this comment

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

The intent of the test_ecs_spec.py test file is to make high level sanity checks and assertions about the schema. As such, it's important that we're able to keep adding things in here about the current version we're building (e.g. ensuring that geo is correctly nested in a new place). As such, we can't have this test happen based on reading other git refs entirely. Once again, think about this in terms of running tests from within a feature branch.

Please move the unit tests about reading git refs to the test_ecs_helpers.py file instead.

The cleanup of moving the schema loading to setUp is a good one, though. We can keep that 😄

Makefile Outdated
@@ -61,7 +62,7 @@ generate: legacy_use_cases codegen generator
# Run the new generator
.PHONY: generator
generator:
$(PYTHON) scripts/generator.py --include "${INCLUDE}"
$(PYTHON) scripts/generator.py --include "${INCLUDE}" --build-version ${BUILD_VERSION}
Copy link
Contributor

Choose a reason for hiding this comment

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

make generator doesn't need to specify a git ref, it should by default run on the files that are already checked out.

Comment on lines 22 to 26
version = 'master'
if args.build_version:
version = args.build_version
tree = ecs_helpers.get_git_tree(version)
ecs_version = read_version(tree)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please align the wording to "git refs" here as well.

Copy link
Contributor

@webmat webmat left a comment

Choose a reason for hiding this comment

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

This is great, thanks Marshall!

I tried it and it works well for 1.4 too :-D

Doesn't work for 1.3 and before because the asciidoc expects attributes that didn't exist back then (categorization stuff), but that's out of scope for this PR. If it comes up we'll address in a follow-up.

@marshallmain marshallmain merged commit ef1cdac into elastic:master May 15, 2020
@marshallmain marshallmain deleted the add-build-version branch May 15, 2020 18:23
webmat pushed a commit to webmat/ecs that referenced this pull request Jun 4, 2020
Trivial conflict in changelog.

Interesting conflict with elastic#851. The new scripts/schema/loader.py file
has most of the new code around loading ECS files from git refs. In this
merge commit I'm also slightly adjusting comments and wording of output
messages around this.
@ebeahan ebeahan mentioned this pull request Jul 9, 2020
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.

Make the ECS tooling able to build the artifacts based on a git ref
2 participants