-
Notifications
You must be signed in to change notification settings - Fork 169
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
fix(cmake): fixed git dev versioning. #946
Conversation
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
cmake/modules/versions.cmake
Outdated
endif() | ||
string(REGEX MATCH "^[0-9]+.[0-9]+.[0-9]+$" libs_tag ${dev_version}) | ||
string(REGEX MATCH "^[0-9]+.[0-9]+.[0-9]+\\+driver$" driver_tag ${dev_version}) | ||
message("Tags: ${libs_tag} ${driver_tag}") |
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.
Example output, tested with any combination of tags:
NO TAG:
Tags:
-- Libs version: 0.10.0-rc1-475+3f5ccfe
Tags:
-- Driver version: 4.0.1+driver-419+3f5ccfe
TAG LIBS:
Tags: 0.10.5
-- Libs version: 0.10.5
Tags:
-- Driver version: 4.0.1+driver-419+3f5ccfe
TAG DRV:
Tags:
-- Libs version: 0.10.0-rc1-475+3f5ccfe
Tags: 4.0.2+driver
-- Driver version: 4.0.2+driver
BOTH:
Tags: 0.10.5
-- Libs version: 0.10.5
Tags: 4.0.2+driver
-- Driver version: 4.0.2+driver
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 will remove this line that was just needed for testing ;)
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.
Cleaned up!
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
Wip because i spotted a bug :/ |
Fixed; output is now correct in any case. |
/milestone 0.11.0 |
To quickly test, fetch this branch and from the HEAD of this branch, try a cmake. |
Ci is not picking up anything though :/ Perhaps we need to port also https://github.com/falcosecurity/falco/pull/2292/files#diff-b803fcb7f17ed9235f1e5cb1fcd2f5d3b2838429d4368ae4c57ce4436577f03f changes? |
Nope it was already broken (see others opened PRs). I think we just miss git client in the ci. |
0fa6171
to
8ef41b8
Compare
Ok we needed to add the git safe directory since we are using a |
f88f214
to
bdb132f
Compare
Fixed! |
bdb132f
to
7319bf1
Compare
@@ -128,7 +136,7 @@ jobs: | |||
apt update && apt install -y --no-install-recommends ca-certificates cmake build-essential clang llvm git pkg-config autoconf automake libtool libelf-dev wget libb64-dev libc-ares-dev libcurl4-openssl-dev libssl-dev libtbb-dev libjq-dev libjsoncpp-dev libgrpc++-dev protobuf-compiler-grpc libgtest-dev libprotobuf-dev linux-headers-generic | |||
|
|||
run: | | |||
git config --global --add safe.directory ${{ github.workspace }} | |||
git config --global --add safe.directory $GITHUB_WORKSPACE |
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.
Switched to use $GITHUB_WORKSPACE
per this bug: actions/checkout#785
In this case we weren't affected, but since i used $GITHUB_WORKSPACE
in other jobs, i decided to be consistent and use it everywhere.
@@ -87,6 +87,111 @@ function(get_git_head_revision _refspecvar _hashvar) | |||
PARENT_SCOPE) | |||
endfunction() | |||
|
|||
function(git_get_latest_tag _var) |
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 is basically copy-pasted from the Falco one.
execute_process(COMMAND | ||
"${GIT_EXECUTABLE}" | ||
rev-list | ||
${ARGN} |
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.
Only difference from Falco one: we pass --tags
too from external, because in git rev-list
, --tags
option takes an optional filtering argument, and we need to filter for +driver
.
See https://git-scm.com/docs/git-rev-list.
function(_get_git_version _var is_driver) | ||
# Try to obtain the exact git tag | ||
if (is_driver) | ||
git_get_exact_tag(tag --match=*+driver) |
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 is exactly like before, but we are forcing the ARGN
manually now.
endif() | ||
string(REGEX MATCH "^[0-9]+.[0-9]+.[0-9]+$" libs_tag ${dev_version}) | ||
string(REGEX MATCH "^[0-9]+.[0-9]+.[0-9]+\\+driver$" driver_tag ${dev_version}) | ||
if(dev_version MATCHES "NOTFOUND$" OR (libs_tag STREQUAL "" AND driver_tag STREQUAL "")) |
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.
Algorithm is the same as on Falco: if we are not on a tag (ie: on a x.y.z or x.y.z+driver), we fetch HEAD, then latest tag (for driver or userspace), and then we mix them together to output a diff-from-latest_tag version.
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
7319bf1
to
e4db728
Compare
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.
/approve
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.
LGTM
I remember the bug in Falco that we fixed in the latest release
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Andreagit97, FedeDP, LucaGuerra The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind bug
Any specific area of the project related to this PR?
/area build
Does this PR require a change in the driver versions?
What this PR does / why we need it:
Fixes libs dev versioning by applying similar fixes as falcosecurity/falco#2292.
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?: