Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

Commit

Permalink
Update license & copyright headers (#97)
Browse files Browse the repository at this point in the history
* Remove licensecheck

* go run ./internal/copyright

* Validate copyright headers in CI

* Add Temporal Technologies Inc. to LICENSE

* Update copyright header to include full LICENSE content as per temporalio/temporal
  • Loading branch information
jlegrone committed Aug 1, 2022
1 parent c93d79b commit a4b633d
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 273 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ on:
branches: [ main ]

jobs:
copyright:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
- name: Verify File Headers
run: go run ./internal/copyright --verify-only
coverage:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 2 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
MIT License

Copyright (c) 2022 Temporal Technologies Inc. All rights reserved.

Copyright (c) 2021 Datadog, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
135 changes: 0 additions & 135 deletions LICENSE-3rdparty.csv

This file was deleted.

4 changes: 4 additions & 0 deletions cmd/temporalite/ui.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Unless explicitly stated otherwise all files in this repository are licensed under the MIT License.
//
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2021 Datadog, Inc.

//go:build !headless

package main
Expand Down
4 changes: 4 additions & 0 deletions cmd/temporalite/ui_disabled.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Unless explicitly stated otherwise all files in this repository are licensed under the MIT License.
//
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2021 Datadog, Inc.

//go:build headless

package main
Expand Down
4 changes: 4 additions & 0 deletions cmd/temporalite/ui_disabled_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Unless explicitly stated otherwise all files in this repository are licensed under the MIT License.
//
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2021 Datadog, Inc.

//go:build headless

package main
Expand Down
4 changes: 4 additions & 0 deletions cmd/temporalite/ui_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Unless explicitly stated otherwise all files in this repository are licensed under the MIT License.
//
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2021 Datadog, Inc.

//go:build !headless

package main
Expand Down
2 changes: 2 additions & 0 deletions internal/copyright/header.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Unless explicitly stated otherwise all files in this repository are licensed under the MIT License.

Copyright (c) 2022 Temporal Technologies Inc. All rights reserved.

This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2021 Datadog, Inc.
41 changes: 24 additions & 17 deletions internal/copyright/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
"strings"
Expand All @@ -53,11 +54,7 @@ type (
}
)

var (
//go:embed header.txt
headerText string
headerPrefixes = []string{"The MIT License", "Unless explicitly stated"}
)
var headerPrefixes = []string{"The MIT License", "Unless explicitly stated"}

var (
// directories to be excluded
Expand All @@ -69,35 +66,45 @@ var (
// command line utility that adds license header
// to the source files. Usage as follows:
//
// ./cmd/tools/copyright/licensegen.go
// go run ./internal/copyright
func main() {
var cfg config
flag.StringVar(&cfg.scanDir, "scanDir", ".", "directory to scan")
flag.BoolVar(&cfg.verifyOnly, "verifyOnly", false, "don't automatically add headers, just verify all files")
flag.StringVar(&cfg.licenseFile, "header-file", "./LICENSE", "file containing copyright header content")
flag.StringVar(&cfg.scanDir, "scan-dir", ".", "directory to scan")
flag.BoolVar(&cfg.verifyOnly, "verify-only", false, "don't automatically add headers, just verify all files")
flag.Parse()

task := newAddLicenseHeaderTask(&cfg)
task, err := newAddLicenseHeaderTask(&cfg)
if err != nil {
log.Fatal(err)
}
if err := task.run(); err != nil {
fmt.Println(err)
os.Exit(-1)
fmt.Println("ERROR:", err)
fmt.Println("To fix missing copyright headers, execute the following command:\n go run ./internal/copyright")
os.Exit(1)
}
}

func newAddLicenseHeaderTask(cfg *config) *addLicenseHeaderTask {
return &addLicenseHeaderTask{
config: cfg,
func newAddLicenseHeaderTask(cfg *config) (*addLicenseHeaderTask, error) {
b, err := os.ReadFile(cfg.licenseFile)
if err != nil {
return nil, err
}
return &addLicenseHeaderTask{
license: string(b),
config: cfg,
}, nil
}

func (task *addLicenseHeaderTask) run() error {
license, err := commentOutLines(headerText)
license, err := commentOutLines(task.license)
if err != nil {
return fmt.Errorf("copyright header failed to comment out lines, err=%v", err.Error())
return fmt.Errorf("copyright header failed to comment out lines: %w", err)
}
task.license = license

if err := filepath.Walk(task.config.scanDir, task.handleFile); err != nil {
return fmt.Errorf("copyright header check failed, err=%v", err.Error())
return fmt.Errorf("copyright header check failed: %w", err)
}
return nil
}
Expand Down
4 changes: 4 additions & 0 deletions internal/examples/helloworld/testinterceptor.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Unless explicitly stated otherwise all files in this repository are licensed under the MIT License.
//
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2021 Datadog, Inc.

package helloworld

import (
Expand Down

0 comments on commit a4b633d

Please sign in to comment.