Add CI check for license headers

Otherwise no one is ever going to add them.
varsha/versions
Adam Wolfe Gordon 2019-07-02 13:58:00 -06:00
parent 2b080d1b9a
commit 401837a7aa
2 changed files with 28 additions and 0 deletions

View File

@ -6,6 +6,7 @@ workflow "Pull Request" {
"vet",
"lint",
"test",
"check-licenses",
]
}
@ -32,3 +33,8 @@ action "test" {
}
runs = ["go", "test", "-race", "-cover", "./..."]
}
action "check-licenses" {
uses = "docker://golang:1.12.6"
runs = ["./script/check-licenses.sh"]
}

22
script/check-licenses.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash
function list_go_files {
srcdir=$(realpath $(dirname "${BASH_SOURCE[0]}")/..)
for f in $(find "$srcdir" -name '*.go' -and -not -path "$srcdir/vendor/*") ; do
echo "$f"
done
}
function has_license {
head -n2 "$1" | grep -q 'Copyright .... DigitalOcean'
}
ret=0
for f in $(list_go_files) ; do
if ! has_license "$f" ; then
echo "$f is missing license header"
ret=1
fi
done
exit $ret