mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-18 03:23:37 +08:00
Add automated license check to travis
This commit is contained in:
parent
eaa796eeba
commit
d4f2a37e4b
@ -98,7 +98,7 @@ jobs:
|
|||||||
# This tests the formatting of a PR.
|
# This tests the formatting of a PR.
|
||||||
- if: (type = pull_request) OR (type = cron) OR NOT (branch = master)
|
- if: (type = pull_request) OR (type = cron) OR NOT (branch = master)
|
||||||
stage: test
|
stage: test
|
||||||
name: "pgindent"
|
name: "pgindent and license check"
|
||||||
env:
|
env:
|
||||||
- PG_VERSION=10.2 PG_GIT_TAG=REL_10_2
|
- PG_VERSION=10.2 PG_GIT_TAG=REL_10_2
|
||||||
before_install:
|
before_install:
|
||||||
@ -112,6 +112,7 @@ jobs:
|
|||||||
- docker exec -it pgbuild /bin/bash -c 'cd /build/debug && make pgindent'
|
- docker exec -it pgbuild /bin/bash -c 'cd /build/debug && make pgindent'
|
||||||
- docker exec -it pgbuild /bin/bash -c 'diff -r -q /build/src /tmp/timescale_src'
|
- docker exec -it pgbuild /bin/bash -c 'diff -r -q /build/src /tmp/timescale_src'
|
||||||
- docker exec -it pgbuild /bin/bash -c 'diff -r -q /build/test/src /tmp/timescale_test_src'
|
- docker exec -it pgbuild /bin/bash -c 'diff -r -q /build/test/src /tmp/timescale_test_src'
|
||||||
|
- docker exec -it pgbuild /bin/bash -c 'cd /build/debug && make licensecheck'
|
||||||
|
|
||||||
- if: type = cron
|
- if: type = cron
|
||||||
stage: test
|
stage: test
|
||||||
|
@ -300,3 +300,10 @@ endif (UNIX)
|
|||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
add_subdirectory(sql)
|
add_subdirectory(sql)
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|
||||||
|
add_custom_target(licensecheck
|
||||||
|
SRC_DIR=${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/check_license_apache.sh -c ${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||||
|
COMMAND SRC_DIR=${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/check_license_apache.sh -s ${CMAKE_CURRENT_SOURCE_DIR}/sql
|
||||||
|
COMMAND SRC_DIR=${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/check_license_apache.sh -c ${CMAKE_CURRENT_SOURCE_DIR}/test
|
||||||
|
COMMAND SRC_DIR=${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/check_license_apache.sh -t ${CMAKE_CURRENT_SOURCE_DIR}/test
|
||||||
|
USES_TERMINAL)
|
||||||
|
6
scripts/c_license_header.h
Normal file
6
scripts/c_license_header.h
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016-2018 Timescale, Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* This file is licensed under the Apache License,
|
||||||
|
* see LICENSE-APACHE at the top level directory.
|
||||||
|
*/
|
38
scripts/check_file_license_apache.sh
Executable file
38
scripts/check_file_license_apache.sh
Executable file
@ -0,0 +1,38 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
FLAG=${1}
|
||||||
|
FILE=${2}
|
||||||
|
SCRIPTPATH="$( cd "$(dirname "${0}")" ; pwd -P )"
|
||||||
|
TIMESCALE_LOCATION=`dirname ${SCRIPTPATH}`
|
||||||
|
|
||||||
|
LICENSE_FILE=
|
||||||
|
LICENSE_STRING=
|
||||||
|
FIRST_COMMENT=
|
||||||
|
|
||||||
|
if [[ "${FLAG}" == '-c' ]]; then
|
||||||
|
LICENSE_FILE=${SCRIPTPATH}/c_license_header.h
|
||||||
|
LICENSE_STRING=`awk 'BEGIN {ORS="\0"}{if($1 == "*/") {print; exit;}} {print}' ${LICENSE_FILE}`
|
||||||
|
FIRST_COMMENT=`awk 'BEGIN {ORS="\0"}{if($1 == "*/") {print; exit;}} {print}' ${FILE}`
|
||||||
|
elif [[ "${FLAG}" == '-s' ]]; then
|
||||||
|
LICENSE_FILE=${SCRIPTPATH}/sql_license.sql
|
||||||
|
LICENSE_STRING=`awk 'BEGIN {ORS="\0"}{if($1 == "") {print; exit;}} {print}' ${SCRIPTPATH}/sql_license.sql`
|
||||||
|
FIRST_COMMENT=`awk 'BEGIN {ORS="\0"}{if($1 == "") {print; exit;}} {print}' ${FILE}`
|
||||||
|
elif [[ "${FLAG}" == '-t' ]]; then
|
||||||
|
LICENSE_FILE=${SCRIPTPATH}/test_license.sql
|
||||||
|
LICENSE_STRING=`awk 'BEGIN {ORS="\0"}{if($1 == "") {print; exit;}} {print}' ${SCRIPTPATH}/test_license.sql`
|
||||||
|
FIRST_COMMENT=`awk 'BEGIN {ORS="\0"}{if($1 == "") {print; exit;}} {print}' ${FILE}`
|
||||||
|
else
|
||||||
|
echo "Unkown flag" ${1}
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${FIRST_COMMENT}" != "${LICENSE_STRING}" ]]; then
|
||||||
|
echo ${FILE#"$TIMESCALE_LOCATION/"} "lacks a license header. Add";
|
||||||
|
echo
|
||||||
|
cat ${LICENSE_FILE}
|
||||||
|
echo
|
||||||
|
echo "to the top of the file";
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0;
|
24
scripts/check_license_apache.sh
Executable file
24
scripts/check_license_apache.sh
Executable file
@ -0,0 +1,24 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
SUFFIX0=
|
||||||
|
SUFFIX1=
|
||||||
|
|
||||||
|
if [[ ${1} == '-c' ]]; then
|
||||||
|
SUFFIX0='*.c'
|
||||||
|
SUFFIX1='*.h'
|
||||||
|
else
|
||||||
|
SUFFIX0='*.sql'
|
||||||
|
SUFFIX1='*.sql'
|
||||||
|
fi
|
||||||
|
|
||||||
|
SCRIPT_DIR=$(dirname ${0})
|
||||||
|
SRC_DIR=$(dirname ${SCRIPT_DIR})
|
||||||
|
|
||||||
|
# we skip license checks for:
|
||||||
|
# - the update script fragments, because the generated update scripts will
|
||||||
|
# contain the license at top, and we don't want to repeat it in the middle
|
||||||
|
# - test/sql/dump which contains auto-generated code
|
||||||
|
# - src/chunk_adatptive since it's still in BETA
|
||||||
|
|
||||||
|
find $2 -type f \( -name "${SUFFIX0}" -or -name "${SUFFIX1}" \) -and -not -path "${SRC_DIR}/sql/updates/*.sql" -and -not -path "${SRC_DIR}/test/sql/dump/*.sql" -and -not -path "${SRC_DIR}/src/chunk_adaptive.*" -print0 | xargs -0 -n1 $(dirname ${0})/check_file_license_apache.sh ${1}
|
||||||
|
|
5
scripts/sql_license.sql
Normal file
5
scripts/sql_license.sql
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
-- Copyright (c) 2016-2018 Timescale, Inc. All Rights Reserved.
|
||||||
|
--
|
||||||
|
-- This file is licensed under the Apache License, see LICENSE-APACHE
|
||||||
|
-- at the top level directory of the timescaledb distribution.
|
||||||
|
|
5
scripts/test_license.sql
Normal file
5
scripts/test_license.sql
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
-- Copyright (c) 2016-2018 Timescale, Inc. All Rights Reserved.
|
||||||
|
--
|
||||||
|
-- This file is licensed under the Apache License,
|
||||||
|
-- see LICENSE-APACHE at the top level directory.
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user