Add CI check for license headers
Otherwise no one is ever going to add them.varsha/versions
parent
2b080d1b9a
commit
401837a7aa
|
@ -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"]
|
||||
}
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue