diff --git a/depsBundle.py b/depsBundle.py index 892003c6..eab4493b 100644 --- a/depsBundle.py +++ b/depsBundle.py @@ -1,3 +1,5 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + from __future__ import annotations import re diff --git a/depsBundle.sh b/depsBundle.sh index 7b861ce8..3b94b990 100755 --- a/depsBundle.sh +++ b/depsBundle.sh @@ -1,4 +1,6 @@ #!/bin/bash +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + # This script is called in a shell subprocess. # If editing this script, please see the security considerations diff --git a/install_builder/deadline-cloud-for-nuke.xml b/install_builder/deadline-cloud-for-nuke.xml index b9889efa..653f77fe 100644 --- a/install_builder/deadline-cloud-for-nuke.xml +++ b/install_builder/deadline-cloud-for-nuke.xml @@ -1,3 +1,5 @@ + + deadline_cloud_for_nuke Deadline Cloud for Nuke 14.0-15.0 diff --git a/installer/DeadlineCloudForNuke.xml b/installer/DeadlineCloudForNuke.xml index e5e64b00..2dc3c56a 100644 --- a/installer/DeadlineCloudForNuke.xml +++ b/installer/DeadlineCloudForNuke.xml @@ -1,3 +1,5 @@ + + DeadlineCloudForNukeSubmitter AWS Deadline Cloud for Nuke Submitter diff --git a/job_bundle_output_tests/cwd-path/expected_job_bundle/asset_references.yaml b/job_bundle_output_tests/cwd-path/expected_job_bundle/asset_references.yaml index d42d3498..f444cca7 100644 --- a/job_bundle_output_tests/cwd-path/expected_job_bundle/asset_references.yaml +++ b/job_bundle_output_tests/cwd-path/expected_job_bundle/asset_references.yaml @@ -1,3 +1,5 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + assetReferences: inputs: directories: [] diff --git a/job_bundle_output_tests/cwd-path/expected_job_bundle/parameter_values.yaml b/job_bundle_output_tests/cwd-path/expected_job_bundle/parameter_values.yaml index c3719633..eee7e000 100644 --- a/job_bundle_output_tests/cwd-path/expected_job_bundle/parameter_values.yaml +++ b/job_bundle_output_tests/cwd-path/expected_job_bundle/parameter_values.yaml @@ -1,3 +1,5 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + parameterValues: - name: Frames value: 1-100 diff --git a/job_bundle_output_tests/cwd-path/expected_job_bundle/template.yaml b/job_bundle_output_tests/cwd-path/expected_job_bundle/template.yaml index af479423..999a110a 100644 --- a/job_bundle_output_tests/cwd-path/expected_job_bundle/template.yaml +++ b/job_bundle_output_tests/cwd-path/expected_job_bundle/template.yaml @@ -1,3 +1,5 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + specificationVersion: jobtemplate-2023-09 name: cwd-path.nk parameterDefinitions: @@ -125,4 +127,4 @@ steps: - file://{{ Task.File.runData }} cancelation: mode: NOTIFY_THEN_TERMINATE - timeout: 518400 \ No newline at end of file + timeout: 518400 diff --git a/job_bundle_output_tests/frame/expected_job_bundle/asset_references.yaml b/job_bundle_output_tests/frame/expected_job_bundle/asset_references.yaml index c0e20340..1b947b9a 100644 --- a/job_bundle_output_tests/frame/expected_job_bundle/asset_references.yaml +++ b/job_bundle_output_tests/frame/expected_job_bundle/asset_references.yaml @@ -1,3 +1,5 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + assetReferences: inputs: directories: [] diff --git a/job_bundle_output_tests/frame/expected_job_bundle/parameter_values.yaml b/job_bundle_output_tests/frame/expected_job_bundle/parameter_values.yaml index e4c95606..76a05649 100644 --- a/job_bundle_output_tests/frame/expected_job_bundle/parameter_values.yaml +++ b/job_bundle_output_tests/frame/expected_job_bundle/parameter_values.yaml @@ -1,3 +1,5 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + parameterValues: - name: Frames value: 3-7 diff --git a/job_bundle_output_tests/frame/expected_job_bundle/template.yaml b/job_bundle_output_tests/frame/expected_job_bundle/template.yaml index 0976b790..c59d8f49 100644 --- a/job_bundle_output_tests/frame/expected_job_bundle/template.yaml +++ b/job_bundle_output_tests/frame/expected_job_bundle/template.yaml @@ -1,3 +1,5 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + specificationVersion: jobtemplate-2023-09 name: frame.nk parameterDefinitions: diff --git a/job_bundle_output_tests/group-read/expected_job_bundle/asset_references.yaml b/job_bundle_output_tests/group-read/expected_job_bundle/asset_references.yaml index 08ec58e7..3a1020d4 100644 --- a/job_bundle_output_tests/group-read/expected_job_bundle/asset_references.yaml +++ b/job_bundle_output_tests/group-read/expected_job_bundle/asset_references.yaml @@ -1,3 +1,5 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + assetReferences: inputs: directories: [] diff --git a/job_bundle_output_tests/group-read/expected_job_bundle/parameter_values.yaml b/job_bundle_output_tests/group-read/expected_job_bundle/parameter_values.yaml index fbb6c1ea..60880e50 100644 --- a/job_bundle_output_tests/group-read/expected_job_bundle/parameter_values.yaml +++ b/job_bundle_output_tests/group-read/expected_job_bundle/parameter_values.yaml @@ -1,3 +1,5 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + parameterValues: - name: Frames value: 1-100 diff --git a/job_bundle_output_tests/group-read/expected_job_bundle/template.yaml b/job_bundle_output_tests/group-read/expected_job_bundle/template.yaml index 4da29da5..ac055591 100644 --- a/job_bundle_output_tests/group-read/expected_job_bundle/template.yaml +++ b/job_bundle_output_tests/group-read/expected_job_bundle/template.yaml @@ -1,3 +1,5 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + specificationVersion: jobtemplate-2023-09 name: group-read.nk parameterDefinitions: diff --git a/job_bundle_output_tests/multi-load-save/expected_job_bundle/asset_references.yaml b/job_bundle_output_tests/multi-load-save/expected_job_bundle/asset_references.yaml index f64a92c4..20c840ca 100644 --- a/job_bundle_output_tests/multi-load-save/expected_job_bundle/asset_references.yaml +++ b/job_bundle_output_tests/multi-load-save/expected_job_bundle/asset_references.yaml @@ -1,3 +1,5 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + assetReferences: inputs: directories: [] diff --git a/job_bundle_output_tests/multi-load-save/expected_job_bundle/parameter_values.yaml b/job_bundle_output_tests/multi-load-save/expected_job_bundle/parameter_values.yaml index 474d32fc..2d52289a 100644 --- a/job_bundle_output_tests/multi-load-save/expected_job_bundle/parameter_values.yaml +++ b/job_bundle_output_tests/multi-load-save/expected_job_bundle/parameter_values.yaml @@ -1,3 +1,5 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + parameterValues: - name: Frames value: 1-100 diff --git a/job_bundle_output_tests/multi-load-save/expected_job_bundle/template.yaml b/job_bundle_output_tests/multi-load-save/expected_job_bundle/template.yaml index ea685e13..cabf3398 100644 --- a/job_bundle_output_tests/multi-load-save/expected_job_bundle/template.yaml +++ b/job_bundle_output_tests/multi-load-save/expected_job_bundle/template.yaml @@ -1,3 +1,5 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + specificationVersion: jobtemplate-2023-09 name: multi-load-save.nk parameterDefinitions: diff --git a/job_bundle_output_tests/noise-saver/expected_job_bundle/asset_references.yaml b/job_bundle_output_tests/noise-saver/expected_job_bundle/asset_references.yaml index 1bd38318..eb0c8aab 100644 --- a/job_bundle_output_tests/noise-saver/expected_job_bundle/asset_references.yaml +++ b/job_bundle_output_tests/noise-saver/expected_job_bundle/asset_references.yaml @@ -1,3 +1,5 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + assetReferences: inputs: directories: [] diff --git a/job_bundle_output_tests/noise-saver/expected_job_bundle/parameter_values.yaml b/job_bundle_output_tests/noise-saver/expected_job_bundle/parameter_values.yaml index 6484d6b5..b0fdaa47 100644 --- a/job_bundle_output_tests/noise-saver/expected_job_bundle/parameter_values.yaml +++ b/job_bundle_output_tests/noise-saver/expected_job_bundle/parameter_values.yaml @@ -1,3 +1,5 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + parameterValues: - name: Frames value: 1-100 diff --git a/job_bundle_output_tests/noise-saver/expected_job_bundle/template.yaml b/job_bundle_output_tests/noise-saver/expected_job_bundle/template.yaml index 807e48a0..1427451a 100644 --- a/job_bundle_output_tests/noise-saver/expected_job_bundle/template.yaml +++ b/job_bundle_output_tests/noise-saver/expected_job_bundle/template.yaml @@ -1,3 +1,5 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + specificationVersion: jobtemplate-2023-09 name: noise-saver.nk parameterDefinitions: diff --git a/job_bundle_output_tests/ocio/expected_job_bundle/asset_references.yaml b/job_bundle_output_tests/ocio/expected_job_bundle/asset_references.yaml index 0bc20a18..9e4314bd 100644 --- a/job_bundle_output_tests/ocio/expected_job_bundle/asset_references.yaml +++ b/job_bundle_output_tests/ocio/expected_job_bundle/asset_references.yaml @@ -1,3 +1,5 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + assetReferences: inputs: directories: diff --git a/job_bundle_output_tests/ocio/expected_job_bundle/parameter_values.yaml b/job_bundle_output_tests/ocio/expected_job_bundle/parameter_values.yaml index c77f9057..a86f5d8c 100644 --- a/job_bundle_output_tests/ocio/expected_job_bundle/parameter_values.yaml +++ b/job_bundle_output_tests/ocio/expected_job_bundle/parameter_values.yaml @@ -1,3 +1,5 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + parameterValues: - name: Frames value: 1-100 diff --git a/job_bundle_output_tests/ocio/expected_job_bundle/template.yaml b/job_bundle_output_tests/ocio/expected_job_bundle/template.yaml index 748bfdb0..eda52f0d 100644 --- a/job_bundle_output_tests/ocio/expected_job_bundle/template.yaml +++ b/job_bundle_output_tests/ocio/expected_job_bundle/template.yaml @@ -1,3 +1,5 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + specificationVersion: jobtemplate-2023-09 name: ocio.nk parameterDefinitions: diff --git a/pipeline/build.sh b/pipeline/build.sh index c886ee1d..a2b1a2e0 100755 --- a/pipeline/build.sh +++ b/pipeline/build.sh @@ -1,4 +1,6 @@ #!/bin/sh +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + # Set the -e option set -e @@ -7,4 +9,4 @@ pip install --upgrade hatch pip install --upgrade twine hatch -v run codebuild:lint hatch run codebuild:test -hatch -v run codebuild:build \ No newline at end of file +hatch -v run codebuild:build diff --git a/pipeline/e2e.sh b/pipeline/e2e.sh index f026fe3d..47aca522 100755 --- a/pipeline/e2e.sh +++ b/pipeline/e2e.sh @@ -1,7 +1,9 @@ #!/bin/sh +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + # Set the -e option set -e pip install --upgrade pip pip install --upgrade hatch -hatch run e2e:test \ No newline at end of file +hatch run e2e:test diff --git a/pipeline/integ.sh b/pipeline/integ.sh index 232a6f01..8712da5e 100755 --- a/pipeline/integ.sh +++ b/pipeline/integ.sh @@ -1,7 +1,9 @@ #!/bin/sh +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + # Set the -e option set -e pip install --upgrade pip pip install --upgrade hatch -hatch run integ:test \ No newline at end of file +hatch run integ:test diff --git a/pipeline/publish.sh b/pipeline/publish.sh index 9e9c1b5b..fce9d037 100755 --- a/pipeline/publish.sh +++ b/pipeline/publish.sh @@ -1,6 +1,8 @@ #!/bin/sh +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + # Set the -e option set -e ./pipeline/build.sh -twine upload --repository codeartifact dist/* --verbose \ No newline at end of file +twine upload --repository codeartifact dist/* --verbose diff --git a/scripts/add_copyright_headers.sh b/scripts/add_copyright_headers.sh index 63297f8e..ed466c62 100755 --- a/scripts/add_copyright_headers.sh +++ b/scripts/add_copyright_headers.sh @@ -1,15 +1,10 @@ #!/bin/bash # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +set -euxo pipefail -set -euo pipefail - -if [ $# -eq 0 ]; then - echo "Usage: add-copyright-headers ..." >&2 - exit 1 -fi - -for file in "$@"; do - if ! head -1 | grep 'Copyright ' "$file" >/dev/null; then +process_file() { + local file="$1" + if ! head -2 "$file" | grep 'Copyright ' > /dev/null; then case $file in *.java) CONTENT=$(cat "$file") @@ -18,60 +13,110 @@ for file in "$@"; do $CONTENT EOF - ;; + ;; + *.py) + if head -1 "$file" | grep -q '^#!'; then + # If file has shebang, preserve it + SHEBANG=$(head -1 "$file") + CONTENT=$(tail -n +2 "$file") + cat > "$file" < "$file" < "$file" </dev/null; then + if head -1 "$file" | grep -q ' "$file" < + $CONTENT EOF else CONTENT=$(cat "$file") cat > "$file" < + $CONTENT EOF fi - ;; - *.py) + ;; + *.ps1) CONTENT=$(cat "$file") cat > "$file" < "$file" < "$file" < "$file" < "$file" < "$file" <&2 - exit 1 - ;; + ;; esac fi -done \ No newline at end of file +} + +# If no arguments provided, process tracked files recursively +if [ $# -eq 0 ]; then + # Get all tracked files that match our patterns, respecting .gitignore + # and excluding .github directory + git ls-files "*.java" "*.xml" "*.py" "*.yml" "*.yaml" "*.cfg" "*.ini" "*.ps1" "*.sh" | + grep -v "^\.github/" | + while IFS= read -r file; do + process_file "$file" + done +else + # Process specific files provided as arguments + for file in "$@"; do + # Skip files in .github directory + if [[ $file != .github/* ]]; then + process_file "$file" + fi + done +fi \ No newline at end of file diff --git a/src/deadline/nuke_submitter/adaptor_override_environment.yaml b/src/deadline/nuke_submitter/adaptor_override_environment.yaml index 17521643..9215a09e 100644 --- a/src/deadline/nuke_submitter/adaptor_override_environment.yaml +++ b/src/deadline/nuke_submitter/adaptor_override_environment.yaml @@ -1,3 +1,5 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + specificationVersion: 'jobtemplate-2023-09' parameterDefinitions: - name: AdaptorWheels diff --git a/src/deadline/nuke_submitter/default_nuke_job_template.yaml b/src/deadline/nuke_submitter/default_nuke_job_template.yaml index d421c6f9..f2e325ef 100644 --- a/src/deadline/nuke_submitter/default_nuke_job_template.yaml +++ b/src/deadline/nuke_submitter/default_nuke_job_template.yaml @@ -1,3 +1,5 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + specificationVersion: jobtemplate-2023-09 name: Default Nuke Job Template parameterDefinitions: diff --git a/test/test_copyright_headers.py b/test/test_copyright_headers.py index 40564b6a..0517744c 100644 --- a/test/test_copyright_headers.py +++ b/test/test_copyright_headers.py @@ -7,7 +7,15 @@ _copyright_header_re = re.compile( r"Copyright Amazon\.com, Inc\. or its affiliates\. All Rights Reserved\.", re.IGNORECASE ) -_generated_by_scm = re.compile(r"# file generated by setuptools_scm", re.IGNORECASE) +_generated_by_scm = re.compile(r"# file generated by setuptools[-_]scm", re.IGNORECASE) + + +class FileMissingCopyRight(Exception): + filepath: Path + + def __init__(self, message, filepath): + super().__init__(message) + self.filepath = filepath def _check_file(filename: Path) -> None: @@ -18,15 +26,17 @@ def _check_file(filename: Path) -> None: return # success lines_read += 1 if lines_read > 10: - raise Exception( + raise FileMissingCopyRight( f"Could not find a valid Amazon.com copyright header in the top of {filename}." - " Please add one." + "Please run scripts/add_copyright_headers.sh from repository root folder to add it.", + Path(filename), ) else: # __init__.py files are usually empty, this is to catch that. - raise Exception( + raise FileMissingCopyRight( f"Could not find a valid Amazon.com copyright header in the top of {filename}." - " Please add one." + " Please run scripts/add_copyright_headers.sh from repository root folder to add it.", + Path(filename), ) @@ -50,19 +60,27 @@ def test_copyright_headers(): # The root of the project is the directory that contains the test directory. while not (root_project_dir / "test").exists(): root_project_dir = root_project_dir.parent - # Choose only a few top level directories to test. - # That way we don't snag any virtual envs a developer might create, at the risk of missing - # some top level .py files. - top_level_dirs = ["src", "test", "scripts"] + # Call out every directory & extension we expect to see copyright headers in; non-exhaustive but best-effort + top_level_dirs = ["src", "test", "scripts", "pipeline", "installer", "install_builder"] file_count = 0 + failed_files = set() for top_level_dir in top_level_dirs: - for glob_pattern in ("**/*.py", "**/*.sh"): + for glob_pattern in ("**/*.py", "**/*.sh", "**/*.ps1", "**/*.xml"): for path in Path(root_project_dir / top_level_dir).glob(glob_pattern): print(path) if not _is_version_file(path): - _check_file(path) + try: + _check_file(path) + except FileMissingCopyRight as e: + failed_files.add(e.filepath) file_count += 1 + if failed_files: + formatted_failed_files = "\n\t".join(str(filepath) for filepath in failed_files) + raise Exception( + f"Found {len(failed_files)} files without copyright headers:\n\t{formatted_failed_files}" + ) + print(f"test_copyright_headers checked {file_count} files successfully.")