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

Adds license header checker workflow #302

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
56 changes: 56 additions & 0 deletions .ci/license/check-license-headers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env bash
# Copyright OpenSearch Contributors
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.

# Check that source code files in this repo have the appropriate license
# header.

if [ "$TRACE" != "" ]; then
export PS4='${BASH_SOURCE}:${LINENO}: ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
set -o xtrace
fi
set -o errexit
set -o pipefail

TOP=$(cd "$(dirname "$0")/.." >/dev/null && pwd)
NLINES_SC=$(wc -l ./.ci/license/license-sc.txt | awk '{print $1}')
NLINES_MC=$(wc -l ./.ci/license/license-mc.txt | awk '{print $1}')

echo $NLINES_SC
echo $NLINES_MC

function check_license_header {
local fP
f=$1
if (diff -a --strip-trailing-cr license/license-mc.txt <(head -$NLINES_MC "$f") >/dev/null) || (diff -a --strip-trailing-cr license/license-sc.txt <(head -$NLINES_SC "$f") >/dev/null); then
return 0
else
echo "check-license-headers: error: '$f' does not have required license header, see 'diff -u ./.ci/license/license-mc.txt <(head -$NLINES_MC ../$f)'"
return 1
fi
}

cd "$TOP"
nErrors=0

for f in $(git ls-files --directory ../ | grep '\.ts$'); do
if ! check_license_header $f; then
nErrors=$((nErrors+1))
fi
done

for f in $(git ls-files --directory ../ | grep '\.js$'); do
if ! check_license_header $f; then
nErrors=$((nErrors+1))
fi
done

if [[ $nErrors -eq 0 ]]; then
exit 0
else
exit 1
fi
9 changes: 9 additions & 0 deletions .ci/license/license-mc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/
6 changes: 6 additions & 0 deletions .ci/license/license-sc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright OpenSearch Contributors
// SPDX-License-Identifier: Apache-2.0
//
// The OpenSearch Contributors require contributions made to
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
14 changes: 14 additions & 0 deletions .github/workflows/license-header.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: License headers

on: [push, pull_request]

jobs:
licenseheader:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Check license headers
run: "./.ci/license/check-license-headers.sh"
3 changes: 1 addition & 2 deletions api/api/bulk.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

/*
Expand Down
3 changes: 1 addition & 2 deletions api/api/cat.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

/*
Expand Down
3 changes: 1 addition & 2 deletions api/api/clear_scroll.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

/*
Expand Down
3 changes: 1 addition & 2 deletions api/api/cluster.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

/*
Expand Down
3 changes: 1 addition & 2 deletions api/api/count.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

/*
Expand Down
3 changes: 1 addition & 2 deletions api/api/create.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

/*
Expand Down
3 changes: 1 addition & 2 deletions api/api/dangling_indices.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

/*
Expand Down
3 changes: 1 addition & 2 deletions api/api/delete.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

/*
Expand Down
3 changes: 1 addition & 2 deletions api/api/delete_by_query.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

/*
Expand Down
3 changes: 1 addition & 2 deletions api/api/delete_by_query_rethrottle.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

/*
Expand Down
3 changes: 1 addition & 2 deletions api/api/delete_script.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

/*
Expand Down
3 changes: 1 addition & 2 deletions api/api/exists.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

/*
Expand Down
3 changes: 1 addition & 2 deletions api/api/exists_source.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

/*
Expand Down
3 changes: 1 addition & 2 deletions api/api/explain.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

/*
Expand Down
3 changes: 1 addition & 2 deletions api/api/features.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

/*
Expand Down
3 changes: 1 addition & 2 deletions api/api/field_caps.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

/*
Expand Down
3 changes: 1 addition & 2 deletions api/api/get.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

/*
Expand Down
3 changes: 1 addition & 2 deletions api/api/get_script.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

/*
Expand Down
3 changes: 1 addition & 2 deletions api/api/get_script_context.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

/*
Expand Down
3 changes: 1 addition & 2 deletions api/api/get_script_languages.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

/*
Expand Down
3 changes: 1 addition & 2 deletions api/api/get_source.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

/*
Expand Down
3 changes: 1 addition & 2 deletions api/api/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

/*
Expand Down
Loading