[go: up one dir, main page]

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

src: improved version output #1817

Merged
merged 1 commit into from
Jun 20, 2023

Conversation

lkingland
Copy link
Member
  • 🎁 Knative version now included in func verbose output
  • 🐛 fixes bug where builds without an associated version number showed v0.0.0
  • 🧹 validates version passed by build is a valid semver

Ensures that func version remains consistent; always returning an ascending semver of the version, with the associated knative tag being part of the verbose version information.

Replaces the default v0.0.0 version tag when building from a non-tagged commit to the "human readable" form provided by "git describe". This consists of the most recently tagged version along with a suffix which consists of the number of commits which have been added since the tagged version, and the hash.

The reasoning behind this change is that we must retain the ability to release versions independently of the knative releases, while at the same time communicating which knative release to for which this version is associated. The primary version number is the version of this library, and of the binary itself. At time of this writing, that is v0.37.0, and is the most contectually relevant. The knative version to which this library and cli tool relates most closely is v1.10, and is included as metadata, and printed in verbose mode.

Here's how this will look in practice:

The most recent Knative version is v1.10, which was released with Functions v0.37.0. Checking out v0.37.0 correctly displays the versions:

❯ git checkout v0.37.0 && make
❯ ./func version -v
Version: v0.37.0
Knative: v1.10.0
Commit: 61179d88
SocatImage: quay.io/boson/alpine-socat:1.7.4.3-r1-non-root
TarImage: quay.io/boson/alpine-socat:1.7.4.3-r1-non-root

