Skip to content

Commit

Permalink
Remove vendor dir in /test (microsoft#1417)
Browse files Browse the repository at this point in the history
Given this slows down development both for us and external contributors
as for most changes one would need to run `go mod vendor` in /test to
bring in the latest local hcsshim changes, I think it's time we removed
this.

Pros:
1. Easier for automated tooling like dependabot, and more recently a
Microsoft security bot, to make PRs that can just be checked in.
All of these automated PRs tend to fail as the bot doesn't know it would
need to run go mod vendor in /test as well for our repo. The approach today
to check these in is typically someone manually checks out the branch
dependabot (or whatever other bot) made, vendor to test, and then push a
new commit to those automated PRs and then we can check them in.

2. Speeds up development flow as we don't need to go mod vendor in test
before pushing almost every change.

3. Speeds up external contributions as well as there's no extra step to
follow to make a change to most things in /internal anymore. We state that
this needs to be done in our README, but it's probably a testament to how
odd our setup is that it's missed here and there.

Cons:
1. We lose the main selling point of vendoring for our test dependencies
which is that if one of our dependencies is no longer accessible
(deleted, renamed, whatever else) we don't have a local copy included
in our repo. This will increase our dependence on the Go modules proxy
server which seems like a fair tradeoff, and I think we're fine with this for
test dependencies at least.

I've removed the references to this extra step in the README as well as
got rid of the CI step verifying that the vendor dir was up to date. I
don't think we needed the mod=vendor env var either, as since go 1.14 if
there's a top level vendor folder I believe the flag is transparently set
for commands that accept it.

Signed-off-by: Daniel Canter <dcanter@microsoft.com>
  • Loading branch information
dcantah authored and Kirtana Ashok committed Jul 11, 2022
1 parent 8a301f2 commit 3c37022
Show file tree
Hide file tree
Showing 374 changed files with 7 additions and 60,065 deletions.
37 changes: 7 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ on:
- push
- pull_request

env:
GOFLAGS: -mod=vendor
GOPROXY: off

jobs:
protos:
runs-on: 'windows-2019'
Expand Down Expand Up @@ -88,25 +84,6 @@ jobs:
}
exit $process.ExitCode
verify-test-vendor:
runs-on: 'windows-2019'
env:
GOPROXY: "https://proxy.golang.org,direct"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '^1.17.0'
- name: Validate test modules
shell: powershell
run: |
$currentPath = (Get-Location).Path
$process = Start-Process powershell.exe -PassThru -Verb runAs -Wait -ArgumentList $currentPath/scripts/Verify-GoModules.ps1, $currentPath, "test"
if ($process.ExitCode -ne 0) {
Write-Error "Test package modules are not up to date. Please validate your go version >= this job's and run `go mod vendor` followed by `go mod tidy` in hcsshim/test directory."
}
exit $process.ExitCode
test:
runs-on: ${{ matrix.os }}
strategy:
Expand All @@ -119,17 +96,17 @@ jobs:
go-version: '^1.17.0'

- run: go test -gcflags=all=-d=checkptr -v ./... -tags admin
- run: go test -gcflags=all=-d=checkptr -v ./internal -tags admin
working-directory: test
- run: go test -gcflags=all=-d=checkptr -c ./containerd-shim-runhcs-v1/ -tags functional
- run: go test -mod=mod -gcflags=all=-d=checkptr -v ./internal -tags admin
working-directory: test
- run: go test -mod=mod -gcflags=all=-d=checkptr -c ./containerd-shim-runhcs-v1/ -tags functional
working-directory: test
- run: go test -gcflags=all=-d=checkptr -c ./cri-containerd/ -tags functional
- run: go test -mod=mod -gcflags=all=-d=checkptr -c ./cri-containerd/ -tags functional
working-directory: test
- run: go test -gcflags=all=-d=checkptr -c ./functional/ -tags functional
- run: go test -mod=mod -gcflags=all=-d=checkptr -c ./functional/ -tags functional
working-directory: test
- run: go test -gcflags=all=-d=checkptr -c ./runhcs/ -tags functional
- run: go test -mod=mod -gcflags=all=-d=checkptr -c ./runhcs/ -tags functional
working-directory: test
- run: go build -o sample-logging-driver.exe ./cri-containerd/helpers/log.go
- run: go build -mod=mod -o sample-logging-driver.exe ./cri-containerd/helpers/log.go
working-directory: test

- uses: actions/upload-artifact@v2
Expand Down
18 changes: 0 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,24 +75,6 @@ certify they either authored the work themselves or otherwise have permission to
more info, as well as to make sure that you can attest to the rules listed. Our CI uses the [DCO Github app](https://github.com/apps/dco) to ensure
that all commits in a given PR are signed-off.

### Test Directory (Important to note)

This project has tried to trim some dependencies from the root Go modules file that would be cumbersome to get transitively included if this
project is being vendored/used as a library. Some of these dependencies were only being used for tests, so the /test directory in this project also has
its own go.mod file where these are now included to get around this issue. Our tests rely on the code in this project to run, so the test Go modules file
has a relative path replace directive to pull in the latest hcsshim code that the tests actually touch from this project
(which is the repo itself on your disk).

```
replace (
github.com/Microsoft/hcsshim => ../
)
```

Because of this, for most code changes you may need to run `go mod vendor` + `go mod tidy` in the /test directory in this repository, as the
CI in this project will check if the files are out of date and will fail if this is true.


## Code of Conduct

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
Expand Down
37 changes: 0 additions & 37 deletions test/vendor/github.com/Microsoft/go-winio/README.md

This file was deleted.

Loading

0 comments on commit 3c37022

Please sign in to comment.