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

Define build time dependencies #181

Merged
merged 10 commits into from
Jun 14, 2021
Merged

Conversation

mtojek
Copy link
Contributor

@mtojek mtojek commented Jun 2, 2021

What does this PR do?

This PR introduces support for build-time dependencies.

Why is it important?

We need to checkout field definitions from the ECS repository and use them to compile up-to-date and synced fields.

Checklist

Related issues

@mtojek mtojek self-assigned this Jun 2, 2021
@elasticmachine
Copy link

elasticmachine commented Jun 2, 2021

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: Pull request #181 updated

  • Start Time: 2021-06-10T13:04:40.957+0000

  • Duration: 2 min 20 sec

  • Commit: ec81ed5

Trends 🧪

Image of Build Times

@mtojek mtojek marked this pull request as draft June 2, 2021 14:54
@mtojek mtojek requested review from ruflin and jsoriano June 2, 2021 14:54
versions/1/manifest.spec.yml Outdated Show resolved Hide resolved
reference:
type: string
description: Source reference
pattern: 'git@[a-z0-9]{40}'
Copy link
Member

Choose a reason for hiding this comment

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

Allow the use of tags too? (Can be extended in the future in any case)

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 reason why I chose a commit hash is because it's always the same for all develops. If we put a tag here (e.g. [email protected]), the elastic-package will build a slightly different package based on the commit marked with the tag. I was thinking about a switch for elastic-package build, for example: --update, which can update references to latest dependency versions.

Actually I see a problem with this design: how can I pick the latest commit for ECS 1.9? Let me suggest something.

Copy link
Contributor Author

@mtojek mtojek Jun 7, 2021

Choose a reason for hiding this comment

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

Ok, I adjusted the manifest to include additional field "version". The update procedure would be as follows:

  1. Check ECS dependency considering version (e.g. 1.9).
  2. Fetch latest commit from the branch 1.9.
  3. Update reference with the commit hash.

Note:

I'm not fully satisfied with this approach (need to store version and source reference), but I don't see any other reasonable approach. We can always store an additional metafile somewhere around, but with this decision we could also introduce a special deps.yml instead of keeping everything in package manifest.

Copy link
Member

@jsoriano jsoriano Jun 7, 2021

Choose a reason for hiding this comment

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

@mtojek having a version and a reference can be confusing, even contradictory if someone sets a reference that doesn't correspond to a version. I think that we can go on by now with your original approach with the reference only, and we can improve it later to support other use cases.

how can I pick the latest commit for ECS 1.9?

Fetch latest commit from the branch 1.9.

I wouldn't try to support branches, at least by now, configured branches may lead to unreproducible builds, same code built at different moments can result in packages with different fields.

Copy link
Contributor

Choose a reason for hiding this comment

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

++

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

test/packages/good/manifest.yml Outdated Show resolved Hide resolved
@mtojek mtojek requested a review from jsoriano June 7, 2021 07:58
@@ -40,3 +40,8 @@ icons:
title: system
size: 1000x1000
type: image/svg+xml
build:
Copy link
Contributor

Choose a reason for hiding this comment

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

If we put this into the "main" manifest.yml, it will also stay in the package when downloaded by Kibana. Do we want that? Or should it be really a build time definition that is removed? Maybe a separate file? Or similar / part of the test definitions?

Copy link
Contributor Author

@mtojek mtojek Jun 7, 2021

Choose a reason for hiding this comment

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

There are pros and cons of both options.

it will also stay in the package when downloaded by Kibana. Do we want that?

Pros:

  • Kibana can link directly to ECS docs or repo to refer to the revisions
  • We don't need to reverse engineer the ECS version used by the built package

Cons:

  • Manifest contains new entries for dependencies

Or should it be really a build time definition that is removed?

I would be against modifying the manifest to get rid of dependencies. Maybe we can get rid of the build level and just leave dependencies.

Maybe a separate file?

Hm.. we can extract this logic to deps.yml. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

  • Agree on not modifying the manifest during build time
  • Interesting point that Kibana could also use this information in the future to build reference links

Maybe deps.yml gives us best of both worlds? But I'm torn if adding more files is a good idea. One advantage of depds.yml is that there could be a command elastic-package deps update (just made it up) that automatically updates references in the deps.yml file. I would not necessarily do the same with the manifest.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One advantage of depds.yml is that there could be a command elastic-package deps update (just made it up) that automatically updates references in the deps.yml file. I would not necessarily do the same with the manifest.

Yes, that's the plan. I was thinking about elastic-package build --update, which will try to pull latest commit references.

@mtojek
Copy link
Contributor Author

mtojek commented Jun 9, 2021

Ok, I extracted dependencies to an external file named "deps.yaml".

@mtojek mtojek marked this pull request as ready for review June 9, 2021 14:22
@mtojek mtojek requested a review from ruflin June 9, 2021 14:22
@@ -0,0 +1,4 @@
build:
Copy link
Member

Choose a reason for hiding this comment

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

Is build redundant now here? What other dependencies can be in this file? If at some moment there are runtime dependencies they will need to be in the manifest, or somewhere downloaded by Kibana.

Suggested change
build:

Or perhaps this file can be called build.yml in case we need more things in the future only in build time. And this key could be called dependencies.

Suggested change
build:
dependencies:

Copy link
Contributor Author

@mtojek mtojek Jun 9, 2021

Choose a reason for hiding this comment

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

I'm ok with build.yml too, although this may suggest to introduce more side features into it :)

We have also _dev directory, maybe this one is a better fit? For example: _dev/build/deps.yml. WDYT? Currently we're using the _dev/build/docs to render README files.

Copy link
Contributor Author

@mtojek mtojek Jun 10, 2021

Choose a reason for hiding this comment

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

I adjusted the PR to use build.yml in the package root directory.

@mtojek mtojek requested a review from jsoriano June 10, 2021 07:57
@@ -0,0 +1,3 @@
dependencies:
Copy link
Contributor

Choose a reason for hiding this comment

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

Just approved the other PR but we have one more name here: dependency.

I assume the ecs dependency can only be used once, should we add it by name instead of array?

dependencies:
  ecs:
    reference: foo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replaced array with objects. I assume it's just to prevent custom dependencies that users may try to introduce and we don't want them now.

Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

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

I like it with objects too 🙂

@mtojek mtojek merged commit 674263f into elastic:master Jun 14, 2021
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.

4 participants