Skip to content

Commit

Permalink
feat: improve copyright headers handling
Browse files Browse the repository at this point in the history
Signed-off-by: Tomas Dvorak <[email protected]>
  • Loading branch information
Tomas2D committed Dec 23, 2024
1 parent 9b55000 commit a6939c7
Show file tree
Hide file tree
Showing 16 changed files with 201 additions and 182 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ jobs:
cache: "yarn"
- name: Install dependencies
run: yarn install --immutable
- name: Copyright Headers
- name: Check Copyright Header
uses: actions/setup-go@v3
with:
go-version: 1.23
run: yarn copyright
run: yarn copyright:check
- name: Code Lint
run: yarn lint
- name: Code Format
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,4 @@ dist
.idea
/experiments
.npmrc
.DS_Store
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
yarn lint-staged
CI=true yarn docs:check && yarn lint && yarn format && yarn ts:check && yarn run test:unit && yarn copyright
CI=true yarn docs:check && yarn lint && yarn format && yarn ts:check && yarn run test:unit && yarn copyright:check
12 changes: 12 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import tseslint from "typescript-eslint";
import prettierConfig from "eslint-config-prettier";
import unusedImports from "eslint-plugin-unused-imports";
import markdown from "@eslint/markdown";
import stylisticJs from "@stylistic/eslint-plugin-js";

