Merge pull request #3270 from MonzElmasry/validate-go-mod-ci

Add ci step to validate incorrect replacement fork
This commit is contained in:
Menna Elmasry 2021-05-05 20:00:45 +02:00 committed by GitHub
commit 17d91c5148
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 0 deletions

View File

@ -254,6 +254,28 @@ volumes:
host: host:
path: /var/run/docker.sock path: /var/run/docker.sock
---
kind: pipeline
name: validate_go_mods
platform:
os: linux
arch: amd64
steps:
- name: validate_go_mods
image: rancher/dapper:v0.5.0
commands:
- dapper -f Dockerfile.test.mod.dapper
volumes:
- name: docker
path: /var/run/docker.sock
volumes:
- name: docker
host:
path: /var/run/docker.sock
--- ---
kind: pipeline kind: pipeline
name: manifest name: manifest

View File

@ -0,0 +1,11 @@
ARG GOLANG=golang:1.16.2-alpine3.12
FROM ${GOLANG}
RUN apk -U --no-cache add bash jq
ENV DAPPER_SOURCE /go/src/github.com/rancher/k3s/
ENV HOME ${DAPPER_SOURCE}
WORKDIR ${DAPPER_SOURCE}
COPY ./scripts/test-mods /bin/
ENTRYPOINT ["/bin/test-mods"]

10
scripts/test-mods Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
set -e -x
res=$(go mod edit --json | jq '.Replace[] | select(.Old.Path | contains("k8s.io/")) | .New.Path' | grep -v k3s-io | wc -l)
if [ $res -gt 0 ];then
echo "Incorrect kubernetes replacement fork in go.mod"
exit 1
else
exit 0
fi