diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cb03e6930e..85572d2040 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,6 +69,7 @@ jobs: rustup component add rustfmt - name: Run run: | + make check-license make clippy make fmt diff --git a/Makefile b/Makefile index 4e4480f54f..5038a66df2 100644 --- a/Makefile +++ b/Makefile @@ -40,6 +40,9 @@ test-ut: fmt: cd $(DIR); cargo fmt -- --check +check-license: + cd $(DIR); sh scripts/check-license.sh + clippy: cd $(DIR); cargo clippy --all-targets --all-features --workspace -- -D warnings diff --git a/analytic_engine/src/role_table/leader.rs b/analytic_engine/src/role_table/leader.rs index 3ab8778f72..8763acefc5 100644 --- a/analytic_engine/src/role_table/leader.rs +++ b/analytic_engine/src/role_table/leader.rs @@ -1,3 +1,5 @@ +// Copyright 2022 CeresDB Project Authors. Licensed under Apache-2.0. + use std::{ collections::HashMap, sync::{ diff --git a/analytic_engine/src/role_table/mod.rs b/analytic_engine/src/role_table/mod.rs index ca739d7d64..a6a9e2840c 100644 --- a/analytic_engine/src/role_table/mod.rs +++ b/analytic_engine/src/role_table/mod.rs @@ -1,3 +1,5 @@ +// Copyright 2022 CeresDB Project Authors. Licensed under Apache-2.0. + use std::{collections::HashMap, sync::Arc}; use async_trait::async_trait; diff --git a/analytic_engine/src/sst/parquet/index.rs b/analytic_engine/src/sst/parquet/index.rs index 73e76a34bc..5b8a747a48 100644 --- a/analytic_engine/src/sst/parquet/index.rs +++ b/analytic_engine/src/sst/parquet/index.rs @@ -1,3 +1,5 @@ +// Copyright 2022 CeresDB Project Authors. Licensed under Apache-2.0. + use std::collections::HashMap; use std::convert::TryFrom; use std::process::id; diff --git a/etc/license.template b/etc/license.template deleted file mode 100644 index 377ec98bed..0000000000 --- a/etc/license.template +++ /dev/null @@ -1 +0,0 @@ -// Copyright {\d+} CeresDB Project Authors. Licensed under Apache-2.0. \ No newline at end of file diff --git a/rustfmt.toml b/rustfmt.toml index 61594ccda0..c8a8c585c6 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -9,6 +9,4 @@ format_code_in_doc_comments = true # Reorder impl items. type and const are put first, then macros and methods. reorder_impl_items = true # Discard existing import groups, and create three groups for std, external crates, crates -group_imports = "StdExternalCrate" - -license_template_path = "etc/license.template" \ No newline at end of file +group_imports = "StdExternalCrate" \ No newline at end of file diff --git a/scripts/check-license.sh b/scripts/check-license.sh new file mode 100644 index 0000000000..49ed9be7a9 --- /dev/null +++ b/scripts/check-license.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +# Check all source files have a license header. +set -eu + +for i in $(git ls-files --exclude-standard | grep "\.rs"); do + # first line -> match -> print line -> quit + matches=$(sed -n "1{/Copyright [0-9]\{4\} CeresDB Project Authors. Licensed under Apache-2.0./p;};q;" $i) + if [ -z "${matches}" ]; then + echo "License header is missing from $i." + exit 1 + fi +done + +echo "License check passed." diff --git a/src/adapter.rs b/src/adapter.rs index 28ae6aa9c4..64bd7459c6 100644 --- a/src/adapter.rs +++ b/src/adapter.rs @@ -1,3 +1,5 @@ +// Copyright 2022 CeresDB Project Authors. Licensed under Apache-2.0. + use async_trait::async_trait; use catalog::{ manager::ManagerRef as CatalogManagerRef,