From 9d42148b93f0f40171b1c802215dc11f9e3fc766 Mon Sep 17 00:00:00 2001 From: Victor Farazdagi Date: Mon, 15 Jun 2020 19:15:54 +0300 Subject: [PATCH] Go mod tidy (#6264) * updates go.sum * go mod tidy checker * reverts go.sum * updates apk command * fixes path * show git status * more debug info * more debug info * minor test * get rid of git * multiple checks * test reset * change order of checkers * mod verify * broken sum * Merge refs/heads/master into go-mod-tidy * better info * Merge branch 'go-mod-tidy' of github.com:prysmaticlabs/prysm into go-mod-tidy * better info * reset * run go mod tidy to fix --- .github/actions/gomodtidy/Dockerfile | 5 ++++ .github/actions/gomodtidy/action.yml | 5 ++++ .github/actions/gomodtidy/entrypoint.sh | 34 +++++++++++++++++++++++++ .github/workflows/go.yml | 4 +++ 4 files changed, 48 insertions(+) create mode 100644 .github/actions/gomodtidy/Dockerfile create mode 100644 .github/actions/gomodtidy/action.yml create mode 100755 .github/actions/gomodtidy/entrypoint.sh diff --git a/.github/actions/gomodtidy/Dockerfile b/.github/actions/gomodtidy/Dockerfile new file mode 100644 index 000000000..9ea7e87af --- /dev/null +++ b/.github/actions/gomodtidy/Dockerfile @@ -0,0 +1,5 @@ +FROM golang:alpine + +COPY entrypoint.sh /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/.github/actions/gomodtidy/action.yml b/.github/actions/gomodtidy/action.yml new file mode 100644 index 000000000..27d3d8e9e --- /dev/null +++ b/.github/actions/gomodtidy/action.yml @@ -0,0 +1,5 @@ +name: 'Go mod tidy checker' +description: 'Checks that `go mod tidy` has been applied.' +runs: + using: 'docker' + image: 'Dockerfile' diff --git a/.github/actions/gomodtidy/entrypoint.sh b/.github/actions/gomodtidy/entrypoint.sh new file mode 100755 index 000000000..7c952aa0c --- /dev/null +++ b/.github/actions/gomodtidy/entrypoint.sh @@ -0,0 +1,34 @@ +#!/bin/sh -l +set -e +export PATH=$PATH:/usr/local/go/bin + +cd $GITHUB_WORKSPACE + +cp go.mod go.mod.orig +cp go.sum go.sum.orig + +go mod tidy + +echo "Checking go.mod and go.sum:" +checks=0 +if [ "$(diff -s go.mod.orig go.mod | grep -c 'Files go.mod.orig and go.mod are identical')" = 1 ]; then + echo "- go.mod is up to date." + checks=$((checks + 1)) +else + echo "- go.mod is NOT up to date." +fi + +if [ "$(diff -s go.sum.orig go.sum | grep -c 'Files go.sum.orig and go.sum are identical')" = 1 ]; then + echo "- go.sum is up to date." + checks=$((checks + 1)) +else + echo "- go.sum is NOT up to date." +fi + +if [ $checks -eq 2 ]; then + exit 0 +fi + +# Notify of any issues. +echo "Run 'go mod tidy' to update." +exit 1 diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 3d66357bf..f91015923 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -15,6 +15,10 @@ jobs: - name: Checkout uses: actions/checkout@v1 + - name: Go mod tidy checker + id: gomodtidy + uses: ./.github/actions/gomodtidy + - name: Gofmt checker id: gofmt uses: ./.github/actions/gofmt