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: simplify for modern Go #13870

Merged
merged 10 commits into from
May 19, 2022

Conversation

kolyshkin
Copy link
Contributor

This removes about 100 lines from the top-level Makefile.

Please review commit by commit, and see commit messages for details.

Note some of these changes are standing on the assumption that Go >= 1.16 is used (which is true since we use things like filepath.WalkDir which require go 1.16).

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 14, 2022
@lsm5
Copy link
Member

lsm5 commented Apr 14, 2022

/approve

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 14, 2022
@mheon
Copy link
Member

mheon commented Apr 18, 2022

Test failures seem related

@lsm5
Copy link
Member

lsm5 commented Apr 19, 2022

@kolyshkin RE: podman.spec.rpkg we'll need to ensure that rpkg local or make package works. Your current PR gives me this:

$ rpkg local
ERROR: git_dir_version: Could not get remote URL.
git_dir_version failed with value 1.

@lsm5
Copy link
Member

lsm5 commented Apr 19, 2022

@kolyshkin RE: podman.spec.rpkg we'll need to ensure that rpkg local or make package works. Your current PR gives me this:

$ rpkg local
ERROR: git_dir_version: Could not get remote URL.
git_dir_version failed with value 1.

I wonder if it's related to your fork being called libpod.

@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 22, 2022
@kolyshkin kolyshkin force-pushed the makefile-cleanups branch from 9d7da20 to 073166b Compare May 17, 2022 01:29
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 17, 2022
@kolyshkin
Copy link
Contributor Author

OK, this should work now. The problem with rpm building was caused by the fact that gobuild macro is setting GO111MODULE=off which makes it unable to build using relative vendor subdirectory. Fixed by having

%global gomodulesmode GO111MODULE=on

@edsantiago
Copy link
Member

LGTM in principle, but I don't know enough Go to approve. It's not passing CI, though.

@kolyshkin
Copy link
Contributor Author

The error from "Test Code Consistency" job

go: downloading github.com/uber/jaeger-client-go v2.30.0+incompatible
go: github.com/containers/[email protected] requires
	github.com/containerd/[email protected] requires
	github.com/containerd/[email protected] requires
	github.com/containerd/[email protected] requires
	github.com/Microsoft/[email protected] requires
	github.com/containerd/[email protected] requires
	github.com/Microsoft/hcsshim/[email protected] requires
	github.com/docker/[email protected] requires
	google.golang.org/[email protected]: invalid version: git fetch --unshallow -f origin in /var/tmp/go/pkg/mod/cache/vcs/14bb952cc8902e20fb82cb08a9d29b90b010f5d6d0d3737e9cb402b3b57a25b5: exit status 128:
	fatal: fetch-pack: invalid index-pack output
make: *** [Makefile:257: vendor] Error 1

seems like a network glitch. Perhaps we should remove "make vendor" from most of the jobs, since it is error prone and doing it once is enough.

@kolyshkin kolyshkin force-pushed the makefile-cleanups branch from c213b13 to f250fb7 Compare May 17, 2022 18:18
@kolyshkin
Copy link
Contributor Author

kolyshkin commented May 17, 2022

OK, for some reason Cirrus-CI has GOPROXY=direct set (and also GOSUMDB=off). I was not able to find out where this is being set, perhaps @saschagrunert knows something? This is definitely not the default setting so it must be set somewhere.

So I had to add the following to .cirrus.yml to combat that:

    # Sane (default) value for GOPROXY and GOSUMDB.
    GOPROXY: "https://proxy.golang.org,direct"
    GOSUMDB: "sum.golang.org"

@kolyshkin
Copy link
Contributor Author

It's not passing CI, though.

I am still working on it, thus it's a draft.

kolyshkin added 10 commits May 17, 2022 13:40
This was originally added in commit a824186 to be used from
Travis CI. Travis was removed in commit 8771a03 and there is
no need to have this target ever since (October 2018).

Also, remove the comment about BUILD_TAGS, which originally belonged to
varlink target (removed by commit f62a356) but got misplaced
later.

Signed-off-by: Kir Kolyshkin <[email protected]>
Since about Go 1.10 (or whereabouts) the specific package structure
is no longer required.

This also removes GOPKGDIR and GOPKGBASEDIR as they were only used by
gopathok.

Signed-off-by: Kir Kolyshkin <[email protected]>
Recent commit 3b91779 removes
this target, but some artifacts remain. Remove those.

Fixes: 3b91779
Signed-off-by: Kir Kolyshkin <[email protected]>
Remove GOPATH setting as since Go 1.9 it defaults to $HOME/go (for
earlier versions it had to be specified explicitly).

Remove GOPATH-related code from the spec, using relative paths when
compiling packages, and enable Go modules, simplifying the spec.

Remove support for multiple paths in GOPATH (which is rarely used and
doesn't really work with modules).

Remove setting GOBIN, rely on $GOPATH/bin instead. In case GOBIN is
explicitly set (which is highly unlikely), forcefully ignore by
unsetting it.

Remove GOBIN from tools invocation since we added GOPATH/bin to PATH.

Signed-off-by: Kir Kolyshkin <[email protected]>
GOPROXY's default value is "https://proxy.golang.org,direct"
since go 1.13, so it is redundant to set it explicitly.

For some reason though, GOPROXY in Cirrus CI is set to direct,
which makes things such as go mod tidy very slow. So, set the
proper (default) value for in in .cirrus.yml. Do the same for GOSUMDB.

Signed-off-by: Kir Kolyshkin <[email protected]>
"go build" no longer requires explicit "-mod=vendor", as this is the
default since go 1.14.

Signed-off-by: Kir Kolyshkin <[email protected]>
Those are not used since commit 0d1ba0a.

Fixes: 0d1ba0a
Signed-off-by: Kir Kolyshkin <[email protected]>
It is superceded by golangci-lint, which has gofmt as one of the
linters.

Signed-off-by: Kir Kolyshkin <[email protected]>
Using it is no longer needed.

Signed-off-by: Kir Kolyshkin <[email protected]>
Add .golangci.yml, podman.spec.rpkg, and non top-level Makefiles.

Signed-off-by: Kir Kolyshkin <[email protected]>
@kolyshkin kolyshkin force-pushed the makefile-cleanups branch from f250fb7 to 6531170 Compare May 17, 2022 21:06
@kolyshkin kolyshkin marked this pull request as ready for review May 18, 2022 20:41
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 18, 2022
@kolyshkin
Copy link
Contributor Author

OK, this one is ready, PTAL @edsantiago @lsm5 @Luap99 @vrothberg

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

Thanks, @kolyshkin! Much appreciated.

LGTM

@openshift-ci
Copy link
Contributor

openshift-ci bot commented May 19, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kolyshkin, lsm5, vrothberg

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

@rhatdan
Copy link
Member

rhatdan commented May 19, 2022

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label May 19, 2022
@openshift-merge-robot openshift-merge-robot merged commit 948c5e9 into containers:main May 19, 2022
@edsantiago
Copy link
Member

@lsm5 can you, if it's not too hard, trigger a manual koji build? This is a big scary PR with lots of potential to break builds, and it would be nice to catch breakage early. (Clarification: good stuff, but still big and scary)

@lsm5
Copy link
Member

lsm5 commented May 26, 2022

@edsantiago sorry about the late response, the rhcontainerbot/podman-next copr has had successful builds recently, so all's well. https://copr.fedorainfracloud.org/coprs/rhcontainerbot/podman-next/package/podman/ . I'll need to check if the fedora sources need further changes to make use of the changes in this PR.

Thanks @kolyshkin !!

@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 21, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants