Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce copyright check in CI #1965

Merged
merged 8 commits into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

# bazel configurations for running tests under sanitizers.
# Based on https://github.com/bazelment/trunk/blob/master/tools/bazel.rc

Expand Down
3 changes: 3 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

# See Clang docs: http://clang.llvm.org/docs/ClangFormatStyleOptions.html
BasedOnStyle: Chromium

Expand Down
3 changes: 3 additions & 0 deletions .cmake-format.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

# If comment markup is enabled, don't reflow the first comment block in
# eachlistfile. Use this to preserve formatting of your
# copyright/licensestatements.
Expand Down
45 changes: 45 additions & 0 deletions .copyright-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright 2023, The OpenTelemetry Authors
marcalff marked this conversation as resolved.
Show resolved Hide resolved
# SPDX-License-Identifier: Apache-2.0

# Ignore the following directories

./.git/*
./.github/*
./third_party/*
marcalff marked this conversation as resolved.
Show resolved Hide resolved
./tools/vcpkg/*
./tools/ports/*

# Third party code

./api/include/opentelemetry/nostd/internal/absl/*
./exporters/jaeger/thrift-gen/*
./exporters/etw/include/opentelemetry/exporters/etw/TraceLoggingDynamic.h

# Doc

./docs/*

## Ignore the following files patterns

*.md
*.rst
*.png
*.log
*.patch
*.json
*.nuspec

# Packaging
*/CONTROL

# LICENSE files
*/LICENSE

# Ignore the following misc files

./.bazelignore
./.bazelversion
./docker/.gitignore
.markdownlintignore
./ci/toc.yml
./ci/valgrind-suppressions
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,13 @@ jobs:
- name: run tests
run: ./ci/do_ci.sh format

copyright:
name: Copyright
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: check copyright
run: ./tools/check_copyright.sh

windows:
name: CMake -> exporter proto
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

# Ref. https://github.com/github/gitignore/blob/master/C%2B%2B.gitignore
# Prerequisites
*.d
Expand Down Expand Up @@ -51,3 +54,6 @@

tags
.cache/clangd/*

# Temporary dir used when generating semconv
./buildscripts/semantic-convention/opentelemetry-specification
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Increment the:

* Convert Prometheus Exporter to Pull MetricReader [#1953](https://github.com/open-telemetry/opentelemetry-cpp/pull/1953)
* Upgrade prometheus-cpp to v1.1.0 [#1954](https://github.com/open-telemetry/opentelemetry-cpp/pull/1954)
* [CI] Enforce copyright check in CI [#1965](https://github.com/open-telemetry/opentelemetry-cpp/pull/1965)

## [1.8.2] 2023-01-31

Expand Down
1 change: 0 additions & 1 deletion buildscripts/semantic-convention/.gitignore

This file was deleted.

3 changes: 3 additions & 0 deletions ci/docfx.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
REM Copyright The OpenTelemetry Authors
REM SPDX-License-Identifier: Apache-2.0

SETLOCAL ENABLEEXTENSIONS

type ci\docfx.json > docfx.json
Expand Down
3 changes: 3 additions & 0 deletions cmake/opentelemetry-cpp-config.cmake.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2023, The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

#.rst:
# opentelemetry-cpp-config.cmake
# --------
Expand Down
3 changes: 3 additions & 0 deletions docker/Dockerfile.alpine.base
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2023, The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

ARG BASE_IMAGE=alpine:latest
ARG CORES=${nproc}

Expand Down
3 changes: 3 additions & 0 deletions docker/Dockerfile.centos
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2023, The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

FROM centos:7

ARG TOOLSET_VER=11
Expand Down
3 changes: 3 additions & 0 deletions docker/Dockerfile.debian.deps
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2023, The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

ARG BASE_IMAGE=ubuntu:latest
ARG CORES=${nproc}

Expand Down
15 changes: 2 additions & 13 deletions sdk/src/trace/samplers/trace_id_ratio.cc
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
// Copyright 2020, Open Telemetry Authors
// Copyright 2020, 2023, The OpenTelemetry Authors
// Copyright 2017, OpenCensus Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// SPDX-License-Identifier: Apache-2.0

#include "opentelemetry/sdk/trace/samplers/trace_id_ratio.h"

Expand Down
3 changes: 3 additions & 0 deletions tools/build-bazel.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
REM Copyright The OpenTelemetry Authors
REM SPDX-License-Identifier: Apache-2.0

pushd "%~dp0"
set "PATH=%CD%;%PATH%"
cd ..
Expand Down
3 changes: 3 additions & 0 deletions tools/build-benchmark.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
REM Copyright The OpenTelemetry Authors
REM SPDX-License-Identifier: Apache-2.0

@echo off
set BUILDTOOLS_VERSION=vs2019
set CMAKE_GEN="Visual Studio 16 2019"
Expand Down
3 changes: 3 additions & 0 deletions tools/build-clang-12.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
REM Copyright The OpenTelemetry Authors
REM SPDX-License-Identifier: Apache-2.0

@echo off
pushd %~dp0
set "PATH=%ProgramFiles%\LLVM-12\bin;%PATH%"
Expand Down
3 changes: 3 additions & 0 deletions tools/build-clang.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
REM Copyright The OpenTelemetry Authors
REM SPDX-License-Identifier: Apache-2.0

@echo off
pushd %~dp0
set "PATH=%ProgramFiles%\LLVM\bin;%PATH%"
Expand Down
3 changes: 3 additions & 0 deletions tools/build-docker.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
REM Copyright The OpenTelemetry Authors
REM SPDX-License-Identifier: Apache-2.0

@echo off
pushd %~dp0
REM Default arguments
Expand Down
3 changes: 3 additions & 0 deletions tools/build-nuget.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
REM Copyright The OpenTelemetry Authors
REM SPDX-License-Identifier: Apache-2.0

@echo off
pushd "%~dp0"
set "PATH=%CD%;%PATH%"
Expand Down
3 changes: 3 additions & 0 deletions tools/build-vs2015.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
REM Copyright The OpenTelemetry Authors
REM SPDX-License-Identifier: Apache-2.0

REM Build with Visual Studio 2015
set "PATH=%ProgramFiles(x86)%\MSBuild\14.0\Bin;%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\VC\bin;%PATH%"

Expand Down
3 changes: 3 additions & 0 deletions tools/build-vs2017.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
REM Copyright The OpenTelemetry Authors
REM SPDX-License-Identifier: Apache-2.0

REM Build with Visual Studio 2017
set "BUILDTOOLS_VERSION=vs2017"
set ARCH=x64
Expand Down
3 changes: 3 additions & 0 deletions tools/build-vs2019.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
REM Copyright The OpenTelemetry Authors
REM SPDX-License-Identifier: Apache-2.0

REM Build with Visual Studio 2019
set "BUILDTOOLS_VERSION=vs2019"
set ARCH=x64
Expand Down
3 changes: 3 additions & 0 deletions tools/build-vs2022.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
REM Copyright The OpenTelemetry Authors
REM SPDX-License-Identifier: Apache-2.0

REM Build with Visual Studio 2022
set "BUILDTOOLS_VERSION=vs2022"
set ARCH=x64
Expand Down
3 changes: 3 additions & 0 deletions tools/build.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
REM Copyright The OpenTelemetry Authors
REM SPDX-License-Identifier: Apache-2.0

@echo off
REM ##########################################################################################
REM # Build SDK with (msvc or clang) + CMake + (MSBuild or Ninja). #
Expand Down
99 changes: 99 additions & 0 deletions tools/check_copyright.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#!/bin/bash

# Copyright 2023, The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

if [[ ! -e tools/check_copyright.sh ]]; then
echo "This tool must be run from the topmost directory." >&2
exit 1
fi

set -e

#
# Process input file .copyright-ignore,
# - remove comments
# - remove blank lines
# to create file /tmp/all_ignored
#

grep -v "^#" < .copyright-ignore | \
grep -v "^[[:space:]]*$" > /tmp/all_ignored

#
# Find all files from the repository
# to create file /tmp/all_checked
#

find . -type f -print | sort -u > /tmp/all_checked

#
# Filter out /tmp/all_checked,
# remove all ignored patterns from /tmp/all_ignored
# When the pattern is *.md,
# make sure to filter *\.md to avoid hiding *.cmd
# Then, *\.md needs to be escaped to *\\.md,
# to be given to egrep, hence the sed.
#

while IFS= read -r PATTERN; do
SAFE_PATTERN=`echo "${PATTERN}" | sed "s!\.!\\\\\.!g"`
echo "Filtering out ${SAFE_PATTERN}"
egrep -v "${SAFE_PATTERN}" < /tmp/all_checked > /tmp/all_checked-tmp
mv /tmp/all_checked-tmp /tmp/all_checked
done < /tmp/all_ignored

#
# For all files in /tmp/all_checked
# - verify there is copyright
# - verify there is a license
# and append to /tmp/all_missing
#
# Valid copyright strings are:
# - Copyright The OpenTelemetry Authors
# - Copyright YEAR, The OpenTelemetry Authors
# - Copyright YEAR, YEAR, The OpenTelemetry Authors
marcalff marked this conversation as resolved.
Show resolved Hide resolved
#
# Valid license strings are:
# - SPDX-License-Identifier: Apache-2.0
#

rm -rf /tmp/all_missing
touch /tmp/all_missing

for FILE in `cat /tmp/all_checked`
do
echo "Checking ${FILE}"
export COPYRIGHT=`head -10 ${FILE} | egrep -c "Copyright (20[0-9][0-9], ){0,2}The OpenTelemetry Authors"`
export LICENSE=`head -10 ${FILE} | grep -c "SPDX-License-Identifier: Apache-2.0"`
if [ "$COPYRIGHT" == "0" ]; then
echo "Missing copyright in ${FILE}" >> /tmp/all_missing
fi;
if [ "${LICENSE}" == "0" ]; then
echo "Missing license in ${FILE}" >> /tmp/all_missing
fi;
done

#
# Final report
#

FAIL_COUNT=`wc -l < /tmp/all_missing`

if [ ${FAIL_COUNT} != "0" ]; then
#
# CI FAILED
#

cat /tmp/all_missing

echo "Total number of failed checks: ${FAIL_COUNT}"
exit 1
fi;

#
# CI PASSED
#

exit 0

3 changes: 3 additions & 0 deletions tools/download.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
REM Copyright The OpenTelemetry Authors
REM SPDX-License-Identifier: Apache-2.0

@REM This script allows to download a file to local machine. First argument is URL
set "PATH=%SystemRoot%;%SystemRoot%\System32;%SystemRoot%\System32\WindowsPowerShell\v1.0\;%ProgramFiles%\Git\bin"
@powershell -File Download.ps1 %1
3 changes: 3 additions & 0 deletions tools/git-cl.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
REM Copyright The OpenTelemetry Authors
REM SPDX-License-Identifier: Apache-2.0

@echo off
setlocal enabledelayedexpansion
if "%1" == "format" (
Expand Down
3 changes: 3 additions & 0 deletions tools/install-vs-addons.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
REM Copyright The OpenTelemetry Authors
REM SPDX-License-Identifier: Apache-2.0

set "PATH=%SystemRoot%;%SystemRoot%\System32;%SystemRoot%\System32\WindowsPowerShell\v1.0\;%ProgramFiles%\Git\bin"
cd %~dp0
call powershell -File .\install_llvm-win64.ps1
Expand Down
3 changes: 3 additions & 0 deletions tools/setup-buildtools.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
REM Copyright The OpenTelemetry Authors
REM SPDX-License-Identifier: Apache-2.0

@echo off
setlocal enableextensions
setlocal enabledelayedexpansion
Expand Down
3 changes: 3 additions & 0 deletions tools/setup-devenv.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
REM Copyright The OpenTelemetry Authors
REM SPDX-License-Identifier: Apache-2.0

endlocal
set "PATH=%~dp0;%PATH%"
set "TOOLS_PATH=%~dp0"
Expand Down
3 changes: 3 additions & 0 deletions tools/vcvars.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
REM Copyright The OpenTelemetry Authors
REM SPDX-License-Identifier: Apache-2.0

@echo off
REM +-------------------------------------------------------------------+
REM | Autodetect and set up the build environment. |
Expand Down