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

makefile: check cargo version #1503

Merged
merged 1 commit into from
Apr 21, 2021
Merged

makefile: check cargo version #1503

merged 1 commit into from
Apr 21, 2021

Conversation

webern
Copy link
Contributor

@webern webern commented Apr 19, 2021

Issue number:

Follow up to #1408
Follow up to #1361

Description of changes:

makefile: check cargo version

For the build-package target (used by cargo make repo), we need Cargo
version 1.51 or higher to build a dependency of the variants workspace.
To make this clear, we check the Cargo version before build-package and
provide a clear error message.

Testing done:

rustup default 1.50.0
cargo make repo
# Error: Cargo 1.51.0 or greater is required, your version is 1.50.0
# [cargo-make] ERROR - Error while executing command, exit code: 1
# [cargo-make] WARN - Build Failed.
# FAIL: 1
rustup default 1.51.0
cargo make repo
# Works!

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

Makefile.toml Outdated Show resolved Hide resolved
Makefile.toml Outdated Show resolved Hide resolved
For the build-package target (used by cargo make repo), we need Cargo
version 1.51 or higher to build a dependency of the variants workspace.
To make this clear, we check the Cargo version before build-package and
provide a clear error message.
@webern webern requested review from etungsten and jpculp April 20, 2021 20:45
Copy link
Member

@jpculp jpculp left a comment

Choose a reason for hiding this comment

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

Approved if the checks come back green.

strarr=(${cargo_version//./ })
cargo_major="${strarr[0]}"
cargo_minor="${strarr[1]}"
if [ "${cargo_major}" -gt "1" ] ; then
Copy link
Member

Choose a reason for hiding this comment

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

nit. It would be nice if we could standardize on [[...]].
nit. I don't think you need quotes for things without spaces (ie. numbers)

Copy link
Contributor

Choose a reason for hiding this comment

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

This is typically done to maintain some level of compatibility with other shells, and then only use [[ ]] where you know you need bash specifics.

Copy link
Member

Choose a reason for hiding this comment

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

If we are worried about compatibility with other shells, then shouldn't we avoid all instances of bash-isms?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, we do need some of them. It's a balance - sometimes bash-isms are the best way to do something, but otherwise staying compatible with POSIX sh and BSD userland is a good habit. We've seen both of those things bite us in Makefile.toml, for example. Even if your shebang is bash, it's nice to use sh basics when they're essentially identical, like in this case, in case you need the script to run elsewhere someday. (I'm old, and so have run into this many times.)

@webern
Copy link
Contributor Author

webern commented Apr 20, 2021

webern force-pushed the webern:check-cargo branch from a8a10b1 to afd9c4c

I pushed @jpculp's suggestion, but I based on the discussion I think I'm going to undo it and merge.

@webern
Copy link
Contributor Author

webern commented Apr 20, 2021

webern force-pushed the webern:check-cargo branch from afd9c4c to a8a10b1

Revert back to where we were when we had a bunch of green check marks :)

@webern webern merged commit 926b214 into bottlerocket-os:develop Apr 21, 2021
@webern webern deleted the check-cargo branch April 21, 2021 03:34
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.

5 participants