scripts: makefile, dockerfile, travis, ...

This commit is contained in:
Fernandez Ludovic 2019-08-11 12:20:53 +02:00 committed by Traefiker Bot
parent 4c5e7a238d
commit 51b0508512
12 changed files with 71 additions and 133 deletions

View file

@ -65,7 +65,7 @@
text = "Error return value of `rw.Write` is not checked" text = "Error return value of `rw.Write` is not checked"
[[issues.exclude-rules]] [[issues.exclude-rules]]
path = "pkg/middlewares/recovery/recovery.go" path = "pkg/middlewares/recovery/recovery.go"
text = "`logger` can be `github.com/containous/traefik/vendor/github.com/stretchr/testify/assert.TestingT`" text = "`logger` can be `github.com/stretchr/testify/assert.TestingT`"
[[issues.exclude-rules]] [[issues.exclude-rules]]
path = "pkg/provider/docker/builder_test.go" path = "pkg/provider/docker/builder_test.go"
text = "(U1000: func )?`(.+)` is unused" text = "(U1000: func )?`(.+)` is unused"

View file

@ -11,7 +11,7 @@ builds:
env: env:
- CGO_ENABLED=0 - CGO_ENABLED=0
ldflags: ldflags:
- -s -w -X github.com/containous/traefik/pkg/version.Version={{.Version}} -X github.com/containous/traefik/pkg/version.Codename={{.Env.CODENAME}} -X github.com/containous/traefik/pkg/version.BuildDate={{.Date}} - -s -w -X github.com/containous/traefik/v2/pkg/version.Version={{.Version}} -X github.com/containous/traefik/v2/pkg/version.Codename={{.Env.CODENAME}} -X github.com/containous/traefik/v2/pkg/version.BuildDate={{.Date}}
goos: goos:
- linux - linux
@ -40,16 +40,16 @@ builds:
changelog: changelog:
skip: true skip: true
archive: archives:
name_template: '{{ .ProjectName }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm - id: traefik
}}v{{ .Arm }}{{ end }}' name_template: '{{ .ProjectName }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
format: tar.gz format: tar.gz
format_overrides: format_overrides:
- goos: windows - goos: windows
format: zip format: zip
files: files:
- LICENSE.md - LICENSE.md
- CHANGELOG.md - CHANGELOG.md
checksum: checksum:
name_template: "{{ .ProjectName }}_v{{ .Version }}_checksums.txt" name_template: "{{ .ProjectName }}_v{{ .Version }}_checksums.txt"

View file

@ -1,6 +1,6 @@
#!/usr/bin/env bash # For personnal CI
set -e # mv /home/runner/workspace/src/github.com/<username>/ /home/runner/workspace/src/github.com/containous/
# cd /home/runner/workspace/src/github.com/containous/traefik/
for s in apache2 cassandra elasticsearch memcached mysql mongod postgresql sphinxsearch rethinkdb rabbitmq-server redis-server; do sudo service $s stop; done for s in apache2 cassandra elasticsearch memcached mysql mongod postgresql sphinxsearch rethinkdb rabbitmq-server redis-server; do sudo service $s stop; done
sudo swapoff -a sudo swapoff -a
sudo dd if=/dev/zero of=/swapfile bs=1M count=3072 sudo dd if=/dev/zero of=/swapfile bs=1M count=3072
@ -20,3 +20,8 @@ if [ -n "$SHOULD_TEST" ]; then docker version; fi
if [ -f "./.semaphoreci/golang.sh" ]; then ./.semaphoreci/golang.sh; fi if [ -f "./.semaphoreci/golang.sh" ]; then ./.semaphoreci/golang.sh; fi
if [ -f "./.semaphoreci/golang.sh" ]; then export GOROOT="/usr/local/golang/1.12/go"; fi if [ -f "./.semaphoreci/golang.sh" ]; then export GOROOT="/usr/local/golang/1.12/go"; fi
if [ -f "./.semaphoreci/golang.sh" ]; then export GOTOOLDIR="/usr/local/golang/1.12/go/pkg/tool/linux_amd64"; fi if [ -f "./.semaphoreci/golang.sh" ]; then export GOTOOLDIR="/usr/local/golang/1.12/go/pkg/tool/linux_amd64"; fi
if [ -f "./go.mod" ]; then export GO111MODULE=on; fi
if [ -f "./go.mod" ]; then export GOPROXY=https://proxy.golang.org; fi
if [ -f "./go.mod" ]; then go mod download; fi
sudo rm -rf /usr/local/golang/1.4.3/ /usr/local/golang/1.5.4/ /usr/local/golang/1.6.4 /usr/local/golang/1.7.6 /usr/local/golang/1.8.6 /usr/local/golang/1.9.7 /usr/local/golang/1.10.3
df

View file

@ -9,9 +9,10 @@ services:
env: env:
global: global:
- REPO: $TRAVIS_REPO_SLUG - REPO=$TRAVIS_REPO_SLUG
- VERSION: $TRAVIS_TAG - VERSION=$TRAVIS_TAG
- CODENAME: faisselle - CODENAME=faisselle
- GO111MODULE=on
script: script:
- echo "Skipping tests... (Tests are executed on SemaphoreCI)" - echo "Skipping tests... (Tests are executed on SemaphoreCI)"

View file

@ -128,15 +128,6 @@ docs-serve:
generate-crd: generate-crd:
./script/update-generated-crd-code.sh ./script/update-generated-crd-code.sh
## Download dependencies
dep-ensure:
dep ensure -v
./script/prune-dep.sh
## Clean vendor directory
dep-prune:
./script/prune-dep.sh
## Create packages for the release ## Create packages for the release
release-packages: generate-webui build-dev-image release-packages: generate-webui build-dev-image
rm -rf dist rm -rf dist
@ -156,5 +147,5 @@ fmt:
run-dev: run-dev:
go generate go generate
go build ./cmd/traefik GO111MODULE=on go build ./cmd/traefik
./traefik ./traefik

View file

@ -5,31 +5,33 @@ RUN apk --update upgrade \
&& update-ca-certificates \ && update-ca-certificates \
&& rm -rf /var/cache/apk/* && rm -rf /var/cache/apk/*
# Download golangci-lint and misspell binary to bin folder in $GOPATH
RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin v1.17.1 \
&& go get github.com/client9/misspell/cmd/misspell
# Download goreleaser binary to bin folder in $GOPATH
RUN curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | sh
# Which docker version to test on # Which docker version to test on
ARG DOCKER_VERSION=18.09.7 ARG DOCKER_VERSION=18.09.7
ARG DEP_VERSION=0.5.4
# Download go-bindata binary to bin folder in $GOPATH
RUN mkdir -p /usr/local/bin \
&& curl -fsSL -o /usr/local/bin/go-bindata https://github.com/containous/go-bindata/releases/download/v1.0.0/go-bindata \
&& chmod +x /usr/local/bin/go-bindata
# Download dep binary to bin folder in $GOPATH
RUN mkdir -p /usr/local/bin \
&& curl -fsSL -o /usr/local/bin/dep https://github.com/golang/dep/releases/download/v${DEP_VERSION}/dep-linux-amd64 \
&& chmod +x /usr/local/bin/dep
# Download docker # Download docker
RUN mkdir -p /usr/local/bin \ RUN mkdir -p /usr/local/bin \
&& curl -fL https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_VERSION}.tgz \ && curl -fL https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_VERSION}.tgz \
| tar -xzC /usr/local/bin --transform 's#^.+/##x' | tar -xzC /usr/local/bin --transform 's#^.+/##x'
# Download go-bindata binary to bin folder in $GOPATH
RUN mkdir -p /usr/local/bin \
&& curl -fsSL -o /usr/local/bin/go-bindata https://github.com/containous/go-bindata/releases/download/v1.0.0/go-bindata \
&& chmod +x /usr/local/bin/go-bindata
# Download golangci-lint binary to bin folder in $GOPATH
RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin v1.17.1
# Download golangci-lint and misspell binary to bin folder in $GOPATH
RUN GO111MODULE=off go get github.com/client9/misspell/cmd/misspell
# Download goreleaser binary to bin folder in $GOPATH
RUN curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | sh
WORKDIR /go/src/github.com/containous/traefik WORKDIR /go/src/github.com/containous/traefik
# Download go modules
COPY go.mod .
COPY go.sum .
RUN GO111MODULE=on GOPROXY=https://proxy.golang.org go mod download
COPY . /go/src/github.com/containous/traefik COPY . /go/src/github.com/containous/traefik

View file

@ -24,6 +24,12 @@ RUN mkdir -p /usr/local/bin \
&& chmod +x /usr/local/bin/go-bindata && chmod +x /usr/local/bin/go-bindata
WORKDIR /go/src/github.com/containous/traefik WORKDIR /go/src/github.com/containous/traefik
# Download go modules
COPY go.mod .
COPY go.sum .
RUN GO111MODULE=on GOPROXY=https://proxy.golang.org go mod download
COPY . /go/src/github.com/containous/traefik COPY . /go/src/github.com/containous/traefik
RUN rm -rf /go/src/github.com/containous/traefik/static/ RUN rm -rf /go/src/github.com/containous/traefik/static/

View file

@ -28,7 +28,7 @@ fi
# Build binaries # Build binaries
# shellcheck disable=SC2086 # shellcheck disable=SC2086
CGO_ENABLED=0 GOGC=off go build ${FLAGS[*]} -ldflags "-s -w \ CGO_ENABLED=0 GOGC=off go build ${FLAGS[*]} -ldflags "-s -w \
-X github.com/containous/traefik/pkg/version.Version=$VERSION \ -X github.com/containous/traefik/pkg/v2/version.Version=$VERSION \
-X github.com/containous/traefik/pkg/version.Codename=$CODENAME \ -X github.com/containous/traefik/pkg/v2/version.Codename=$CODENAME \
-X github.com/containous/traefik/pkg/version.BuildDate=$DATE" \ -X github.com/containous/traefik/pkg/v2/version.BuildDate=$DATE" \
-a -installsuffix nocgo -o dist/traefik ./cmd/traefik -a -installsuffix nocgo -o dist/traefik ./cmd/traefik

View file

@ -1,6 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
export GO111MODULE=on
export GOPROXY=https://proxy.golang.org
# List of bundles to create when no argument is passed # List of bundles to create when no argument is passed
DEFAULT_BUNDLES=( DEFAULT_BUNDLES=(
generate generate

View file

@ -1,59 +0,0 @@
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
echo "Prune dependencies"
find vendor -name '*_test.go' -exec rm {} \;
find vendor -type f \( ! -iname 'licen[cs]e*' \
-a ! -iname '*notice*' \
-a ! -iname '*patent*' \
-a ! -iname '*copying*' \
-a ! -iname '*unlicense*' \
-a ! -iname '*copyright*' \
-a ! -iname '*copyleft*' \
-a ! -iname '*legal*' \
-a ! -iname 'disclaimer*' \
-a ! -iname 'third-party*' \
-a ! -iname 'thirdparty*' \
-a ! -iname '*.go' \
-a ! -iname '*.c' \
-a ! -iname '*.s' \
-a ! -iname '*.pl' \
-a ! -iname '*.cc' \
-a ! -iname '*.cpp' \
-a ! -iname '*.cxx' \
-a ! -iname '*.h' \
-a ! -iname '*.hh' \
-a ! -iname '*.hpp' \
-a ! -iname '*.hxx' \
-a ! -wholename 'vendor/k8s.io/code-generator/*' \
-a ! -iname '*.s' \) -exec rm -f {} +
find . -type d \( -iname '*Godeps*' \) -exec rm -rf {} +
find vendor -type l \( ! -iname 'licen[cs]e*' \
-a ! -iname '*notice*' \
-a ! -iname '*patent*' \
-a ! -iname '*copying*' \
-a ! -iname '*unlicense*' \
-a ! -iname '*copyright*' \
-a ! -iname '*copyleft*' \
-a ! -iname '*legal*' \
-a ! -iname 'disclaimer*' \
-a ! -iname 'third-party*' \
-a ! -iname 'thirdparty*' \
-a ! -iname '*.go' \
-a ! -iname '*.c' \
-a ! -iname '*.S' \
-a ! -iname '*.cc' \
-a ! -iname '*.cpp' \
-a ! -iname '*.cxx' \
-a ! -iname '*.h' \
-a ! -iname '*.hh' \
-a ! -iname '*.hpp' \
-a ! -iname '*.hxx' \
-a ! -iname '*.s' \) -exec rm -f {} +

View file

@ -2,6 +2,7 @@
HACK_DIR="$( cd "$( dirname "${0}" )" && pwd -P)"; export HACK_DIR HACK_DIR="$( cd "$( dirname "${0}" )" && pwd -P)"; export HACK_DIR
REPO_ROOT=${HACK_DIR}/.. REPO_ROOT=${HACK_DIR}/..
TRAEFIK_MODULE_VERSION=v2
rm -rf "${REPO_ROOT}"/vendor rm -rf "${REPO_ROOT}"/vendor
go mod vendor go mod vendor
@ -9,16 +10,19 @@ chmod +x "${REPO_ROOT}"/vendor/k8s.io/code-generator/*.sh
"${REPO_ROOT}"/vendor/k8s.io/code-generator/generate-groups.sh \ "${REPO_ROOT}"/vendor/k8s.io/code-generator/generate-groups.sh \
all \ all \
github.com/containous/traefik/pkg/provider/kubernetes/crd/generated \ github.com/containous/traefik/${TRAEFIK_MODULE_VERSION}/pkg/provider/kubernetes/crd/generated \
github.com/containous/traefik/pkg/provider/kubernetes/crd \ github.com/containous/traefik/${TRAEFIK_MODULE_VERSION}/pkg/provider/kubernetes/crd \
traefik:v1alpha1 \ traefik:v1alpha1 \
--go-header-file "${HACK_DIR}"/boilerplate.go.tmpl \ --go-header-file "${HACK_DIR}"/boilerplate.go.tmpl \
"$@" "$@"
deepcopy-gen \ deepcopy-gen \
--input-dirs github.com/containous/traefik/pkg/config/dynamic \ --input-dirs github.com/containous/traefik/${TRAEFIK_MODULE_VERSION}/pkg/config/dynamic \
--input-dirs github.com/containous/traefik/pkg/tls \ --input-dirs github.com/containous/traefik/${TRAEFIK_MODULE_VERSION}/pkg/tls \
--input-dirs github.com/containous/traefik/pkg/types \ --input-dirs github.com/containous/traefik/${TRAEFIK_MODULE_VERSION}/pkg/types \
--output-package github.com/containous/traefik \
-O zz_generated.deepcopy --go-header-file "${HACK_DIR}"/boilerplate.go.tmpl -O zz_generated.deepcopy --go-header-file "${HACK_DIR}"/boilerplate.go.tmpl
cp -r "${REPO_ROOT}"/"${TRAEFIK_MODULE_VERSION:?}"/* "${REPO_ROOT}"; rm -rf "${REPO_ROOT}"/"${TRAEFIK_MODULE_VERSION:?}"
rm -rf "${REPO_ROOT}"/vendor rm -rf "${REPO_ROOT}"/vendor

View file

@ -4,26 +4,11 @@ set -o pipefail
set -o nounset set -o nounset
SCRIPT_DIR="$( cd "$( dirname "${0}" )" && pwd -P)"; export SCRIPT_DIR SCRIPT_DIR="$( cd "$( dirname "${0}" )" && pwd -P)"; export SCRIPT_DIR
vendor_dir="./vendor/"
# We run dep install to and see if we have a diff afterwards echo "checking go modules for unintentional changes..."
echo "checking ${vendor_dir} for unintentional changes..."
dep ensure -v go mod tidy
("${SCRIPT_DIR}"/prune-dep.sh) git diff --exit-code go.mod
git diff --exit-code go.sum
# Let see if the working directory is clean echo 'Congratulations! All go modules changes are done the right way.'
diffs="$(git status --porcelain -- ${vendor_dir} 2>/dev/null)"
if [[ "$diffs" ]]; then
{
echo "The result of 'dep ensure' for vendor directory '${vendor_dir}' differs"
echo
echo "$diffs"
echo
echo 'Please vendor your package(s) with dep.'
echo
} >&2
exit 2
fi
echo 'Congratulations! All vendoring changes are done the right way.'