thoth-station / thoth-ops-infra

Infrastructure project to have collections of container images.
GNU General Public License v3.0
0 stars 9 forks source link

provide golang infrastructure for pre-commit #38

Closed goern closed 3 years ago

goern commented 3 years ago

Let's merge https://github.com/larsks/opf-go-precommit and thoth-precommit from https://github.com/thoth-station/thoth-ops-infra in one container image, so that we can have a unified pre-commit job (for example https://github.com/thoth-station/slo-reporter/blob/master/.prow.yaml#L2-L13) for python or golang source

seeAlso https://operatefirst.slack.com/archives/C01RF4SPNDD/p1622570329014400

/assign @harshad16 /assign @larsks /priority important-soon /sig pipelines /area documentation

sesheta commented 3 years ago

@goern: GitHub didn't allow me to assign the following users: larsks.

Note that only thoth-station members, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time. For more information please see the contributor guide

In response to [this](https://github.com/thoth-station/thoth-ops-infra/issues/38): >Let's merge https://github.com/larsks/opf-go-precommit and thoth-precommit from https://github.com/thoth-station/thoth-ops-infra in one container image, so that we can have a unified pre-commit job (for example https://github.com/thoth-station/slo-reporter/blob/master/.prow.yaml#L2-L13) for python or golang source > >seeAlso https://operatefirst.slack.com/archives/C01RF4SPNDD/p1622570329014400 > >/assign @harshad16 >/assign @larsks >/priority important-soon >/sig pipelines >/area documentation Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
larsks commented 3 years ago

The existing pre-commit images are based on images from the s2i-thoth repository. If we want a f34/py39 based pre-commit image, do we need to start with f34-py39 image in s2i-thoth?

harshad16 commented 3 years ago

it will be there in few mins , we are releasing it

larsks commented 3 years ago

The existing pre-commit images set $HOME to /opt/app-root/src, which is presumably where one is expected to mount the source tree to be checked. This is a bad default, since it means anything that normally gets installed in $HOME gets installed into the source tree, which can have unintended side effects (this is a particularly problem with Go, because it will by default install dependencies into ~/go, so running go test ./... in the source tree will pick up unit tests for all the dependencies).

When running on a local system, changes in /opt/app-root/src impact the local build environment, since the source tree is bind-mounted into the image.

We need make $HOME different from the source tree.

I guess the easiest option is just to mount the sources somewhere else at runtime, e.g.:

docker run -v $PWD:/src -w /src ...
goern commented 3 years ago

What is the behaviour implemented by s2i-go ?

larsks commented 3 years ago

I haven't the foggiest idea. Taking a look at https://github.com/sclorg/golang-container now...

larsks commented 3 years ago

The go s2i image sets HOME to /opt/app-root/src, but the Dockerfile generated by s2i build --as-dockerfile ... copies sources into /tmp/src and runs the build from there:

pushd /tmp/src
[...]
go build -o /opt/app-root/gobinary
sesheta commented 3 years ago

Stale issues rot after 30d of inactivity. Mark the issue as fresh with /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

/lifecycle rotten

sesheta commented 3 years ago

Rotten issues close after 30d of inactivity. Reopen the issue with /reopen. Mark the issue as fresh with /remove-lifecycle rotten.

/close

sesheta commented 3 years ago

Stale issues rot after 30d of inactivity. Mark the issue as fresh with /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

/lifecycle rotten

sesheta commented 3 years ago

@sesheta: Closing this issue.

In response to [this](https://github.com/thoth-station/thoth-ops-infra/issues/38#issuecomment-904209124): >Rotten issues close after 30d of inactivity. >Reopen the issue with `/reopen`. >Mark the issue as fresh with `/remove-lifecycle rotten`. > >/close Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.