export default tseslint.config(
{
Expand Down Expand Up @@ -40,6 +41,8 @@ export default tseslint.config(
},
plugins: {
"unused-imports": unusedImports,
// @ts-expect-error wrong types
"@stylistic/js": stylisticJs,
},
rules: {
"no-console": ["error"],
Expand Down Expand Up @@ -74,6 +77,15 @@ export default tseslint.config(
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-empty-object-type": "off",
"quote-props": ["error", "consistent"],
"@stylistic/js/lines-around-comment": [
"error",
{
applyDefaultIgnorePatterns: false,
afterBlockComment: true,
beforeBlockComment: false,
ignorePattern: /^(?![\s\S]*Copyright \d+ IBM Corp.)[\s\S]+$/u.source,
},
],
},
},
{
Expand Down
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@
},
"lint-staged": {
"*.{ts,js}": "eslint --fix",
"*": ["prettier --ignore-unknown --write", "yarn copyright"],
"*": [
"prettier --ignore-unknown --write",
"yarn copyright"
],
"docs/**/*.md": "yarn docs:links"
},
"prettier": {
Expand Down Expand Up @@ -159,6 +162,7 @@
"test:examples:watch": "vitest --config ./examples/vitest.examples.config.ts watch tests/examples",
"prepare": "husky",
"copyright": "./scripts/copyright.sh",
"copyright:check": "TYPE=check ./scripts/copyright.sh",
"release": "release-it",
"ibm-vllm:generate-types": "./scripts/ibm_vllm_generate_protos/ibm_vllm_generate_protos.sh",
"_ensure_env": "cp -n .env.template .env || true"
Expand Down Expand Up @@ -288,6 +292,7 @@
"@opentelemetry/semantic-conventions": "^1.28.0",
"@release-it/conventional-changelog": "^8.0.2",
"@rollup/plugin-commonjs": "^28.0.1",
"@stylistic/eslint-plugin-js": "^2.12.1",
"@swc/core": "^1.10.0",
"@types/eslint": "^9.6.1",
"@types/eslint-config-prettier": "^6.11.3",
Expand All @@ -303,7 +308,7 @@
"docsify-cli": "^4.4.4",
"dotenv": "^16.4.7",
"embedme": "^1.22.1",
"eslint": "^9.16.0",
"eslint": "^9.17.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-unused-imports": "^4.1.4",
"glob": "^11.0.0",
Expand Down Expand Up @@ -331,7 +336,7 @@
"tsup": "^8.3.5",
"tsx": "^4.19.2",
"typescript": "^5.7.2",
"typescript-eslint": "^8.17.0",
"typescript-eslint": "^8.18.1",
"vite-tsconfig-paths": "^5.1.3",
"vitest": "^2.1.8",
"yaml": "^2.6.1"
Expand Down
3 changes: 2 additions & 1 deletion scripts/copyright.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
set -e

if [ "$#" -eq 0 ]; then
TARGETS=("src" "dist" "tests" "scripts")
TARGETS=('src/**/*.{js,ts,proto}' "dist/**/*.js" "tests/**/*.{js,ts}" "scripts/**/*.{sh,ts,js}")
else
TARGETS=("$@")
fi
Expand Down Expand Up @@ -50,6 +50,7 @@ fi
TYPE=${TYPE:-add}

if command -v nwa &> /dev/null; then
echo "Running 'nwa' version $(nwa --version)"
nwa "${TYPE}" -l apache -c "$AUTHOR" "${TARGETS[@]}"
elif command -v docker &> /dev/null; then
docker run --rm -v "${PWD}:/src" ghcr.io/b1nary-gr0up/nwa:main "${TYPE}" -l apache -c "$AUTHOR" "${TARGETS[@]}"
Expand Down
28 changes: 13 additions & 15 deletions src/adapters/ibm-vllm/proto/caikit_data_model_caikit_nlp.proto
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
/**
* Copyright 2024 IBM Corp.
*
* 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.
*/
// Copyright 2024 IBM Corp.
//
// 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.

// Source: https://github.com/IBM/vllm/blob/main/proto/caikit_data_model_caikit_nlp.proto

Expand Down
28 changes: 13 additions & 15 deletions src/adapters/ibm-vllm/proto/caikit_data_model_common.proto
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
/**
* Copyright 2024 IBM Corp.
*
* 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.
*/
// Copyright 2024 IBM Corp.
//
// 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.

// Source: https://github.com/IBM/vllm/blob/main/proto/caikit_data_model_common.proto

Expand Down
28 changes: 13 additions & 15 deletions src/adapters/ibm-vllm/proto/caikit_data_model_nlp.proto
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
/**
* Copyright 2024 IBM Corp.
*
* 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.
*/
// Copyright 2024 IBM Corp.
//
// 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.

// Source: https://github.com/IBM/vllm/blob/main/proto/caikit_data_model_nlp.proto

Expand Down
28 changes: 13 additions & 15 deletions src/adapters/ibm-vllm/proto/caikit_data_model_runtime.proto
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
/**
* Copyright 2024 IBM Corp.
*
* 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.
*/
// Copyright 2024 IBM Corp.
//
// 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.

// Source: https://github.com/IBM/vllm/blob/main/proto/caikit_data_model_runtime.proto

Expand Down
28 changes: 13 additions & 15 deletions src/adapters/ibm-vllm/proto/caikit_runtime_Nlp.proto
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
/**
* Copyright 2024 IBM Corp.
*
* 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.
*/
// Copyright 2024 IBM Corp.
//
// 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.

// Source: https://github.com/IBM/vllm/blob/main/proto/caikit_runtime_Nlp.proto

Expand Down
28 changes: 13 additions & 15 deletions src/adapters/ibm-vllm/proto/generation.proto
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
/**
* Copyright 2024 IBM Corp.
*
* 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.
*/
// Copyright 2024 IBM Corp.
//
// 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.

// Source: https://github.com/IBM/vllm/blob/main/proto/generation.proto

Expand Down
1 change: 1 addition & 0 deletions src/agents/bee/runners/default/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { BaseRunner, BeeRunnerLLMInput, BeeRunnerToolInput } from "@/agents/bee/runners/base.js";
import type {
BeeAgentRunIteration,
Expand Down
1 change: 1 addition & 0 deletions src/agents/bee/runners/granite/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { BaseMessage, Role } from "@/llms/primitives/message.js";
import type { AnyTool } from "@/tools/base.js";
import { isEmpty } from "remeda";
Expand Down
1 change: 1 addition & 0 deletions src/agents/parsers/linePrefix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { Emitter } from "@/emitter/emitter.js";
import { entries } from "remeda";
import { ValueError } from "@/errors.js";
Expand Down
Loading

0 comments on commit a6939c7

Please sign in to comment.