Skip to content
Open
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
30 changes: 30 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#
# 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.
#
- id: ccdc-copywrite-check
Comment thread
shanooni024 marked this conversation as resolved.
name: CCDC Copywrite header check
entry: main/hooks/copywrite_check.sh
language: python
pass_filenames: false
additional_dependencies:
- copywrite==1.1.3
Comment on lines +18 to +21

- id: ccdc-copywrite-fix
name: CCDC Copywrite header fix
entry: main/hooks/copywrite_fix.sh
language: python
pass_filenames: false
stages: [manual]
additional_dependencies:
- copywrite==1.1.3
26 changes: 24 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -8,10 +22,18 @@ inputs:
runs:
using: "composite"
steps:
- run: python3 $GITHUB_ACTION_PATH/main.py
- name: Install copywrite
uses: hashicorp/setup-copywrite@v1.1.3

- name: Validate Header Compliance
run: copywrite headers --config "$GITHUB_ACTION_PATH/main/copywrite/.copywrite.hcl" --plan
Comment thread
shanooni024 marked this conversation as resolved.
shell: bash
Comment thread
shanooni024 marked this conversation as resolved.

- 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'
14 changes: 14 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
34 changes: 34 additions & 0 deletions main/copywrite/.copywrite.hcl
Original file line number Diff line number Diff line change
@@ -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_HOOK_ROOT}/main/copywrite/headers/ccdc_hash.tmpl"
}

rule {
paths = ["**/*.js", "**/*.ts", "**/*.cs", "**/*.cpp", "**/*.cxx", "**/*.cc", "**/*.h", "**/*.hpp"]
license_header = "${COPYWRITE_HOOK_ROOT}/main/copywrite/headers/ccdc_slash.tmpl"
}
15 changes: 15 additions & 0 deletions main/copywrite/headers/ccdc_hash.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# START_LICENSE_TEXT
# This code is Copyright (C) {{ .Year }} The Cambridge Crystallographic Data Centre (CCDC)
Comment on lines +1 to +2
# 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
15 changes: 15 additions & 0 deletions main/copywrite/headers/ccdc_slash.tmpl
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions main/hooks/copywrite_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/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; }

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
24 changes: 24 additions & 0 deletions main/hooks/copywrite_fix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/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; }

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}"