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

[common/building] fix: fuse version should be built outside build.rs #791

Merged
merged 1 commit into from
Jun 9, 2021

Conversation

drmingdrmer
Copy link
Member

@drmingdrmer drmingdrmer commented Jun 9, 2021

I hereby agree to the terms of the CLA available at: https://datafuse.rs/policies/cla/

Summary

[common/building] fix: fuse version should be built outside build.rs

Inside build.rs, the env vars such as VERGEN_BUILD_SEMVER is written
only to stdout thus it is impossible to reuse these vars to compose
FUSE_COMMIT_VERSION.

This patch fixes the issue by building FUSE_COMMIT_VERSION with a
lazy_static block from env vars in runtime.

Changelog

  • Bug Fix

Related Issues

#782 (comment)

Inside `build.rs`, the env vars such as `VERGEN_BUILD_SEMVER` is written
only to stdout thus it is impossible to reuse these vars to compose
`FUSE_COMMIT_VERSION`.

This patch fixes the issue by building `FUSE_COMMIT_VERSION` with a
`lazy_static` block from env vars in runtime.
@databend-bot databend-bot added the pr-bugfix this PR patches a bug in codebase label Jun 9, 2021
@databend-bot
Copy link
Member

Thanks for the contribution!
I have applied any labels matching special text in your PR Changelog.

Please review the labels and make any necessary changes.

@drmingdrmer drmingdrmer requested a review from BohuTANG June 9, 2021 06:40
@drmingdrmer drmingdrmer marked this pull request as ready for review June 9, 2021 06:40
@drmingdrmer
Copy link
Member Author

@PsiACE This patch should fix your issue?
Sorry for the inconvenience. 😭

use structopt::StructOpt;
use structopt_toml::StructOptToml;

pub const FUSE_COMMIT_VERSION: &str = env!("FUSE_COMMIT_VERSION");
lazy_static! {
Copy link
Member

Choose a reason for hiding this comment

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

Cool.
The lazy looks duplicated with fusequery/query/src/configs/config.rs

Copy link
Member Author

Choose a reason for hiding this comment

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

Aye sir.
I left these boilerplate there because I'm not very sure about if it is all right for two binaries sharing a common version.
Moving these to a common lib would be better?

Copy link
Member

Choose a reason for hiding this comment

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

+1

Copy link
Member Author

@drmingdrmer drmingdrmer Jun 9, 2021

Choose a reason for hiding this comment

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

@BohuTANG
There is an issue with sharing these common codes:
The option_env must be evaluated after build.rs finished.
build.rs depends on common/building. Thus common/building will be compiled without knowing of these env vars.
Then to share the common codes, they must be moved to another crate that is not common/building.

For now, no other common crate is suitable for this task.
Thus we have to:

  • Let fusestore reference fusequery::*::FUSE_COMMIT_VERSION or reverse.
  • or create another crate to keep the common codes.

Copy link
Member

Choose a reason for hiding this comment

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

Got

@codecov-commenter
Copy link

Codecov Report

Merging #791 (25500e3) into master (de13818) will increase coverage by 0%.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master    #791   +/-   ##
======================================
  Coverage      77%     78%           
======================================
  Files         317     318    +1     
  Lines       17416   17426   +10     
======================================
+ Hits        13579   13593   +14     
+ Misses       3837    3833    -4     
Impacted Files Coverage Δ
fusequery/query/src/configs/config.rs 98% <ø> (ø)
fusestore/store/src/configs/config.rs 92% <ø> (ø)
fusequery/query/src/configs/config_test.rs 97% <100%> (+<1%) ⬆️
fusestore/store/src/configs/config_test.rs 100% <100%> (ø)
common/runtime/src/runtime_test.rs 100% <0%> (+26%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update de13818...25500e3. Read the comment docs.

Copy link
Member

@BohuTANG BohuTANG left a comment

Choose a reason for hiding this comment

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

LGTM

@databend-bot
Copy link
Member

CI Passed
Reviewer Approved
Let's Merge

@databend-bot databend-bot merged commit 1c7a97f into databendlabs:master Jun 9, 2021
Copy link
Member

@PsiACE PsiACE left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @drmingdrmer

@drmingdrmer drmingdrmer deleted the fix-fuse-ver branch June 9, 2021 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-bugfix this PR patches a bug in codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants