tools: add prepare-source.sh

A script that runs various go tools (mod tidy, mod vendor, and fmt for
now).

The idea is that it prepares the source to be ready for master. As such,
running it on master shouldn't modify any files. Make sure of that by
adding a test.
This commit is contained in:
Lars Karlitski 2020-02-14 13:22:38 +01:00
parent 6703055925
commit 049969911d
2 changed files with 17 additions and 0 deletions

View file

@ -8,6 +8,16 @@ addons:
- gnupg2
matrix:
include:
- name: source-test
script:
- |
set -e
./tools/prepare-source.sh
if [ ! $(git diff --quiet --exit-code) ]; then
echo
echo "Please include these changes in your branch: "
git diff
fi
- name: unit-tests
arch: amd64
language: go

7
tools/prepare-source.sh Executable file
View file

@ -0,0 +1,7 @@
#!/bin/sh
set -eux
go fmt ./...
go mod tidy
go mod vendor