From 3caa86301a2207434cbc48c0b610a6efc5a22027 Mon Sep 17 00:00:00 2001 From: Matthew Watkins Date: Fri, 12 Apr 2024 13:12:38 +0100 Subject: [PATCH] Chore: Update DevOps tooling from central repository [skip ci] This commit created by automation/scripting Signed-off-by: Matthew Watkins --- .gitignore | 170 ++++++++++++++++++++++++++++++++++------ .pre-commit-config.yaml | 170 ++++++++++++++++++++++++++++++++++------ 2 files changed, 290 insertions(+), 50 deletions(-) diff --git a/.gitignore b/.gitignore index 692f450..c4ad8e4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,22 +1,39 @@ +# Temporary devops repo +.devops + +# Output files from co2budget.ipynb (ITR-Examples) +OECM-images +TPI-images + + +# Local node cache +node_modules + +# Credentials / Secrets +credentials.env +config.toml + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] +*$py.class + +.idea/* +*.iml # C extensions *.so -# Credentials -credentials.env - -# Credentials -credentials.env - # Distribution / packaging .Python -env/ +.pdm-python +.pdm-build +.pdm.toml +.tox build/ develop-eggs/ -dist/ +dist/** +!app/static/frontend/dist/ downloads/ eggs/ .eggs/ @@ -25,15 +42,14 @@ lib64/ parts/ sdist/ var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ *.egg-info/ .installed.cfg *.egg - -# Mac OS-specific storage files -.DS_Store - -# Mac OS-specific storage files -.DS_Store +MANIFEST +poetry.lock # PyInstaller # Usually these files are written by a python script from a template @@ -45,18 +61,122 @@ var/ pip-log.txt pip-delete-this-directory.txt +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ -# Scratch pads -pad.ipynb +# Translations +*.mo +*.pot -# Unit test / coverage reports -*test_output -# Unit test / coverage reports -*test_output +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal -credentials.env -src/inventories/hazard/inventory_live.json -.vscode/launch.json -.vscode/settings.json -.pdm-python +# Excel stuff: +~$*.xlsx + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ +examples/itr_ui/ +itr_env/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# The actual launch configuration for AWS +docker-compose_aws.yml +.idea/workspace.xml +*.exe +%USERPROFILE%/* + +# vscode +.vscode + +# Misc +.noseids +test/.DS_Store +.DS_Store + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d1617ce..2e85b55 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,42 +1,162 @@ --- +ci: + autofix_commit_msg: "Chore: pre-commit autoupdate" + skip: + # pre-commit.ci cannot install WGET, so tomlint must be disabled + - tomllint + # - pre-commit-update + +exclude: | + (?x)^( + docs\/conf.py| + dco-signoffs/$ + )$ + repos: + + # - repo: https://gitlab.com/vojko.pribudic/pre-commit-update + # rev: v0.1.0 + # hooks: + # - id: pre-commit-update + # args: [--dry-run] + + - repo: local + hooks: + - id: tomllint + name: "Script: scripts/tomllint.sh" + language: script + # pass_filenames: false + files: \^*.toml + types: [file] + entry: scripts/tomllint.sh . + - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v4.6.0 hooks: - - id: trailing-whitespace - - id: check-merge-conflict - - id: end-of-file-fixer - - id: name-tests-test - - id: check-byte-order-marker + - id: check-added-large-files + - id: check-ast - id: check-case-conflict - - id: check-docstring-first + - id: check-executables-have-shebangs - id: check-json + - id: check-merge-conflict + - id: check-shebang-scripts-are-executable + - id: check-symlinks - id: check-toml + # - id: detect-aws-credentials + - id: check-xml - id: check-yaml - - id: check-symlinks - - id: detect-private-key - - id: check-ast - id: debug-statements + - id: detect-private-key + - id: end-of-file-fixer + - id: mixed-line-ending + args: ["--fix=lf"] + - id: name-tests-test + args: ["--pytest-test-first"] + # Do not allow direct push to main/master branches + - id: no-commit-to-branch + # - id: pretty-format-json + - id: requirements-txt-fixer + - id: trailing-whitespace + + # Autoformat: YAML, JSON, Markdown, etc. + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v4.0.0-alpha.8 + hooks: + - id: prettier + args: + ['--no-error-on-unmatched-pattern', '--ignore-unknown'] - - repo: https://github.com/Lucas-C/pre-commit-hooks - rev: v1.5.5 + # Lint: Markdown + - repo: https://github.com/igorshubovych/markdownlint-cli + rev: v0.39.0 hooks: - - id: remove-tabs + - id: markdownlint + args: ["--fix"] + + # - repo: https://github.com/asottile/pyupgrade + # rev: v3.15.0 + # hooks: + # - id: pyupgrade + # args: ['--py37-plus'] - - repo: https://github.com/psf/black - rev: '24.2.0' + - repo: https://github.com/psf/black-pre-commit-mirror + rev: 24.3.0 hooks: - id: black + + - repo: https://github.com/psf/black-pre-commit-mirror + rev: 24.3.0 + hooks: - id: black-jupyter - - repo: https://github.com/s-weigand/flake8-nb - rev: v0.5.3 + - repo: https://github.com/jorisroovers/gitlint + rev: v0.19.1 hooks: - - id: flake8-nb - additional_dependencies: - - pep8-naming - # Ignore all format-related checks as Black takes care of those. - args: - - --ignore=E2, W5, F401, E401, E704 - - --select=E, W, F, N - - --max-line-length=120 + - id: gitlint + + - repo: https://github.com/openstack/bashate + rev: 2.1.1 + hooks: + - id: bashate + args: ["--ignore=E006,E011"] + + - repo: https://github.com/shellcheck-py/shellcheck-py + rev: v0.10.0.1 + hooks: + - id: shellcheck + # Optionally only show errors and warnings + # args: ["--severity=warning"] + + # If you want to avoid flake8 errors due to unused vars or imports: + # - repo: https://github.com/PyCQA/autoflake + # rev: v2.0.0 + # hooks: + # - id: autoflake + # args: [ + # --in-place, + # --remove-all-unused-imports, + # --remove-unused-variables, + # ] + + - repo: https://github.com/PyCQA/isort + rev: 5.13.2 + hooks: + - id: isort + args: ["--profile", "black"] + + - repo: https://github.com/adrienverge/yamllint.git + rev: v1.35.1 + hooks: + - id: yamllint + args: [--strict] + + - repo: https://github.com/Mateusz-Grzelinski/actionlint-py + rev: v1.6.27.13 + hooks: + - id: actionlint + + # If like to embrace black styles even in the docs: + # - repo: https://github.com/asottile/blacken-docs + # rev: v1.13.0 + # hooks: + # - id: blacken-docs + # additional_dependencies: [black] + + - repo: https://github.com/pycqa/flake8 + rev: "7.0.0" + hooks: + - id: flake8 + + # Check for misspells in documentation files: + # - repo: https://github.com/codespell-project/codespell + # rev: v2.2.2 + # hooks: + # - id: codespell + + - repo: https://github.com/pre-commit/mirrors-mypy + rev: "v1.9.0" + hooks: + - id: mypy + verbose: true + args: [--show-error-codes] + additional_dependencies: ["pytest", "types-requests"]