From df3d6d97bd8a08061eca415903d305974a563cbc Mon Sep 17 00:00:00 2001 From: Katy Baulch <46493669+katybaulch@users.noreply.github.com> Date: Mon, 8 Apr 2024 15:38:48 +0100 Subject: [PATCH 1/9] Add trunk to nav backend --- .gitignore | 1 + .trunk/.gitignore | 9 ++++ .trunk/configs/.hadolint.yaml | 4 ++ .trunk/configs/.isort.cfg | 2 + .trunk/configs/.markdownlint.yaml | 25 +++++++++ .trunk/configs/.shellcheckrc | 7 +++ .trunk/configs/.yamllint.yaml | 10 ++++ .trunk/configs/bandit.yaml | 1 + .trunk/configs/ruff.toml | 8 +++ .trunk/configure-pyright-with-pyenv.sh | 34 ++++++++++++ .trunk/trunk.yaml | 74 ++++++++++++++++++++++++++ 11 files changed, 175 insertions(+) create mode 100644 .trunk/.gitignore create mode 100644 .trunk/configs/.hadolint.yaml create mode 100644 .trunk/configs/.isort.cfg create mode 100644 .trunk/configs/.markdownlint.yaml create mode 100644 .trunk/configs/.shellcheckrc create mode 100644 .trunk/configs/.yamllint.yaml create mode 100644 .trunk/configs/bandit.yaml create mode 100644 .trunk/configs/ruff.toml create mode 100755 .trunk/configure-pyright-with-pyenv.sh create mode 100644 .trunk/trunk.yaml diff --git a/.gitignore b/.gitignore index 9362cd24..f58fe1dc 100644 --- a/.gitignore +++ b/.gitignore @@ -121,6 +121,7 @@ ipython_config.py # pyenv .python-version +pyrightconfig.json # pipenv # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. diff --git a/.trunk/.gitignore b/.trunk/.gitignore new file mode 100644 index 00000000..15966d08 --- /dev/null +++ b/.trunk/.gitignore @@ -0,0 +1,9 @@ +*out +*logs +*actions +*notifications +*tools +plugins +user_trunk.yaml +user.yaml +tmp diff --git a/.trunk/configs/.hadolint.yaml b/.trunk/configs/.hadolint.yaml new file mode 100644 index 00000000..98bf0cd2 --- /dev/null +++ b/.trunk/configs/.hadolint.yaml @@ -0,0 +1,4 @@ +# Following source doesn't work in most setups +ignored: + - SC1090 + - SC1091 diff --git a/.trunk/configs/.isort.cfg b/.trunk/configs/.isort.cfg new file mode 100644 index 00000000..b9fb3f3e --- /dev/null +++ b/.trunk/configs/.isort.cfg @@ -0,0 +1,2 @@ +[settings] +profile=black diff --git a/.trunk/configs/.markdownlint.yaml b/.trunk/configs/.markdownlint.yaml new file mode 100644 index 00000000..2729f6c1 --- /dev/null +++ b/.trunk/configs/.markdownlint.yaml @@ -0,0 +1,25 @@ +# Autoformatter friendly markdownlint config (all formatting rules disabled) +default: true + +MD013: + # Number of characters + line_length: 80 + + # Number of characters for headings + heading_line_length: 80 + + # Number of characters for code blocks + code_block_line_length: 80 + + # Include + headings: true + + # Don't include + tables: false + code_blocks: false + + # Strict length checking + strict: false + + # Stern length checking + stern: false diff --git a/.trunk/configs/.shellcheckrc b/.trunk/configs/.shellcheckrc new file mode 100644 index 00000000..8c7b1ada --- /dev/null +++ b/.trunk/configs/.shellcheckrc @@ -0,0 +1,7 @@ +enable=all +source-path=SCRIPTDIR +disable=SC2154 + +# If you're having issues with shellcheck following source, disable the errors via: +# disable=SC1090 +# disable=SC1091 diff --git a/.trunk/configs/.yamllint.yaml b/.trunk/configs/.yamllint.yaml new file mode 100644 index 00000000..4d444662 --- /dev/null +++ b/.trunk/configs/.yamllint.yaml @@ -0,0 +1,10 @@ +rules: + quoted-strings: + required: only-when-needed + extra-allowed: ["{|}"] + empty-values: + forbid-in-block-mappings: true + forbid-in-flow-mappings: true + key-duplicates: {} + octal-values: + forbid-implicit-octal: true diff --git a/.trunk/configs/bandit.yaml b/.trunk/configs/bandit.yaml new file mode 100644 index 00000000..4a6ddd33 --- /dev/null +++ b/.trunk/configs/bandit.yaml @@ -0,0 +1 @@ +exclude_dirs: ["tests"] diff --git a/.trunk/configs/ruff.toml b/.trunk/configs/ruff.toml new file mode 100644 index 00000000..927942ea --- /dev/null +++ b/.trunk/configs/ruff.toml @@ -0,0 +1,8 @@ +# Generic, formatter-friendly config. +select = ["B", "D3", "E", "F"] + +# Never enforce `E501` (line length violations). This should be handled by formatters. +ignore = ["E501"] + +[lint] +ignore-init-module-imports = true diff --git a/.trunk/configure-pyright-with-pyenv.sh b/.trunk/configure-pyright-with-pyenv.sh new file mode 100755 index 00000000..88936607 --- /dev/null +++ b/.trunk/configure-pyright-with-pyenv.sh @@ -0,0 +1,34 @@ +#! /usr/bin/env bash +set -e + +# Get the name of the expected venv for this repo from the pyproject.toml file. +venv_name=$(grep -m 1 venv pyproject.toml | tr -s ' ' | tr -d '"' | tr -d "'" | cut -d' ' -f3) || true + +# Check if pyrightconfig already exists. +if [[ ! -f pyrightconfig.json ]]; then + # Check if pyenv-pyright plugin is installed + if ! command -v pyenv &>/dev/null; then + echo "pyenv not installed. Please install pyenv..." + exit 1 + fi + + pyenv_root=$(pyenv root) + dir_path="${pyenv_root}"/plugins/pyenv-pyright + if [[ ! -d ${dir_path} ]]; then + # trunk-ignore(shellcheck/SC2312) + if [[ -n $(ls -A "${dir_path}") ]]; then + git clone https://github.com/alefpereira/pyenv-pyright.git "${dir_path}" + fi + fi + + # Generate the pyrightconfig.json file. + pyenv pyright "${venv_name}" + pyenv local "${venv_name}" +fi + +# Check whether required keys are present in pyrightconfig.json. +if ! jq -r --arg venv_name "${venv_name}" '. | select(.venv != $venv_name) | select(.venvPath != null)' pyrightconfig.json; then + echo "Failed to configure pyright to use pyenv environment '${venv_name}' as interpreter. Please check pyrightconfig.json..." + exit 1 +fi +exit 0 diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml new file mode 100644 index 00000000..04370896 --- /dev/null +++ b/.trunk/trunk.yaml @@ -0,0 +1,74 @@ +# This file controls the behavior of Trunk: https://docs.trunk.io/cli +# +# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml +version: 0.1 +cli: + version: 1.21.0 + +# Trunk provides extensibility via plugins. +# (https://docs.trunk.io/plugins) +plugins: + sources: + - id: trunk + ref: v1.4.5 + uri: https://github.com/trunk-io/plugins + +# Many linters and tools depend on runtimes - configure them here. +# (https://docs.trunk.io/runtimes) +runtimes: + enabled: + - go@1.21.0 + - node@18.12.1 + - python@3.10.8 + +# This is the section where you manage your linters. +# (https://docs.trunk.io/check/configuration) +lint: + definitions: + - name: bandit + direct_configs: [bandit.yaml] + commands: + - name: lint + run: bandit --exit-zero -c bandit.yaml --format json --output ${tmpfile} ${target} + + enabled: + - actionlint@1.6.27 + - bandit@1.7.8 + - black@24.3.0 + - checkov@3.2.55 + - git-diff-check + - hadolint@2.12.0 + - isort@5.13.2 + - markdownlint@0.39.0 + - osv-scanner@1.7.0 + - oxipng@9.0.0 + - pre-commit-hooks@4.5.0: + commands: + - end-of-file-fixer + - check-json + - detect-aws-credentials + - prettier@3.2.5 + - pyright@1.1.357 + - ruff@0.3.5 + - shellcheck@0.10.0 + - shfmt@3.6.0 + - taplo@0.8.1 + - terrascan@1.19.1 + - trivy@0.50.1 + - trufflehog@3.71.0 + - yamllint@1.35.1 + +actions: + disabled: + - trunk-check-pre-push + enabled: + - configure-pyright-with-pyenv + - trunk-check-pre-commit + - trunk-announce + - trunk-fmt-pre-commit + - trunk-upgrade-available + definitions: + - id: configure-pyright-with-pyenv + run: source .trunk/configure-pyright-with-pyenv.sh + triggers: + - git_hooks: [pre-commit] From 021f05c7f740730b8e0c341ae72dfd8acee32835 Mon Sep 17 00:00:00 2001 From: Katy Baulch <46493669+katybaulch@users.noreply.github.com> Date: Mon, 8 Apr 2024 15:42:10 +0100 Subject: [PATCH 2/9] Add code quality job to CI --- .github/workflows/ci-cd.yml | 46 +++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 3bc4f7af..0712548e 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -21,6 +21,20 @@ jobs: (! startsWith(github.ref, 'refs/tags') && ! startsWith(github.ref, 'refs/heads/main')) uses: climatepolicyradar/reusable-workflows/.github/workflows/check-auto-tagging-will-work.yml@v3 + code-quality: + if: | + always() && + (needs.check-auto-tagging-will-work.result == 'skipped' || needs.check-auto-tagging-will-work.result == 'success') && + ! startsWith(github.ref, 'refs/tags') + needs: + - check-auto-tagging-will-work + permissions: + # For trunk to post annotations + checks: write + # For repo checkout + contents: read + uses: climatepolicyradar/reusable-workflows/.github/workflows/python-precommit-validator.yml@v3 + non-search-tests: if: | always() && @@ -33,10 +47,10 @@ jobs: - uses: actions/checkout@v4 - name: Use .env.example - run: cp .env.example .env + run: cp .env.example .env - name: Get python Container - run: docker pull python:3.9 + run: docker pull python:3.9 - name: Build run: | @@ -44,13 +58,13 @@ jobs: docker images - name: Build docker-compose stack - run: make start_without_vespa_setup + run: make start_without_vespa_setup - name: Wait for backend to open port - run: ./scripts/wait_for_port.sh localhost 8888 60 + run: ./scripts/wait_for_port.sh localhost 8888 60 - name: Run backend tests - run: make test_non_search + run: make test_non_search - name: Docker debug run: | @@ -75,14 +89,14 @@ jobs: - uses: actions/checkout@v4 - name: Use .env.example - run: cp .env.example .env + run: cp .env.example .env - name: Get python Container - run: docker pull python:3.9 + run: docker pull python:3.9 - name: Install latest Vespa CLI env: - VESPA_CLI_VERSION: "8.250.43" + VESPA_CLI_VERSION: 8.250.43 run: | mkdir scripts/vespa-cli curl -fsSL https://github.com/vespa-engine/vespa/releases/download/v${VESPA_CLI_VERSION}/vespa-cli_${VESPA_CLI_VERSION}_linux_amd64.tar.gz | \ @@ -95,17 +109,17 @@ jobs: docker images - name: Build docker-compose stack - run: make start + run: make start - name: Setup vespa for search run: make vespa_setup - name: Run backend search tests for vespa - run: make test_search + run: make test_search - name: Log Dump - if: always() - run: docker compose logs + if: always() + run: docker compose logs integration-tests: if: | @@ -122,12 +136,14 @@ jobs: build: if: | always() && - (needs.non-search-tests.result == 'success' && + (needs.code-quality.result == 'success' && + needs.non-search-tests.result == 'success' && needs.search-tests.result == 'success' && needs.integration-tests.result == 'success') && ! startsWith(github.ref, 'refs/tags') runs-on: ubuntu-latest needs: + - code-quality - non-search-tests - search-tests - integration-tests @@ -135,10 +151,10 @@ jobs: - uses: actions/checkout@v4 - name: Use .env.example - run: cp .env.example .env + run: cp .env.example .env - name: Get python Container - run: docker pull python:3.9 + run: docker pull python:3.9 - name: Build run: | From 63feaf7ae4cdb8727bab53e70a68701481e5eaa6 Mon Sep 17 00:00:00 2001 From: Katy Baulch <46493669+katybaulch@users.noreply.github.com> Date: Mon, 8 Apr 2024 16:00:17 +0100 Subject: [PATCH 3/9] Update makefile --- Makefile | 11 +++-------- makefile-docker.defs | 5 +++++ makefile-local.defs | 15 +++++++++++++-- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 13210abb..aa370648 100644 --- a/Makefile +++ b/Makefile @@ -2,11 +2,6 @@ include .env include ./makefile-local.defs include ./makefile-docker.defs -git_hooks: - # Install git pre-commit hooks - poetry run pre-commit install --install-hooks - -restart: - docker compose build - make start - make show_logs +check: + trunk fmt + trunk check diff --git a/makefile-docker.defs b/makefile-docker.defs index 163e089d..96e81d18 100644 --- a/makefile-docker.defs +++ b/makefile-docker.defs @@ -29,6 +29,11 @@ up: # docker-compose up, without -d docker compose -f docker-compose.yml -f docker-compose.dev.yml up +restart: + docker compose build + make start + make show_logs + # ---------------------------------- # database maintenance # ---------------------------------- diff --git a/makefile-local.defs b/makefile-local.defs index f19437d8..ed9286ef 100644 --- a/makefile-local.defs +++ b/makefile-local.defs @@ -9,7 +9,7 @@ ifneq (,$(wildcard ./.env)) exit 1 endif -dev_install: check_dev_environment +dev_install: install_trunk check_dev_environment # Sets up a local dev environment # Copy .env @@ -20,9 +20,20 @@ dev_install: check_dev_environment pip install "poetry==1.7.1" make poetry_environment - make git_hooks + trunk actions run configure-pyright-with-pyenv create_venv: - pyenv deactivate pyenv virtualenv 3.9 backend pyenv activate backend + +install_trunk: + $(eval trunk_installed=$(shell trunk --version > /dev/null 2>&1 ; echo $$? )) +ifneq (${trunk_installed},0) + $(eval OS_NAME=$(shell uname -s | tr A-Z a-z)) + curl https://get.trunk.io -fsSL | bash +endif + +uninstall_trunk: + sudo rm -if `which trunk` + rm -ifr ${HOME}/.cache/trunk From 57be0f3f040621013ab1706aeaa47586fb9ede12 Mon Sep 17 00:00:00 2001 From: Katy Baulch <46493669+katybaulch@users.noreply.github.com> Date: Mon, 8 Apr 2024 16:01:02 +0100 Subject: [PATCH 4/9] Bump package version to 1.8.2 --- pyproject.toml | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 00a6e9b1..9d12d4c6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "navigator_backend" -version = "0.1.0" +version = "1.8.2" description = "" authors = ["CPR-dev-team "] @@ -9,7 +9,9 @@ python = "^3.9" Authlib = "^0.15.5" bcrypt = "^3.2.0" boto3 = "^1.26" -cpr-data-access = {git = "https://github.com/climatepolicyradar/data-access.git", tag="v0.5.8", extras = ["vespa"]} +cpr-data-access = { git = "https://github.com/climatepolicyradar/data-access.git", tag = "v0.5.8", extras = [ + "vespa", +] } fastapi = "^0.104.1" fastapi-health = "^0.4.0" fastapi-pagination = { extras = ["sqlalchemy"], version = "^0.12.19" } @@ -30,7 +32,7 @@ starlette = "^0.27.0" tenacity = "^8.0.1" uvicorn = { extras = ["standard"], version = "^0.20.0" } botocore = "^1.34.19" -db-client = {git = "https://github.com/climatepolicyradar/navigator-db-client.git", tag = "v3.4.0"} +db-client = { git = "https://github.com/climatepolicyradar/navigator-db-client.git", tag = "v3.4.0" } urllib3 = "<2" apscheduler = "^3.10.4" @@ -57,11 +59,7 @@ build-backend = "poetry.core.masonry.api" [tool.pytest.ini_options] addopts = "-p no:cacheprovider" -markers = [ - "cors", - "search", - "unit", -] +markers = ["cors", "search", "unit"] asyncio_mode = "strict" [tool.pydocstyle] @@ -70,9 +68,7 @@ ignore = """ [tool.pyright] include = ["app", "scripts", "tests"] -exclude = [ - "**/__pycache__", -] +exclude = ["**/__pycache__"] ignore = ["scripts/**/*"] defineConstant = { DEBUG = true } @@ -81,4 +77,4 @@ reportMissingTypeStubs = false pythonVersion = "3.9" pythonPlatform = "Linux" -venv = "backend" \ No newline at end of file +venv = "backend" From 5b248d71ab347f11071415a218c5e918cb7f1d19 Mon Sep 17 00:00:00 2001 From: Katy Baulch <46493669+katybaulch@users.noreply.github.com> Date: Mon, 8 Apr 2024 16:12:01 +0100 Subject: [PATCH 5/9] Use docker compose v2 syntax & add make for configuring pyright --- docs/docker.md | 12 ++++++------ makefile-local.defs | 5 ++++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/docs/docker.md b/docs/docker.md index 42d9994f..9e3c8660 100644 --- a/docs/docker.md +++ b/docs/docker.md @@ -3,7 +3,7 @@ Run the stack with ```shell -docker-compose up +docker compose up ``` or @@ -15,29 +15,29 @@ make start ## Rebuilding containers ```shell -docker-compose build +docker compose build ``` ## Restarting containers ```shell -docker-compose restart +docker compose restart ``` ## Bringing containers down ```shell -docker-compose down +docker compose down ``` ## Logging ```shell -docker-compose logs +docker compose logs ``` Or for a specific service: ```shell -docker-compose logs -f name_of_service # backend|db|... +docker compose logs -f name_of_service # backend|db|... ``` diff --git a/makefile-local.defs b/makefile-local.defs index ed9286ef..d9ea15ce 100644 --- a/makefile-local.defs +++ b/makefile-local.defs @@ -9,6 +9,9 @@ ifneq (,$(wildcard ./.env)) exit 1 endif +configure_pyright: + trunk actions run configure-pyright-with-pyenv + dev_install: install_trunk check_dev_environment # Sets up a local dev environment @@ -20,7 +23,7 @@ dev_install: install_trunk check_dev_environment pip install "poetry==1.7.1" make poetry_environment - trunk actions run configure-pyright-with-pyenv + make configure_pyright create_venv: - pyenv deactivate From aa8c33c27b16966494f9caea3c8b68fdc7da264e Mon Sep 17 00:00:00 2001 From: Katy Baulch <46493669+katybaulch@users.noreply.github.com> Date: Mon, 8 Apr 2024 16:30:19 +0100 Subject: [PATCH 6/9] Add dependency update as PR type --- .github/pull_request_template.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 46ac5afb..6bbd54b8 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -39,6 +39,7 @@ Please select the option(s) below that are most relevant: - [ ] GitHub workflow update - [ ] Documentation update - [ ] Refactor legacy code +- [ ] Dependency update ## How Has This Been Tested? From e96da60d1ace66c52ab3a01b36863cba99203708 Mon Sep 17 00:00:00 2001 From: Katy Baulch <46493669+katybaulch@users.noreply.github.com> Date: Mon, 8 Apr 2024 16:38:14 +0100 Subject: [PATCH 7/9] Only run if not cancelled --- .github/workflows/ci-cd.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 0712548e..46c3c4a7 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -23,7 +23,7 @@ jobs: code-quality: if: | - always() && + ! cancelled() && always() && (needs.check-auto-tagging-will-work.result == 'skipped' || needs.check-auto-tagging-will-work.result == 'success') && ! startsWith(github.ref, 'refs/tags') needs: @@ -37,7 +37,7 @@ jobs: non-search-tests: if: | - always() && + ! cancelled() && always() && (needs.check-auto-tagging-will-work.result == 'skipped' || needs.check-auto-tagging-will-work.result == 'success') && ! startsWith(github.ref, 'refs/tags') needs: @@ -79,7 +79,7 @@ jobs: search-tests: if: | - always() && + ! cancelled() && always() && (needs.check-auto-tagging-will-work.result == 'skipped' || needs.check-auto-tagging-will-work.result == 'success') && ! startsWith(github.ref, 'refs/tags') needs: @@ -123,7 +123,7 @@ jobs: integration-tests: if: | - always() && + ! cancelled() && always() && (needs.check-auto-tagging-will-work.result == 'skipped' || needs.check-auto-tagging-will-work.result == 'success') && ! startsWith(github.ref, 'refs/tags') needs: @@ -135,7 +135,7 @@ jobs: build: if: | - always() && + ! cancelled() && always() && (needs.code-quality.result == 'success' && needs.non-search-tests.result == 'success' && needs.search-tests.result == 'success' && @@ -198,7 +198,7 @@ jobs: fi manual-semver: - if: ${{ always() && startsWith(github.ref, 'refs/tags') }} + if: ${{ ! cancelled() && always() && startsWith(github.ref, 'refs/tags') }} uses: climatepolicyradar/reusable-workflows/.github/workflows/semver.yml@v3 secrets: inherit with: @@ -206,7 +206,7 @@ jobs: semver-tag: main-${GITHUB_SHA::8} tag: - if: ${{ always() && (needs.build.result == 'success')}} + if: ${{ ! cancelled() && always() && (needs.build.result == 'success')}} needs: build permissions: contents: write @@ -220,7 +220,7 @@ jobs: DOCKER_REGISTRY: ${{ secrets.DOCKER_REGISTRY }} release: - if: ${{ always() && (needs.tag.result == 'success' && needs.tag.outputs.new_tag != 'Skip')}} + if: ${{ ! cancelled() && always() && (needs.tag.result == 'success' && needs.tag.outputs.new_tag != 'Skip')}} needs: tag permissions: contents: write From b77819e0fec481e5e68e1db321c07f04ae065668 Mon Sep 17 00:00:00 2001 From: Katy Baulch <46493669+katybaulch@users.noreply.github.com> Date: Mon, 8 Apr 2024 17:12:20 +0100 Subject: [PATCH 8/9] Remove old pre-commit file & merge into trunk config --- .pre-commit-config.yaml | 43 ----------------------------------------- .trunk/trunk.yaml | 18 +++++++++++++++-- 2 files changed, 16 insertions(+), 45 deletions(-) delete mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index 4817c85f..00000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,43 +0,0 @@ -repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.1.0 - hooks: - - id: check-json - exclude: tests/data/.*\.json - - id: detect-aws-credentials - args: [ --allow-missing-credentials ] - - id: trailing-whitespace - - id: end-of-file-fixer - exclude: ^.*\.egg-info/ - - id: check-merge-conflict - - id: check-case-conflict - - id: check-toml - - id: check-yaml - - id: check-ast - - id: debug-statements - - id: check-docstring-first - - - repo: https://github.com/python-poetry/poetry - rev: '1.7.1' - hooks: - - id: poetry-check - args: ["-C", "."] - - repo: https://github.com/ambv/black - rev: 23.1.0 - hooks: - - id: black - language_version: python3 - - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: 'v0.0.246' - hooks: - - id: ruff - - repo: local - hooks: - - id: pyright - name: pyright (backend) - entry: pyright - language: node - types: [python] - additional_dependencies: ['pyright@1.1.294'] - -# TODO more checks? e.g. bandit, safety, snyk, ... diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml index 04370896..bb166e8c 100644 --- a/.trunk/trunk.yaml +++ b/.trunk/trunk.yaml @@ -31,6 +31,12 @@ lint: - name: lint run: bandit --exit-zero -c bandit.yaml --format json --output ${tmpfile} ${target} + ignore: + - linters: [ALL] + paths: + # Ignore test data JSON files + - tests/data/**/*.json + enabled: - actionlint@1.6.27 - bandit@1.7.8 @@ -44,9 +50,17 @@ lint: - oxipng@9.0.0 - pre-commit-hooks@4.5.0: commands: - - end-of-file-fixer + - check-ast + - check-case-conflict + - check-docstring-first - check-json - - detect-aws-credentials + - check-merge-conflict + - check-toml + - check-yaml + - debug-statements + - detect-aws-credentials --allow-missing-credentials + - end-of-file-fixer + - trailing-whitespace - prettier@3.2.5 - pyright@1.1.357 - ruff@0.3.5 From ad9372c5b3b5b3be3c3db971f106c45ac5189e30 Mon Sep 17 00:00:00 2001 From: Katy Baulch <46493669+katybaulch@users.noreply.github.com> Date: Mon, 8 Apr 2024 17:20:55 +0100 Subject: [PATCH 9/9] Ignore JSON under test search fixtures folder --- .trunk/trunk.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml index bb166e8c..08a16ea7 100644 --- a/.trunk/trunk.yaml +++ b/.trunk/trunk.yaml @@ -36,6 +36,7 @@ lint: paths: # Ignore test data JSON files - tests/data/**/*.json + - tests/search_fixtures/**/*.json enabled: - actionlint@1.6.27