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
enhancement(cli): Show Git version and target triple in vector --version
output (#1044)
#1044
Conversation
Signed-off-by: Alexander Rodin <rodin.alexander@gmail.com>
Signed-off-by: Alexander Rodin <rodin.alexander@gmail.com>
} else { | ||
built_info::PKG_VERSION.into() | ||
}; | ||
let commit_hash = built_info::GIT_VERSION.and_then(|v| v.split('-').last()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
really I think this is the big thing holding us too built, it pulls down libgit2 and uses that. I wonder if we could just use Command
+ git
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using Command
+ git
would be less portable (for example, git
command is not available on most Windows machines). I agree that libgit2
increases the build time, but it doesn't increase the final executable size because it is used only during the build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can assume that all users compiling from source should have git and if it doesn't exist we can just skip this and place a place holder. I don't think we will ever have the case of someone building a release and not having git.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should separate the discussion about potentially moving away from built
. Personally, I'm in favor of sticking with it (at least for the time being), but I don't think that decision needs to be made as part of this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree. I do not want to assume anything, and it is possible git is not installed. Again, I prefer to optimize for the UX not Lucio's developer happiness. 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what UX we lose by not using built? It's completely a release thing? All we would be avoiding is having to compile libgit to fetch a commit sha. Happy to discuss this further in another issue.
src/main.rs
Outdated
fn get_version() -> String { | ||
let pkg_version = if built_info::CI_PLATFORM.is_some() && built_info::PKG_VERSION.contains('-') | ||
{ | ||
built_info::PKG_VERSION.replace("-dev", "-nightly") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This gets into versioning questions:
- Are we planning on representing the next version with the
-dev
suffix? If so, how do we know which version that is? For example, is the next version0.6.0
or1.0.0
? - Or, should we forgo guessing the next version and allow the package version to represent the last released version? We could also use the result of
git describe --tags
here. I believe that isbuilt_info::GIT_VERSION
.
We started with this discussion but punted on a conclusion since it involved figuring out how we'll release point releases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my ideal world, we use the version of the next release + -dev
. But since that requires knowing the future, I think my second choice would be most recent release + -dev
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that if we go with "the next version in Cargo.toml" approach, there might even be no need to use -dev
suffix, it could be just the next version.
- Rust sets version in
master
to the next released version, without any suffixes (link) - Clang does the same, as
clang --version
from master shows the next version to be released
Then the question is it an actual release or not could be decided in CI by looking at presence of the corresponding Git tag. For example, if the version in Cargo.toml
is 0.6.0 and there is no Git tag v0.6.0
, then the version output by vector --version
would be vector 0.6.0-dev (g816041c 2019-10-17)
and if there is tag v0.6.0
then vector --version
would return vector 0.6.0 (g816041c 2019-10-17)
.
The case when pre-release version is distributed as an archive is rare and I think that there is no need to officially distribute source archives of master at all, it should be enough to distribute only release archives.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The question about whether to bump the version before release or not is tougher, but I lean more to the "next version" approach. If we show the previous version with some suffix, then the users could expect it to be compatible with the previous release, for example if they see the version string starting from 0.5.0, they could assume that they need to look at the documentation for version 0.5.0, which might not be correct.
However, the guessing of the next version is not that hard problem because it could happen not immediately after the next release, but only after the first new change is merged to master.
Example 1
- we release 0.6.0
- then we improve docs (a PR merged to master)
- after the merge we increase the version in Cargo.toml to 0.6.1 and make a new release
- then we wait for the next PR ready to be merged
Example 2
- 0.6.1 is released
- new yet unstable sink is merged
- we are not ready to release, but increase the version in Cargo.toml to 0.7.0 because there are already enough changes for the next major 0.y.z release
- continue merging other PRs
- release 0.7.0
Also, I see no need to actually release all versions that appear in Cargo.toml. If in the previous example we did even more changes after merging the new sink and think that we are ready to release 1.0.0, there seems to be nothing bad with bumping the version in Cargo.toml again up to 1.0.0 and having 1.0.0 release after 0.6.1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well said, and I agree. There is nothing stopping us from bumping up to a major version when it warrants it. My vote is to adopt this strategy. Ref #1010.
Nice work! Once we figure out my above comment we can update this to reflect our future versioning strategy. |
src/main.rs
Outdated
fn get_version() -> String { | ||
let pkg_version = if built_info::CI_PLATFORM.is_some() && built_info::PKG_VERSION.contains('-') | ||
{ | ||
built_info::PKG_VERSION.replace("-dev", "-nightly") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my ideal world, we use the version of the next release + -dev
. But since that requires knowing the future, I think my second choice would be most recent release + -dev
?
} else { | ||
built_info::PKG_VERSION.into() | ||
}; | ||
let commit_hash = built_info::GIT_VERSION.and_then(|v| v.split('-').last()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should separate the discussion about potentially moving away from built
. Personally, I'm in favor of sticking with it (at least for the time being), but I don't think that decision needs to be made as part of this PR.
}; | ||
let commit_hash = built_info::GIT_VERSION.and_then(|v| v.split('-').last()); | ||
let built_date = chrono::DateTime::parse_from_rfc2822(built_info::BUILT_TIME_UTC) | ||
.unwrap() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't really matter, but built
does provide a helper to do this parsing: https://docs.rs/built/0.3.2/src/built/util.rs.html#68-72
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But using it would require adding built
as a runtime dependency, while now it is used only as a build-time dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a good point! Probably not worth it.
@a-rodin I'm happy to rollback fe26627. I'm a little concerned that we'll reliably bump the version as changes happen, but I'm happy to give it a shot and see how it goes. |
Could we solve this by adding an additional check to CI that would fail the build if there are additional changes since last tag, but version is not not updated? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to summarize, I think there are two things being discussed here:
- The code changes in this PR, which I think are good and generally non-controversial
- The question of when in our development/release process we should bump the version number in
Cargo.toml
The leading proposal for (2) seems to be that we bump to the next potential release version as we make the changes that justify that version bump. For example:
- Release
version = "0.1.0"
(git tagv0.1.0
) - Merge small change to docs
- Bump to
version = "0.1.1"
(no git tag) - Merge large breaking change
- Bump to
version = "0.2.0"
(no git tag) - Merge other small changes
- Release
version = "0.2.0"
(git tagv0.2.0
)
I think this generally seems good and would like to clarify a few things:
- Do we include a
-dev
/-nightly
suffix in theCargo.toml
version or is that something that's inferred by the lack of git tag? - Should the version bump happen as part of the normal changes, before them, or after them? I see some slight downsides to bundling them into the same change (e.g. reverts get funky, coordinating multiple open PRs, etc), but before and after both seem like they could be easy to forget and slightly awkward.
I prefer inferring the suffix from lack of Git tag. I think it makes history of
I think what we definitely need to do here is to add a CI test that would fail if there is no Git tag but the version is not updated yet. It would allow us to not forget to bump the version in any case. I don't have a strong opinion about whether bumping the versions is better to be done before merging/after merging/inside PRs, but I like "after merging" slightly more because it generates clean commit history like
or even
in case if PRs for A and B were merged at the same time. |
It'd be pretty easy to add a CI check on What do you think? |
I like the idea of using conventional commits for this. The CI check can infer minimal necessary version bump and fail if the current version bump is less than the minimal required. However, I think the maximal version bump don't have to be constrained by CI to allow doing larger version increments for external reasons. It can be useful when we decide to release 1.0 or if some of the commits end up not following conventional commits strictly enough. |
Agree 👍. I've opened #1083 to represent that. |
Signed-off-by: Alexander Rodin <rodin.alexander@gmail.com>
Signed-off-by: Alexander Rodin <rodin.alexander@gmail.com>
I've updated the version displaying to match the new strategy and show the target platform (#1110). Currently the displayed versions should looks like this:
Nightly versions suffixes are appended when Vector was compiled with special |
Looks great! |
Signed-off-by: Alexander Rodin <rodin.alexander@gmail.com>
Signed-off-by: Alexander Rodin <rodin.alexander@gmail.com>
Signed-off-by: Alexander Rodin <rodin.alexander@gmail.com>
Signed-off-by: Alexander Rodin <rodin.alexander@gmail.com>
Signed-off-by: Alexander Rodin <rodin.alexander@gmail.com>
vector --version
output (#1044)
Closes #951
This PR tries to implement the same logic for version info as
rustc
andcargo
use (see this comment).The table below summarizes output version for development and release versions (based on version in
Cargo.toml
), where builds either from the Git repository (locally / from CI) or from an archive (without.git
directory in the source tree).x.y.z-dev
)x.y.z
)0.6.0-dev (g816041c 2019-10-17)
0.6.0 (g816041c 2019-10-17)
0.6.0-nightly (g816041c 2019-10-17)
0.6.0 (g816041c 2019-10-17)
0.6.0-dev
0.6.0
Initially it is implemented using the information provided by the built crate, which provides the result of
git describe --tags
asbuilt_info::GIT_VERSION
, so that some unnecessary logic happens in runtime.Ideally, it would be better to create a custom
build.rs
file and put this logic there, that's why I marked the PR as draft for now.