Skip to content

Add Go modules to vendor directory #17

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Check vendor
run: DOCKER_BUILDKIT=1 make check-vendor

- name: Lint code
run: DOCKER_BUILDKIT=1 make lint

Expand Down
15 changes: 9 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

.DEFAULT_GOAL := help

PACKAGE=github.com/compose-spec/conformance-tests
IMAGE_PREFIX=composespec/conformance-tests-

.DEFAULT_GOAL := help
GOFLAGS=-mod=vendor

.PHONY: check
check: ## Checks the environment before running any command
Expand All @@ -24,12 +26,12 @@ check: ## Checks the environment before running any command

.PHONY: images
images: ## Build the test images
docker build server -t $(IMAGE_PREFIX)server
docker build client -t $(IMAGE_PREFIX)client
docker build . -f server/Dockerfile -t $(IMAGE_PREFIX)server
docker build . -f client/Dockerfile -t $(IMAGE_PREFIX)client

.PHONY: test
test: check images ## Run tests
GOPRIVATE=$(PACKAGE) go test ./... -v
GOPRIVATE=$(PACKAGE) GOFLAGS=$(GOFLAGS) go test ./... -v

.PHONY: fmt
fmt: ## Format go files
Expand All @@ -47,8 +49,9 @@ lint: build-validate-image
check-license: build-validate-image
docker run --rm $(IMAGE_PREFIX)validate bash -c "./scripts/validate/fileheader"

.PHONY: validate
validate: lint check-license
.PHONY: check-vendor
check-vendor: build-validate-image
docker run --rm $(IMAGE_PREFIX)validate bash -c "./scripts/validate/vendor"

.PHONY: help
help:
Expand Down
8 changes: 4 additions & 4 deletions ci/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
FROM golang:1.14

WORKDIR /go/src
RUN go mod init github.com/compose-spec/conformance-tests

ARG GOLANGCILINT_VERSION=v1.23.8
ARG GOLANGCILINT_VERSION=v1.24.0
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCILINT_VERSION}
RUN go get -u github.com/kunalkushwaha/ltag
RUN go get -v -u github.com/kunalkushwaha/ltag && rm -rf /go/src/github.com/kunalkushwaha

COPY . /go/src
ENV GOFLAGS=-mod=vendor
COPY . .
3 changes: 1 addition & 2 deletions client/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
FROM golang:1.14 AS dev
WORKDIR /go/src
COPY . .
RUN go mod init github.com/compose-spec/conformance-tests/client
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /client .
RUN CGO_ENABLED=0 GOFLAGS=-mod=vendor go build -o /client client/main.go

FROM scratch AS run
COPY --from=dev client /
Expand Down
2 changes: 1 addition & 1 deletion scripts/validate/fileheader
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ fi

BASEPATH="${1-}"

ltag -t "${BASEPATH}scripts/validate/template" --excludes "validate" --check -v
ltag -t "${BASEPATH}scripts/validate/template" --excludes "validate vendor" --check -v
33 changes: 33 additions & 0 deletions scripts/validate/vendor
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

# Copyright The Compose Specification Authors.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


set -eu -o pipefail

go mod tidy 2>/dev/null && go mod vendor 2>/dev/null
Copy link
Member

Choose a reason for hiding this comment

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

One thing to consider (no blocker) is if we want this to always be run, or only if either the Go version is updated, or if go.mod or vendor/ has been modified in a pull request

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tonis didn't have access to this GitHub org. I've added him and will re-ping when he's accepted.


status="$(git status --porcelain -- go.mod go.sum vendor 2>/dev/null)"
diffs=$(echo "$status" | grep -v '^[RAD] ' || true)
if [ "$diffs" ]; then
{
set +x
echo 'Unexpected vendor diff:'
echo
echo "$diffs"
echo
} >&2
exit 1
fi
3 changes: 1 addition & 2 deletions server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
FROM golang:1.14 AS dev
WORKDIR /go/src
COPY . .
RUN go mod init github.com/compose-spec/conformance-tests/server
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /server .
RUN CGO_ENABLED=0 GOFLAGS=-mod=vendor go build -o /server server/main.go

FROM scratch AS run
COPY --from=dev server /
Expand Down
27 changes: 27 additions & 0 deletions vendor/github.com/google/go-cmp/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading