From 45265620c15d5bc058a56349a13d6c7fc884f040 Mon Sep 17 00:00:00 2001 From: MonzElmasry Date: Tue, 4 May 2021 23:20:21 +0200 Subject: [PATCH 1/2] Add ci step to validate incorerct replacement fork Signed-off-by: MonzElmasry --- .drone.yml | 22 ++++++++++++++++++++++ Dockerfile.test.mod.dapper | 11 +++++++++++ scripts/test-mods | 10 ++++++++++ 3 files changed, 43 insertions(+) create mode 100644 Dockerfile.test.mod.dapper create mode 100755 scripts/test-mods diff --git a/.drone.yml b/.drone.yml index 7ac42530b4..0cf5779233 100644 --- a/.drone.yml +++ b/.drone.yml @@ -254,6 +254,28 @@ volumes: host: 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 name: manifest diff --git a/Dockerfile.test.mod.dapper b/Dockerfile.test.mod.dapper new file mode 100644 index 0000000000..ec1232b76e --- /dev/null +++ b/Dockerfile.test.mod.dapper @@ -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"] diff --git a/scripts/test-mods b/scripts/test-mods new file mode 100755 index 0000000000..acd2392bd0 --- /dev/null +++ b/scripts/test-mods @@ -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 \ No newline at end of file From 91c579701678ca22ed2ae26f49ac94f1b7e4b9d0 Mon Sep 17 00:00:00 2001 From: Menna Elmasry <65324011+MonzElmasry@users.noreply.github.com> Date: Wed, 5 May 2021 19:06:12 +0200 Subject: [PATCH 2/2] add new-line Co-authored-by: Brian Downs --- scripts/test-mods | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/test-mods b/scripts/test-mods index acd2392bd0..cc120286f9 100755 --- a/scripts/test-mods +++ b/scripts/test-mods @@ -7,4 +7,4 @@ if [ $res -gt 0 ];then exit 1 else exit 0 -fi \ No newline at end of file +fi