When building from an unreleased commit, such as the current Function main branch (which is 37 commits ahead of what was released as v0.37.0 in Knative 1.10:

❯ git checkout main && make
❯ ./func version -v
Version: v0.37.0-77-gcabba3f9
Knative: v1.10.0
Commit: cabba3f9
SocatImage: quay.io/boson/alpine-socat:1.7.4.3-r1-non-root
TarImage: quay.io/boson/alpine-socat:1.7.4.3-r1-non-root

Please note that this only applies to builds triggered with make build. Direct builds of the source code do not populate these values:

❯ go build ./cmd/func
❯ ./func version -v
Version:
Knative:
Commit:
SocatImage: quay.io/boson/alpine-socat:1.7.4.3-r1-non-root
TarImage: quay.io/boson/alpine-socat:1.7.4.3-r1-non-root

@knative-prow knative-prow bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 19, 2023
@knative-prow
Copy link
knative-prow bot commented Jun 19, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lkingland

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 19, 2023
@knative-prow knative-prow bot requested review from rhuss and vyasgun June 19, 2023 06:01
@codecov
Copy link
codecov bot commented Jun 19, 2023

Codecov Report

Patch coverage: 86.66% and project coverage change: +1.14 🎉

Comparison is base (cabba3f) 62.52% compared to head (e797c94) 63.66%.

❗ Current head e797c94 differs from pull request most recent head 3ff676d. Consider uploading reports for the commit 3ff676d to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1817      +/-   ##
==========================================
+ Coverage   62.52%   63.66%   +1.14%     
==========================================
  Files         106      106              
  Lines       13553    13640      +87     
==========================================
+ Hits         8474     8684     +210     
+ Misses       4281     4134     -147     
- Partials      798      822      +24     
Flag Coverage Δ
e2e-test 37.27% <6.66%> (-0.34%) ⬇️
e2e-test-oncluster 32.99% <6.66%> (-0.19%) ⬇️
e2e-test-oncluster-runtime 28.21% <6.66%> (?)
integration-tests 52.13% <85.71%> (+3.87%) ⬆️
unit-tests-macos-latest 49.74% <85.71%> (-0.24%) ⬇️
unit-tests-ubuntu-latest 50.45% <85.71%> (-0.35%) ⬇️
unit-tests-windows-latest 49.69% <85.71%> (-0.30%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
cmd/root.go 82.22% <85.71%> (+1.69%) ⬆️
cmd/func/main.go 43.47% <100.00%> (+1.25%) ⬆️

... and 8 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

The Knative version is now included in version command verbose output

Building an unreleased version no longer returns v0.0.0, but instead the
value provided by `git describe --tags` which is the most recent tagged
release with a suffix consisting of the number of commits since that
release and the short hash.

Verbose output now always includes the current commit on a dedicated
line.
@lkingland lkingland marked this pull request as ready for review June 19, 2023 14:14
@knative-prow knative-prow bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 19, 2023
@knative-prow knative-prow bot requested a review from dsimansk June 19, 2023 14:14
@lkingland lkingland requested review from lance, zroubalik, aslom and matejvasek and removed request for rhuss, dsimansk and vyasgun June 19, 2023 14:14
@aslom
Copy link
Member
aslom commented Jun 19, 2023

Great idea!

@aslom
Copy link
Member
aslom commented Jun 19, 2023

I love that now it is semver and commit id in the output for func verison -v

 ./func version -v
Version: v0.37.0-78-g3ff676d7
Knative: v1.10.0
Commit: 3ff676d7
SocatImage: quay.io/boson/alpine-socat:1.7.4.3-r1-non-root
TarImage: quay.io/boson/alpine-socat:1.7.4.3-r1-non-root

However, it seems make test-integration fails? I tried it locally and it also fails for me:

=== RUN   TestSignatures/static-invalid
--- PASS: TestSignatures (0.00s)
    --- PASS: TestSignatures/instanced-default (0.00s)
    --- PASS: TestSignatures/instanced-http (0.00s)
    --- PASS: TestSignatures/instanced-cloudevent (0.00s)
    --- PASS: TestSignatures/static-default (0.00s)
    --- PASS: TestSignatures/static-http (0.00s)
    --- PASS: TestSignatures/static-cloudevent (0.00s)
    --- PASS: TestSignatures/instanced-invalid (0.00s)
    --- PASS: TestSignatures/static-invalid (0.00s)
PASS
	knative.dev/func/pkg/scaffolding	coverage: 51.4% of statements
ok  	knative.dev/func/pkg/scaffolding	0.737s	coverage: 51.4% of statements
FAIL
make: *** [test-integration] Error 1
make test-integration  51.11s user 15.49s system 23% cpu 4:40.91 total

How do yo debug it? Optiont o get more output from test and/or log?

@lkingland
Copy link
Member Author
lkingland commented Jun 20, 2023

However, it seems make test-integration fails? I tried it locally and it also fails for me:

=== RUN   TestSignatures/static-invalid
...
FAIL
make: *** [test-integration] Error 1
make test-integration  51.11s user 15.49s system 23% cpu 4:40.91 total

How do yo debug it? Option to get more output from test and/or log?

Thanks for checking @aslom. Yes the failure message at the very end only states that the overall test suite failed, and it is a fairly long set of test cases; some of which spew quite a bit of logs. You can search for --- FAIL to find the exact test that caused the overall system to fail. Here's what I see:

=== RUN   TestGitlab
    gitlab_test.go:202: setting up gitlab env
    gitlab_test.go:212: cannot get sign in page, unexpected status: 504
--- FAIL: TestGitlab (15.06s)
...
(lots more test logs)
...
> 	knative.dev/func/pkg/scaffolding	coverage: 51.4% of statements
> ok  	knative.dev/func/pkg/scaffolding	0.737s	coverage: 51.4% of statements
> FAIL

Is that the same error you see locally? Because I am also seeing it on this PR in the GitHub Acation and that of another PR, so there may be a shared (hopefully transient) issue with the Gitlab installation step.

@aslom
Copy link
Member
aslom commented Jun 20, 2023

Now that all tests passed OK

/lgtm

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Jun 20, 2023
@knative-prow knative-prow bot merged commit 94582ef into knative:main Jun 20, 2023
@lance
Copy link
Member
lance commented Jul 5, 2023

/cherry-pick release-1.10

@knative-prow-robot
Copy link

@lance: #1817 failed to apply on top of branch "release-1.10":

Applying: src: interstitial commit version
Using index info to reconstruct a base tree...
M	Makefile
M	cmd/func/main.go
M	cmd/root.go
M	cmd/root_test.go
Falling back to patching base and 3-way merge...
Auto-merging cmd/root_test.go
CONFLICT (content): Merge conflict in cmd/root_test.go
Auto-merging cmd/root.go
CONFLICT (content): Merge conflict in cmd/root.go
Auto-merging cmd/func/main.go
CONFLICT (content): Merge conflict in cmd/func/main.go
Auto-merging Makefile
CONFLICT (content): Merge conflict in Makefile
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 src: interstitial commit version
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherry-pick release-1.10

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

lance pushed a commit to lance/func that referenced this pull request Jul 5, 2023
The Knative version is now included in version command verbose output

Building an unreleased version no longer returns v0.0.0, but instead the
value provided by `git describe --tags` which is the most recent tagged
release with a suffix consisting of the number of commits since that
release and the short hash.

Verbose output now always includes the current commit on a dedicated
line.
lance pushed a commit to lance/func that referenced this pull request Jul 5, 2023
The Knative version is now included in version command verbose output

Building an unreleased version no longer returns v0.0.0, but instead the
value provided by `git describe --tags` which is the most recent tagged
release with a suffix consisting of the number of commits since that
release and the short hash.

Verbose output now always includes the current commit on a dedicated
line.
knative-prow bot pushed a commit that referenced this pull request Jul 7, 2023
The Knative version is now included in version command verbose output

Building an unreleased version no longer returns v0.0.0, but instead the
value provided by `git describe --tags` which is the most recent tagged
release with a suffix consisting of the number of commits since that
release and the short hash.

Verbose output now always includes the current commit on a dedicated
line.

Co-authored-by: Luke Kingland <luke@lukekingland.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants