diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 30ae15d95..81b730343 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -33,9 +33,6 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Ensure copyright and license header are present - run: ./.github/linters/check_headers_exist.sh - - name: Run pre-commit uses: pre-commit/action@v3.0.0 with: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 035345532..d01c57a3b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,3 +30,9 @@ repos: entry: mypy args: ['--config-file=setup.cfg'] additional_dependencies: ['mypy', 'types-PyYAML', 'types-requests', 'types-python-slugify', 'types-psycopg2'] + - id: copyright-headers + name: copyright-headers + language: script + types_or: [python, shell, yaml, dockerfile] + entry: bin/linters/check_headers_exist.sh + diff --git a/README.md b/README.md index d075fa11d..74bacf14c 100644 --- a/README.md +++ b/README.md @@ -142,7 +142,7 @@ setfacl -R -m d:g::rwX /gae/pixl_dev ### 1. Choose deployment environment -This is one of dev|test|staging|prod and referred to as `` in the docs. +This is one of `dev|test|staging|prod` and referred to as `` in the docs. ### 2. Initialise environment configuration diff --git a/.github/linters/check_headers_exist.sh b/bin/linters/check_headers_exist.sh similarity index 64% rename from .github/linters/check_headers_exist.sh rename to bin/linters/check_headers_exist.sh index 2542f211f..d7c1e6fa8 100755 --- a/.github/linters/check_headers_exist.sh +++ b/bin/linters/check_headers_exist.sh @@ -12,15 +12,15 @@ # 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. +set -euo pipefail -for ext in ".yml" ".yaml" ".sh" "Dockerfile" ".py" -do - # shellcheck disable=SC2044 - for path in $(find . -name "*$ext") - do - if ! grep -q "Copyright" "$path"; then - echo -e "\n\e[31m»»» ⚠️ No copyright/license header in $path" - exit 1 - fi - done || exit 1 +for f in "$@"; do + if ! grep -q '#.*Copyright.*University College London Hospitals NHS Foundation Trust' "$f"; then + echo "No copyright notice found in $f" + exit 1 + fi + if ! grep -q '#.*Licensed under the Apache License, Version 2.0' "$f"; then + echo "No licence notice found in $f" + exit 1 + fi done diff --git a/cli/README.md b/cli/README.md index 466b932c9..deb22fe55 100644 --- a/cli/README.md +++ b/cli/README.md @@ -20,7 +20,7 @@ management tool such as [conda](https://docs.conda.io/en/latest/) or Then install in editable mode by running ```bash -pip install -e ../pixl_core/ . +pip install -e ../pixl_core/ -e . ``` ## Usage @@ -136,7 +136,7 @@ Commands: Install locally in editable mode with the development and testing dependencies by running ```bash -pip install -e ../pixl_core/ .[test] +pip install -e ../pixl_core/ -e .[test] ``` ### Running tests diff --git a/pixl_core/README.md b/pixl_core/README.md index cf669fe87..fbc68471b 100644 --- a/pixl_core/README.md +++ b/pixl_core/README.md @@ -24,7 +24,7 @@ pip install -e . ## Testing ```bash -pip install -e .[test] && pip install ../pytest-pixl +pip install -e .[test] && pip install -e ../pytest-pixl pytest ``` diff --git a/pixl_dcmd/README.md b/pixl_dcmd/README.md index 266f5a51a..1f4c7e534 100644 --- a/pixl_dcmd/README.md +++ b/pixl_dcmd/README.md @@ -20,7 +20,7 @@ Specifically, the `pixl_dcmd` package provides the following functionality: Install the Python dependencies with ```bash -pip install -e ../pixl_core/ .[test,dev] +pip install -e ../pixl_core/ -e .[test,dev] ``` ## Test diff --git a/pixl_ehr/README.md b/pixl_ehr/README.md index 8f9eda259..8eb65c4a4 100644 --- a/pixl_ehr/README.md +++ b/pixl_ehr/README.md @@ -27,13 +27,13 @@ On Windows, follow [these instructions](https://www.postgresqltutorial.com/postg Then install the Python dependencies with ```bash -pip install -e ../pixl_core/ . +pip install -e ../pixl_core/ -e . ``` ## Test ```bash -pip install -e ../pixl_core/ .[test] +pip install -e ../pixl_core/ -e .[test] pytest -m "not processing" ``` diff --git a/pixl_imaging/README.md b/pixl_imaging/README.md index 9610b97c3..989262303 100644 --- a/pixl_imaging/README.md +++ b/pixl_imaging/README.md @@ -12,7 +12,7 @@ for the requested imaging study, if it didn't already exist. ## Installation ```bash -pip install -e ../pixl_core/ . +pip install -e ../pixl_core/ -e . ``` ## Test