From de1adcf3fadc787cee65a45b45ea0451256cb47a Mon Sep 17 00:00:00 2001 From: Shanoon Issaka Date: Mon, 24 Aug 2026 12:25:23 +0100 Subject: [PATCH 1/6] fix(PLA-3414): copyrigth text check --- .pre-commit-hook.yaml | 12 +++++++++ action.yml | 17 +++++++++++-- main/copywrite/.copywrite.hcl | 34 ++++++++++++++++++++++++++ main/copywrite/headers/ccdc_hash.tmpl | 15 ++++++++++++ main/copywrite/headers/ccdc_slash.tmpl | 15 ++++++++++++ main/hooks/copywrite_check.sh | 4 +++ main/hooks/copywrite_fix.sh | 4 +++ 7 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 .pre-commit-hook.yaml create mode 100644 main/copywrite/.copywrite.hcl create mode 100644 main/copywrite/headers/ccdc_hash.tmpl create mode 100644 main/copywrite/headers/ccdc_slash.tmpl create mode 100644 main/hooks/copywrite_check.sh create mode 100644 main/hooks/copywrite_fix.sh diff --git a/.pre-commit-hook.yaml b/.pre-commit-hook.yaml new file mode 100644 index 0000000..d75c2a6 --- /dev/null +++ b/.pre-commit-hook.yaml @@ -0,0 +1,12 @@ +- id: ccdc-copywrite-check + name: CCDC Copywrite header check + entry: hooks/copywrite_check.sh + language: script + pass_filenames: false + +- id: ccdc-copywrite-fix + name: CCDC Copywrite header fix + entry: hooks/copywrite_fix.sh + language: script + pass_filenames: false + stages: [manual] \ No newline at end of file diff --git a/action.yml b/action.yml index 3d7bbd1..a8c4df7 100644 --- a/action.yml +++ b/action.yml @@ -8,10 +8,23 @@ inputs: runs: using: "composite" steps: - - run: python3 $GITHUB_ACTION_PATH/main.py + - name: Checkout Repo + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install copywrite + uses: hashicorp/setup-copywrite@v1.1.2 + + - name: Validate Header Compliance + run: copywrite headers --plan + shell: bash + + - name: Run file compliance check + run: python3 $GITHUB_ACTION_PATH/main.py shell: bash env: INPUT_COMMITMESSAGE: ${{ inputs.commitMessage }} branding: icon: 'check-square' - color: 'green' + color: 'green' \ No newline at end of file diff --git a/main/copywrite/.copywrite.hcl b/main/copywrite/.copywrite.hcl new file mode 100644 index 0000000..a8af818 --- /dev/null +++ b/main/copywrite/.copywrite.hcl @@ -0,0 +1,34 @@ +schema_version = "1" + +project { + copyright_holder = "The Cambridge Crystallographic Data Centre (CCDC)" + + header_ignore = [ + ".git/**", + ".github/**", + "**/bin/**", + "**/obj/**", + "**/packages/**", + "**/node_modules/**", + "**/dist/**", + "**/build/**", + "**/.venv/**", + "**/venv/**", + "**/__pycache__/**", + "**/*.Designer.cs", + "**/*.g.cs", + "**/*.generated.*", + "**/*.min.js", + "**/*.lock", + ] +} + +rule { + paths = ["**/*.py", "**/*.sh", "**/*.bash", "**/*.yaml", "**/*.yml"] + license_header = "copywrite/headers/ccdc_hash.tmpl" +} + +rule { + paths = ["**/*.js", "**/*.ts", "**/*.cs", "**/*.cpp", "**/*.cxx", "**/*.cc", "**/*.h", "**/*.hpp"] + license_header = "copywrite/headers/ccdc_slash.tmpl" +} \ No newline at end of file diff --git a/main/copywrite/headers/ccdc_hash.tmpl b/main/copywrite/headers/ccdc_hash.tmpl new file mode 100644 index 0000000..b30619e --- /dev/null +++ b/main/copywrite/headers/ccdc_hash.tmpl @@ -0,0 +1,15 @@ +# START_LICENSE_TEXT +# This code is Copyright (C) {{ .Year }} The Cambridge Crystallographic Data Centre (CCDC) +# of 12 Union Road, Cambridge CB2 1EZ, UK and a proprietary work of CCDC. This +# code may not be used, reproduced, translated, modified, disassembled or +# copied, except in accordance with a valid licence agreement with CCDC and +# may NOT be disclosed or redistributed in any form, either in whole or in +# part, to any third party. All copies of this code made in accordance with a +# valid licence agreement as referred to above must contain this copyright +# notice. +# +# No representations, warranties, or liabilities are expressed or implied in +# the supply of this code by CCDC, its servants or agents, except where such +# exclusion or limitation is prohibited, void or unenforceable under governing +# law. +# END_LICENSE_TEXT diff --git a/main/copywrite/headers/ccdc_slash.tmpl b/main/copywrite/headers/ccdc_slash.tmpl new file mode 100644 index 0000000..3671665 --- /dev/null +++ b/main/copywrite/headers/ccdc_slash.tmpl @@ -0,0 +1,15 @@ +// START_LICENSE_TEXT +// This code is Copyright (C) {{ .Year }} The Cambridge Crystallographic Data Centre (CCDC) +// of 12 Union Road, Cambridge CB2 1EZ, UK and a proprietary work of CCDC. This +// code may not be used, reproduced, translated, modified, disassembled or +// copied, except in accordance with a valid licence agreement with CCDC and +// may NOT be disclosed or redistributed in any form, either in whole or in +// part, to any third party. All copies of this code made in accordance with a +// valid licence agreement as referred to above must contain this copyright +// notice. +// +// No representations, warranties, or liabilities are expressed or implied in +// the supply of this code by CCDC, its servants or agents, except where such +// exclusion or limitation is prohibited, void or unenforceable under governing +// law. +// END_LICENSE_TEXT diff --git a/main/hooks/copywrite_check.sh b/main/hooks/copywrite_check.sh new file mode 100644 index 0000000..2136d54 --- /dev/null +++ b/main/hooks/copywrite_check.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -euo pipefail +command -v copywrite >/dev/null 2>&1 || { echo "copywrite not found on PATH"; exit 1; } +copywrite headers --config=.copywrite.hcl --plan \ No newline at end of file diff --git a/main/hooks/copywrite_fix.sh b/main/hooks/copywrite_fix.sh new file mode 100644 index 0000000..9e7e767 --- /dev/null +++ b/main/hooks/copywrite_fix.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -euo pipefail +command -v copywrite >/dev/null 2>&1 || { echo "copywrite not found on PATH"; exit 1; } +copywrite headers --config=.copywrite.hcl \ No newline at end of file From e2c6d35ba3c780ca7b0ee438322605da15a29dce Mon Sep 17 00:00:00 2001 From: Shanoon Issaka Date: Tue, 25 Aug 2026 08:59:40 +0100 Subject: [PATCH 2/6] fix(PLA-3414): copyright text action comments resolving --- .pre-commit-hook.yaml => .pre-commit-hooks.yaml | 4 ++-- action.yml | 9 ++------- main/copywrite/.copywrite.hcl | 6 +++--- main/hooks/copywrite_check.sh | 2 +- main/hooks/copywrite_fix.sh | 2 +- 5 files changed, 9 insertions(+), 14 deletions(-) rename .pre-commit-hook.yaml => .pre-commit-hooks.yaml (74%) diff --git a/.pre-commit-hook.yaml b/.pre-commit-hooks.yaml similarity index 74% rename from .pre-commit-hook.yaml rename to .pre-commit-hooks.yaml index d75c2a6..4bd20e4 100644 --- a/.pre-commit-hook.yaml +++ b/.pre-commit-hooks.yaml @@ -1,12 +1,12 @@ - id: ccdc-copywrite-check name: CCDC Copywrite header check - entry: hooks/copywrite_check.sh + entry: main/hooks/copywrite_check.sh language: script pass_filenames: false - id: ccdc-copywrite-fix name: CCDC Copywrite header fix - entry: hooks/copywrite_fix.sh + entry: main/hooks/copywrite_fix.sh language: script pass_filenames: false stages: [manual] \ No newline at end of file diff --git a/action.yml b/action.yml index a8c4df7..92596de 100644 --- a/action.yml +++ b/action.yml @@ -8,16 +8,11 @@ inputs: runs: using: "composite" steps: - - name: Checkout Repo - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Install copywrite - uses: hashicorp/setup-copywrite@v1.1.2 + uses: hashicorp/setup-copywrite@v1.1.3 - name: Validate Header Compliance - run: copywrite headers --plan + run: copywrite headers --config "$GITHUB_ACTION_PATH/main/copywrite/.copywrite.hcl" --plan shell: bash - name: Run file compliance check diff --git a/main/copywrite/.copywrite.hcl b/main/copywrite/.copywrite.hcl index a8af818..7948f39 100644 --- a/main/copywrite/.copywrite.hcl +++ b/main/copywrite/.copywrite.hcl @@ -1,4 +1,4 @@ -schema_version = "1" +schema_version = 1 project { copyright_holder = "The Cambridge Crystallographic Data Centre (CCDC)" @@ -25,10 +25,10 @@ project { rule { paths = ["**/*.py", "**/*.sh", "**/*.bash", "**/*.yaml", "**/*.yml"] - license_header = "copywrite/headers/ccdc_hash.tmpl" + license_header = "main/copywrite/headers/ccdc_hash.tmpl" } rule { paths = ["**/*.js", "**/*.ts", "**/*.cs", "**/*.cpp", "**/*.cxx", "**/*.cc", "**/*.h", "**/*.hpp"] - license_header = "copywrite/headers/ccdc_slash.tmpl" + license_header = "main/copywrite/headers/ccdc_slash.tmpl" } \ No newline at end of file diff --git a/main/hooks/copywrite_check.sh b/main/hooks/copywrite_check.sh index 2136d54..1ceb6e0 100644 --- a/main/hooks/copywrite_check.sh +++ b/main/hooks/copywrite_check.sh @@ -1,4 +1,4 @@ #!/usr/bin/env bash set -euo pipefail command -v copywrite >/dev/null 2>&1 || { echo "copywrite not found on PATH"; exit 1; } -copywrite headers --config=.copywrite.hcl --plan \ No newline at end of file +copywrite headers --config=main/copywrite/.copywrite.hcl --plan \ No newline at end of file diff --git a/main/hooks/copywrite_fix.sh b/main/hooks/copywrite_fix.sh index 9e7e767..b40da1d 100644 --- a/main/hooks/copywrite_fix.sh +++ b/main/hooks/copywrite_fix.sh @@ -1,4 +1,4 @@ #!/usr/bin/env bash set -euo pipefail command -v copywrite >/dev/null 2>&1 || { echo "copywrite not found on PATH"; exit 1; } -copywrite headers --config=.copywrite.hcl \ No newline at end of file +copywrite headers --config=main/copywrite/.copywrite.hcl \ No newline at end of file From 809d49834ac8af53df61cee5fe078eb8a4c33de2 Mon Sep 17 00:00:00 2001 From: Shanoon Issaka Date: Tue, 25 Aug 2026 09:15:25 +0100 Subject: [PATCH 3/6] fix(PLA-3414): update directory --- main/hooks/copywrite_check.sh | 2 +- main/hooks/copywrite_fix.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/main/hooks/copywrite_check.sh b/main/hooks/copywrite_check.sh index 1ceb6e0..2ed3d79 100644 --- a/main/hooks/copywrite_check.sh +++ b/main/hooks/copywrite_check.sh @@ -1,4 +1,4 @@ #!/usr/bin/env bash set -euo pipefail command -v copywrite >/dev/null 2>&1 || { echo "copywrite not found on PATH"; exit 1; } -copywrite headers --config=main/copywrite/.copywrite.hcl --plan \ No newline at end of file +copywrite headers --config="$(dirname "${BASH_SOURCE[0]}")/main/copywrite/.copywrite.hcl" --plan \ No newline at end of file diff --git a/main/hooks/copywrite_fix.sh b/main/hooks/copywrite_fix.sh index b40da1d..0f44c2f 100644 --- a/main/hooks/copywrite_fix.sh +++ b/main/hooks/copywrite_fix.sh @@ -1,4 +1,4 @@ #!/usr/bin/env bash set -euo pipefail command -v copywrite >/dev/null 2>&1 || { echo "copywrite not found on PATH"; exit 1; } -copywrite headers --config=main/copywrite/.copywrite.hcl \ No newline at end of file +copywrite headers --config="$(dirname "${BASH_SOURCE[0]}")/main/copywrite/.copywrite.hcl" \ No newline at end of file From f8eacd6ffcd1560dc6d3ae6eb48f83da513ffae2 Mon Sep 17 00:00:00 2001 From: Shanoon Issaka Date: Tue, 25 Aug 2026 10:13:41 +0100 Subject: [PATCH 4/6] fix(PLA-3414): updarte directory path --- main/copywrite/.copywrite.hcl | 4 ++-- main/hooks/copywrite_check.sh | 8 +++++++- main/hooks/copywrite_fix.sh | 8 +++++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/main/copywrite/.copywrite.hcl b/main/copywrite/.copywrite.hcl index 7948f39..8ecea19 100644 --- a/main/copywrite/.copywrite.hcl +++ b/main/copywrite/.copywrite.hcl @@ -25,10 +25,10 @@ project { rule { paths = ["**/*.py", "**/*.sh", "**/*.bash", "**/*.yaml", "**/*.yml"] - license_header = "main/copywrite/headers/ccdc_hash.tmpl" + license_header = "${COPYWRITE_HOOK_ROOT}/main/copywrite/headers/ccdc_hash.tmpl" } rule { paths = ["**/*.js", "**/*.ts", "**/*.cs", "**/*.cpp", "**/*.cxx", "**/*.cc", "**/*.h", "**/*.hpp"] - license_header = "main/copywrite/headers/ccdc_slash.tmpl" + license_header = "${COPYWRITE_HOOK_ROOT}/main/copywrite/headers/ccdc_slash.tmpl" } \ No newline at end of file diff --git a/main/hooks/copywrite_check.sh b/main/hooks/copywrite_check.sh index 2ed3d79..e6a8e58 100644 --- a/main/hooks/copywrite_check.sh +++ b/main/hooks/copywrite_check.sh @@ -1,4 +1,10 @@ #!/usr/bin/env bash set -euo pipefail command -v copywrite >/dev/null 2>&1 || { echo "copywrite not found on PATH"; exit 1; } -copywrite headers --config="$(dirname "${BASH_SOURCE[0]}")/main/copywrite/.copywrite.hcl" --plan \ No newline at end of file + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +HOOK_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)" +CONFIG_PATH="${HOOK_ROOT}/main/copywrite/.copywrite.hcl" + +export COPYWRITE_HOOK_ROOT="${HOOK_ROOT}" +copywrite headers --config="${CONFIG_PATH}" --plan \ No newline at end of file diff --git a/main/hooks/copywrite_fix.sh b/main/hooks/copywrite_fix.sh index 0f44c2f..2ab92c1 100644 --- a/main/hooks/copywrite_fix.sh +++ b/main/hooks/copywrite_fix.sh @@ -1,4 +1,10 @@ #!/usr/bin/env bash set -euo pipefail command -v copywrite >/dev/null 2>&1 || { echo "copywrite not found on PATH"; exit 1; } -copywrite headers --config="$(dirname "${BASH_SOURCE[0]}")/main/copywrite/.copywrite.hcl" \ No newline at end of file + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +HOOK_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)" +CONFIG_PATH="${HOOK_ROOT}/main/copywrite/.copywrite.hcl" + +export COPYWRITE_HOOK_ROOT="${HOOK_ROOT}" +copywrite headers --config="${CONFIG_PATH}" From 96735d84c695d1af8f1d2c9e7b2d4fe7f46a071f Mon Sep 17 00:00:00 2001 From: Shanoon Issaka Date: Tue, 25 Aug 2026 10:33:14 +0100 Subject: [PATCH 5/6] Fix(PLA-3414): language switched to python --- .pre-commit-hooks.yaml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 4bd20e4..16edbc3 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -1,12 +1,16 @@ - id: ccdc-copywrite-check name: CCDC Copywrite header check entry: main/hooks/copywrite_check.sh - language: script + language: python pass_filenames: false + additional_dependencies: + - copywrite==1.1.3 - id: ccdc-copywrite-fix name: CCDC Copywrite header fix entry: main/hooks/copywrite_fix.sh - language: script + language: python pass_filenames: false - stages: [manual] \ No newline at end of file + stages: [manual] + additional_dependencies: + - copywrite==1.1.3 \ No newline at end of file From 6b52fc69fa7497bdcd2acd01cad44c7dd47f62d1 Mon Sep 17 00:00:00 2001 From: Shanoon Issaka Date: Tue, 25 Aug 2026 10:49:28 +0100 Subject: [PATCH 6/6] fix(PLA-3414): copyright text action comments resolving --- .pre-commit-hooks.yaml | 14 ++++++++++++++ action.yml | 14 ++++++++++++++ main.py | 14 ++++++++++++++ main/hooks/copywrite_check.sh | 14 ++++++++++++++ main/hooks/copywrite_fix.sh | 14 ++++++++++++++ 5 files changed, 70 insertions(+) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 16edbc3..4264680 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -1,3 +1,17 @@ +# +# This code is Copyright (C) The Cambridge Crystallographic Data Centre +# (CCDC) of 12 Union Road, Cambridge CB2 1EZ, UK and a proprietary work of CCDC. +# This code may not be used, reproduced, translated, modified, disassembled or +# copied, except in accordance with a valid licence agreement with CCDC and may +# not be disclosed or redistributed in any form, either in whole or in part, to +# any third party. All copies of this code made in accordance with a valid +# licence agreement as referred to above must contain this copyright notice. +# +# No representations, warranties, or liabilities are expressed or implied in the +# supply of this code by CCDC, its servants or agents, except where such +# exclusion or limitation is prohibited, void or unenforceable under governing +# law. +# - id: ccdc-copywrite-check name: CCDC Copywrite header check entry: main/hooks/copywrite_check.sh diff --git a/action.yml b/action.yml index 92596de..3014725 100644 --- a/action.yml +++ b/action.yml @@ -1,3 +1,17 @@ +# +# This code is Copyright (C) 2026 The Cambridge Crystallographic Data Centre +# (CCDC) of 12 Union Road, Cambridge CB2 1EZ, UK and a proprietary work of CCDC. +# This code may not be used, reproduced, translated, modified, disassembled or +# copied, except in accordance with a valid licence agreement with CCDC and may +# not be disclosed or redistributed in any form, either in whole or in part, to +# any third party. All copies of this code made in accordance with a valid +# licence agreement as referred to above must contain this copyright notice. +# +# No representations, warranties, or liabilities are expressed or implied in the +# supply of this code by CCDC, its servants or agents, except where such +# exclusion or limitation is prohibited, void or unenforceable under governing +# law. +# name: CCDC File Checks author: CCDC description: Check changed files for compliance diff --git a/main.py b/main.py index ba28722..e7791db 100755 --- a/main.py +++ b/main.py @@ -1,4 +1,18 @@ #!/usr/bin/env python3 +# +# This code is Copyright (C) 2026 The Cambridge Crystallographic Data Centre +# (CCDC) of 12 Union Road, Cambridge CB2 1EZ, UK and a proprietary work of CCDC. +# This code may not be used, reproduced, translated, modified, disassembled or +# copied, except in accordance with a valid licence agreement with CCDC and may +# not be disclosed or redistributed in any form, either in whole or in part, to +# any third party. All copies of this code made in accordance with a valid +# licence agreement as referred to above must contain this copyright notice. +# +# No representations, warranties, or liabilities are expressed or implied in the +# supply of this code by CCDC, its servants or agents, except where such +# exclusion or limitation is prohibited, void or unenforceable under governing +# law. +# ''' This is a github action entry point. diff --git a/main/hooks/copywrite_check.sh b/main/hooks/copywrite_check.sh index e6a8e58..15389bf 100644 --- a/main/hooks/copywrite_check.sh +++ b/main/hooks/copywrite_check.sh @@ -1,4 +1,18 @@ #!/usr/bin/env bash +# +# This code is Copyright (C) 2026 The Cambridge Crystallographic Data Centre +# (CCDC) of 12 Union Road, Cambridge CB2 1EZ, UK and a proprietary work of CCDC. +# This code may not be used, reproduced, translated, modified, disassembled or +# copied, except in accordance with a valid licence agreement with CCDC and may +# not be disclosed or redistributed in any form, either in whole or in part, to +# any third party. All copies of this code made in accordance with a valid +# licence agreement as referred to above must contain this copyright notice. +# +# No representations, warranties, or liabilities are expressed or implied in the +# supply of this code by CCDC, its servants or agents, except where such +# exclusion or limitation is prohibited, void or unenforceable under governing +# law. +# set -euo pipefail command -v copywrite >/dev/null 2>&1 || { echo "copywrite not found on PATH"; exit 1; } diff --git a/main/hooks/copywrite_fix.sh b/main/hooks/copywrite_fix.sh index 2ab92c1..6a76d81 100644 --- a/main/hooks/copywrite_fix.sh +++ b/main/hooks/copywrite_fix.sh @@ -1,4 +1,18 @@ #!/usr/bin/env bash +# +# This code is Copyright (C) 2026 The Cambridge Crystallographic Data Centre +# (CCDC) of 12 Union Road, Cambridge CB2 1EZ, UK and a proprietary work of CCDC. +# This code may not be used, reproduced, translated, modified, disassembled or +# copied, except in accordance with a valid licence agreement with CCDC and may +# not be disclosed or redistributed in any form, either in whole or in part, to +# any third party. All copies of this code made in accordance with a valid +# licence agreement as referred to above must contain this copyright notice. +# +# No representations, warranties, or liabilities are expressed or implied in the +# supply of this code by CCDC, its servants or agents, except where such +# exclusion or limitation is prohibited, void or unenforceable under governing +# law. +# set -euo pipefail command -v copywrite >/dev/null 2>&1 || { echo "copywrite not found on PATH"; exit 1; }