Skip to content

Commit

Permalink
check for license headers in CI
Browse files Browse the repository at this point in the history
Also update license information to reflect latest authors.

Updates #cleanup

Signed-off-by: Percy Wegmann <[email protected]>
  • Loading branch information
oxtoacart committed Sep 12, 2024
1 parent 521047c commit cab510f
Show file tree
Hide file tree
Showing 31 changed files with 170 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,11 @@ jobs:
- name: Run tests
run: go test -race ./...

licenses:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: check licenses
run: ./scripts/check_license_headers.sh .
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MIT License

Copyright (c) 2021 David Bond
Copyright (c) 2024 Tailscale Inc & Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
77 changes: 77 additions & 0 deletions scripts/check_license_headers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/sh
#
# Copyright (c) David Bond, Tailscale Inc, & Contributors
# SPDX-License-Identifier: MIT

# check_license_headers.sh checks that all Go files in the given
# directory tree have a correct-looking license header.

check_file() {
got=$1

want=$(cat <<EOF
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT
EOF
)
if [ "$got" = "$want" ]; then
return 0
fi
return 1
}

if [ $# != 1 ]; then
echo "Usage: $0 rootdir" >&2
exit 1
fi

fail=0
for file in $(find $1 \( -name '*.go' -or -name '*.tsx' -or -name '*.ts' -not -name '*.config.ts' \) -not -path '*/.git/*' -not -path '*/node_modules/*'); do
case $file in
$1/tempfork/*)
# Skip, tempfork of third-party code
;;
$1/wgengine/router/ifconfig_windows.go)
# WireGuard copyright.
;;
$1/cmd/tailscale/cli/authenticode_windows.go)
# WireGuard copyright.
;;
*_string.go)
# Generated file from go:generate stringer
;;
$1/control/controlbase/noiseexplorer_test.go)
# Noiseexplorer.com copyright.
;;
*/zsyscall_windows.go)
# Generated syscall wrappers
;;
$1/util/winutil/subprocess_windows_test.go)
# Subprocess test harness code
;;
$1/util/winutil/testdata/testrestartableprocesses/main.go)
# Subprocess test harness code
;;
*$1/k8s-operator/apis/v1alpha1/zz_generated.deepcopy.go)
# Generated kube deepcopy funcs file starts with a Go build tag + an empty line
header="$(head -5 $file | tail -n+3 )"
;;
$1/derp/xdp/bpf_bpfe*.go)
# Generated eBPF management code
;;
*)
header="$(head -2 $file)"
;;
esac
if [ ! -z "$header" ]; then
if ! check_file "$header"; then
fail=1
echo "${file#$1/} doesn't have the right copyright header:"
echo "$header" | sed -e 's/^/ /g'
fi
fi
done

if [ $fail -ne 0 ]; then
exit 1
fi
3 changes: 3 additions & 0 deletions tailscale/client.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

// Package tailscale contains a basic implementation of a client for the Tailscale HTTP api. Documentation is here:
// https://github.com/tailscale/tailscale/blob/main/api.md
package tailscale
Expand Down
3 changes: 3 additions & 0 deletions tailscale/client_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale_test

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/tailscale_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale_test

import (
Expand Down
3 changes: 3 additions & 0 deletions tailscale/time_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tailscale_test

import (
Expand Down
3 changes: 3 additions & 0 deletions v2/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

# tailscale-client-go/v2

[![Go Reference](https://pkg.go.dev/badge/github.com/tailscale/tailscale-client-go/v2.svg)](https://pkg.go.dev/github.com/tailscale/tailscale-client-go/v2)
Expand Down
3 changes: 3 additions & 0 deletions v2/client.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

// Package tsclient contains a basic implementation of a client for the Tailscale HTTP api. Documentation is here:
// https://tailscale.com/api
package tsclient
Expand Down
3 changes: 3 additions & 0 deletions v2/client_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tsclient

import (
Expand Down
3 changes: 3 additions & 0 deletions v2/contacts.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tsclient

import (
Expand Down
3 changes: 3 additions & 0 deletions v2/contacts_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tsclient_test

import (
Expand Down
3 changes: 3 additions & 0 deletions v2/device_posture.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tsclient

import (
Expand Down
3 changes: 3 additions & 0 deletions v2/device_posture_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tsclient_test

import (
Expand Down
3 changes: 3 additions & 0 deletions v2/devices.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tsclient

import (
Expand Down
3 changes: 3 additions & 0 deletions v2/devices_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tsclient_test

import (
Expand Down
3 changes: 3 additions & 0 deletions v2/dns.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tsclient

import (
Expand Down
3 changes: 3 additions & 0 deletions v2/dns_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tsclient_test

import (
Expand Down
3 changes: 3 additions & 0 deletions v2/keys.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tsclient

import (
Expand Down
3 changes: 3 additions & 0 deletions v2/keys_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tsclient_test

import (
Expand Down
3 changes: 3 additions & 0 deletions v2/logging.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tsclient

import (
Expand Down
3 changes: 3 additions & 0 deletions v2/logging_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tsclient_test

import (
Expand Down
3 changes: 3 additions & 0 deletions v2/policyfile.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tsclient

import (
Expand Down
3 changes: 3 additions & 0 deletions v2/policyfile_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tsclient_test

import (
Expand Down
3 changes: 3 additions & 0 deletions v2/tailnet_settings.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tsclient

import (
Expand Down
3 changes: 3 additions & 0 deletions v2/tailnet_settings_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tsclient_test

import (
Expand Down
3 changes: 3 additions & 0 deletions v2/tailscale_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tsclient_test

import (
Expand Down
3 changes: 3 additions & 0 deletions v2/users.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tsclient

import (
Expand Down
3 changes: 3 additions & 0 deletions v2/users_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tsclient_test

import (
Expand Down
3 changes: 3 additions & 0 deletions v2/webhooks.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tsclient

import (
Expand Down
3 changes: 3 additions & 0 deletions v2/webhooks_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) David Bond, Tailscale Inc, & Contributors
// SPDX-License-Identifier: MIT

package tsclient_test

import (
Expand Down

0 comments on commit cab510f

Please sign in to comment.