Skip to content

Commit f0a86cc

Browse files
authored
Fix license header CI checks (#1492)
1 parent a16d9fb commit f0a86cc

File tree

13 files changed

+44
-38
lines changed

13 files changed

+44
-38
lines changed

LICENSE.header

Lines changed: 0 additions & 2 deletions
This file was deleted.

ipcs/socket/socket_unix.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
//go:build !windows && !plan9 && !js
2-
// +build !windows,!plan9,!js
3-
41
// Copyright (C) 2019-2023, Ava Labs, Inc. All rights reserved.
52
// See the file LICENSE for licensing terms.
63

4+
//go:build !windows && !plan9 && !js
5+
// +build !windows,!plan9,!js
6+
77
package socket
88

99
import (

ipcs/socket/socket_windows.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
//go:build windows
2-
// +build windows
3-
41
// Copyright (C) 2019-2023, Ava Labs, Inc. All rights reserved.
52
// See the file LICENSE for licensing terms.
63

4+
//go:build windows
5+
// +build windows
6+
77
package socket
88

99
import (

license.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
header: |
2+
// Copyright (C) 2019-{{YEAR}}, Ava Labs, Inc. All rights reserved.
3+
// See the file LICENSE for licensing terms.
4+

scripts/lint.sh

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,17 @@ function test_golangci_lint {
2828
golangci-lint run --config .golangci.yml
2929
}
3030

31-
# find_go_files [package]
32-
# all go files except generated ones
33-
function find_go_files {
34-
local target="${1}"
35-
go fmt -n "${target}" | grep -Eo "([^ ]*)$" | grep -vE "(\\.pb\\.go|\\.pb\\.gw.go)"
36-
}
37-
3831
# automatically checks license headers
39-
# to modify the file headers (if missing), remove "--check" flag
40-
# TESTS='license_header' ADDLICENSE_FLAGS="-v" ./scripts/lint.sh
41-
_addlicense_flags=${ADDLICENSE_FLAGS:-"--check -v"}
32+
# to modify the file headers (if missing), remove "--verify" flag
33+
# TESTS='license_header' ADDLICENSE_FLAGS="--debug" ./scripts/lint.sh
34+
_addlicense_flags=${ADDLICENSE_FLAGS:-"--verify --debug"}
4235
function test_license_header {
43-
go install -v github.com/google/addlicense@latest
44-
local target="${1}"
36+
go install -v github.com/palantir/go-license@v1.25.0
4537
local files=()
46-
while IFS= read -r line; do files+=("$line"); done < <(find_go_files "${target}")
38+
while IFS= read -r line; do files+=("$line"); done < <(find . -type f -name '*.go' ! -name '*.pb.go' ! -name 'mock_*.go')
4739

48-
addlicense \
49-
-f ./LICENSE.header \
40+
go-license \
41+
--config=./license.yml \
5042
${_addlicense_flags} \
5143
"${files[@]}"
5244
}

scripts/mock.gen.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,25 @@ then
1414
go install -v github.com/golang/mock/mockgen@v1.6.0
1515
fi
1616

17+
if ! command -v go-license &> /dev/null
18+
then
19+
echo "go-license not found, installing..."
20+
# https://github.com/palantir/go-license
21+
go install -v github.com/palantir/go-license@v1.25.0
22+
fi
23+
1724
# tuples of (source interface import path, comma-separated interface names, output file path)
1825
input="scripts/mocks.mockgen.txt"
1926
while IFS= read -r line
2027
do
2128
IFS='=' read src_import_path interface_name output_path <<< "${line}"
2229
package_name=$(basename $(dirname $output_path))
2330
echo "Generating ${output_path}..."
24-
mockgen -copyright_file=./LICENSE.header -package=${package_name} -destination=${output_path} ${src_import_path} ${interface_name}
31+
mockgen -package=${package_name} -destination=${output_path} ${src_import_path} ${interface_name}
32+
33+
go-license \
34+
--config=./license.yml \
35+
"${output_path}"
2536
done < "$input"
2637

2738
echo "SUCCESS"

snow/engine/snowman/block/height_indexed_vm.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (C) 2019-2023, Ava Labs, Inc. All rights reserved.
22
// See the file LICENSE for licensing terms.
3+
34
package block
45

56
import (

utils/linkedhashmap/iterator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2019-2023, Ava Labs, Inte. All rights reserved.
1+
// Copyright (C) 2019-2023, Ava Labs, Inc. All rights reserved.
22
// See the file LICENSE for licensing terms.
33

44
package linkedhashmap

utils/linkedhashmap/linkedhashmap.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2019-2023, Ava Labs, Inte. All rights reserved.
1+
// Copyright (C) 2019-2023, Ava Labs, Inc. All rights reserved.
22
// See the file LICENSE for licensing terms.
33

44
package linkedhashmap

utils/storage/storage_unix.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
//go:build !windows
2-
// +build !windows
3-
41
// Copyright (C) 2019-2023, Ava Labs, Inc. All rights reserved.
52
// See the file LICENSE for licensing terms.
63

4+
//go:build !windows
5+
// +build !windows
6+
77
package storage
88

99
import "syscall"

0 commit comments

Comments
 (0)