oncall-engine/.pre-commit-config.yaml

113 lines
3.7 KiB
YAML
Raw Permalink Normal View History

repos:
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
files: ^engine
args: [--settings-file=engine/pyproject.toml, --filter-files]
- id: isort
name: isort - migrators
files: ^tools/migrators
args: [--settings-file=tools/migrators/.isort.cfg, --filter-files]
fake-data generation script + fixes for django-silk and django-debug-toolbar (#1128) # What this PR does ## Main stuff - add Python script to populate local Grafana/OnCall setup w/ large amounts of fake data. Right now the data types that can be generated are: - teams and Admin users via the Grafana API (must be synced manually by going into the UI before going onto the next step) - Calendar Schedules which have three 8h oncall-shifts, via the OnCall public API - fixes `django-debug-toolbar` when being run in `docker-compose` locally ## Other stuff - documents how to easily modify the Grafana `docker-compose` container provisioning configuration - document solutions for two backend setup related issues encountered when running the engine/celery workers locally, outside of `docker-compose`, on an Apple silicon Mac - fixes small bug in `grafana_plugin.helpers.client.APIClient.call_api` where it would call `response.json()` for all requests, regardless of whether or not the response actually contained data or not - in `engine/settings/dev.py`, properly setup `django-silk` and document the steps to use it locally - make it possible to log out debug SQL queries by specifying `DEV_DEBUG_VIEW_SQL_QUERIES` env var, rather than having to uncomment out a section of `settings/dev.py` ## Which issue(s) this PR fixes - Some local setup issues when trying to use `django-silk` and `django-debug-toolbar` - Makes it much easier to populate your local setup with a lot of fake data - Makes it possible to easily modify your local grafana's provisioning configuration ## Checklist - [ ] Tests updated (N/A) - [ ] Documentation added (N/A) - [ ] `CHANGELOG.md` updated (N/A)
2023-01-20 09:19:41 +01:00
- id: isort
name: isort - dev/scripts
files: ^dev/scripts
args: [--settings-file=dev/scripts/.isort.cfg, --filter-files]
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black
files: ^engine
args: [--config=engine/pyproject.toml]
- id: black
name: black - migrators
files: ^tools/migrators
fake-data generation script + fixes for django-silk and django-debug-toolbar (#1128) # What this PR does ## Main stuff - add Python script to populate local Grafana/OnCall setup w/ large amounts of fake data. Right now the data types that can be generated are: - teams and Admin users via the Grafana API (must be synced manually by going into the UI before going onto the next step) - Calendar Schedules which have three 8h oncall-shifts, via the OnCall public API - fixes `django-debug-toolbar` when being run in `docker-compose` locally ## Other stuff - documents how to easily modify the Grafana `docker-compose` container provisioning configuration - document solutions for two backend setup related issues encountered when running the engine/celery workers locally, outside of `docker-compose`, on an Apple silicon Mac - fixes small bug in `grafana_plugin.helpers.client.APIClient.call_api` where it would call `response.json()` for all requests, regardless of whether or not the response actually contained data or not - in `engine/settings/dev.py`, properly setup `django-silk` and document the steps to use it locally - make it possible to log out debug SQL queries by specifying `DEV_DEBUG_VIEW_SQL_QUERIES` env var, rather than having to uncomment out a section of `settings/dev.py` ## Which issue(s) this PR fixes - Some local setup issues when trying to use `django-silk` and `django-debug-toolbar` - Makes it much easier to populate your local setup with a lot of fake data - Makes it possible to easily modify your local grafana's provisioning configuration ## Checklist - [ ] Tests updated (N/A) - [ ] Documentation added (N/A) - [ ] `CHANGELOG.md` updated (N/A)
2023-01-20 09:19:41 +01:00
- id: black
name: black - dev/scripts
files: ^dev/scripts
- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
files: ^engine
args: [--config=engine/tox.ini]
additional_dependencies:
- flake8-bugbear
- flake8-tidy-imports
- id: flake8
name: flake8 - migrators
files: ^tools/migrators
# Make sure config is compatible with black
# https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#flake8
args: ["--max-line-length=88", "--extend-ignore=E203,E501"]
fake-data generation script + fixes for django-silk and django-debug-toolbar (#1128) # What this PR does ## Main stuff - add Python script to populate local Grafana/OnCall setup w/ large amounts of fake data. Right now the data types that can be generated are: - teams and Admin users via the Grafana API (must be synced manually by going into the UI before going onto the next step) - Calendar Schedules which have three 8h oncall-shifts, via the OnCall public API - fixes `django-debug-toolbar` when being run in `docker-compose` locally ## Other stuff - documents how to easily modify the Grafana `docker-compose` container provisioning configuration - document solutions for two backend setup related issues encountered when running the engine/celery workers locally, outside of `docker-compose`, on an Apple silicon Mac - fixes small bug in `grafana_plugin.helpers.client.APIClient.call_api` where it would call `response.json()` for all requests, regardless of whether or not the response actually contained data or not - in `engine/settings/dev.py`, properly setup `django-silk` and document the steps to use it locally - make it possible to log out debug SQL queries by specifying `DEV_DEBUG_VIEW_SQL_QUERIES` env var, rather than having to uncomment out a section of `settings/dev.py` ## Which issue(s) this PR fixes - Some local setup issues when trying to use `django-silk` and `django-debug-toolbar` - Makes it much easier to populate your local setup with a lot of fake data - Makes it possible to easily modify your local grafana's provisioning configuration ## Checklist - [ ] Tests updated (N/A) - [ ] Documentation added (N/A) - [ ] `CHANGELOG.md` updated (N/A)
2023-01-20 09:19:41 +01:00
- id: flake8
name: flake8 - dev/scripts
files: ^dev/scripts
# Make sure config is compatible with black
# https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#flake8
args: ["--max-line-length=88", "--extend-ignore=E203,E501"]
- repo: https://github.com/pre-commit/mirrors-eslint
[UI] fix eslint/prettier warnings (#678) * UI spring cleaning - fix ~570 outstanding eslint warnings - make eslint force user to correct warnings - remove .css files that are not referenced - remove dummy.tsx as it is not consumed anywhere - remove a few functions that were "dead code" (ie. not consumed anywhere) - remove commented out blocks of code that had no explanatory comments surrounding them * add prettier to pre-commit configuration * change ignoreRestSiblings to true we have a few spots in the codebase where we destructure an object key and then use something like ...restProps setting this to true allows that * upgrade from eslint 7.21.0 to 8.25.0 - add @grafana/eslint-config to dev dependencies and pre-commit eslint deps - add @grafana/eslint-config peer dependencies to package.json * fix remaining outstanding prettier warnings * enable noUnusedLocals and noUnusedParameters and fix errors related to this * make pre-commit complain about eslint warnings * import from moment-timezone instead of moment * fix react/display-name eslint warning * add eslint-plugin-react-hooks to dev deps this is a peer dependency from @grafana/eslint-config * turn off react/prop-types * temporarily turn off react-hooks/exhaustive-deps add note that it will be turned back on and fixed in next PR * fix unused import errors after rebase to dev * fix more new prettier errors * turn react/no-unescaped-entities eslint rule off * address PR comment about useReducer * remove includeTemplateGroup from src/components/AlertTemplates/AlertTemplatesForm.helper.tsx * update arg typing for refreshPageError * update handleSyncException typing * fix strict equality in containers/IntegrationSettings/parts/Autoresolve.tsx * enhance typing in components/AlertTemplates/AlertTemplatesForm.tsx * revert small change per Maxim's comment
2022-10-24 14:27:03 +02:00
rev: v8.25.0
hooks:
- id: eslint
entry: bash -c "cd grafana-plugin && eslint --max-warnings=20 --fix ${@/grafana-plugin\//}" --
types: [file]
files: ^grafana-plugin/src/(?:(?!autogenerated).)*\.(js|jsx|ts|tsx)$
additional_dependencies:
[UI] fix eslint/prettier warnings (#678) * UI spring cleaning - fix ~570 outstanding eslint warnings - make eslint force user to correct warnings - remove .css files that are not referenced - remove dummy.tsx as it is not consumed anywhere - remove a few functions that were "dead code" (ie. not consumed anywhere) - remove commented out blocks of code that had no explanatory comments surrounding them * add prettier to pre-commit configuration * change ignoreRestSiblings to true we have a few spots in the codebase where we destructure an object key and then use something like ...restProps setting this to true allows that * upgrade from eslint 7.21.0 to 8.25.0 - add @grafana/eslint-config to dev dependencies and pre-commit eslint deps - add @grafana/eslint-config peer dependencies to package.json * fix remaining outstanding prettier warnings * enable noUnusedLocals and noUnusedParameters and fix errors related to this * make pre-commit complain about eslint warnings * import from moment-timezone instead of moment * fix react/display-name eslint warning * add eslint-plugin-react-hooks to dev deps this is a peer dependency from @grafana/eslint-config * turn off react/prop-types * temporarily turn off react-hooks/exhaustive-deps add note that it will be turned back on and fixed in next PR * fix unused import errors after rebase to dev * fix more new prettier errors * turn react/no-unescaped-entities eslint rule off * address PR comment about useReducer * remove includeTemplateGroup from src/components/AlertTemplates/AlertTemplatesForm.helper.tsx * update arg typing for refreshPageError * update handleSyncException typing * fix strict equality in containers/IntegrationSettings/parts/Autoresolve.tsx * enhance typing in components/AlertTemplates/AlertTemplatesForm.tsx * revert small change per Maxim's comment
2022-10-24 14:27:03 +02:00
- eslint@^8.25.0
- eslint-plugin-import@^2.25.4
- eslint-plugin-rulesdir@^0.2.1
- eslint-plugin-unused-imports@^3.1.0
[UI] fix eslint/prettier warnings (#678) * UI spring cleaning - fix ~570 outstanding eslint warnings - make eslint force user to correct warnings - remove .css files that are not referenced - remove dummy.tsx as it is not consumed anywhere - remove a few functions that were "dead code" (ie. not consumed anywhere) - remove commented out blocks of code that had no explanatory comments surrounding them * add prettier to pre-commit configuration * change ignoreRestSiblings to true we have a few spots in the codebase where we destructure an object key and then use something like ...restProps setting this to true allows that * upgrade from eslint 7.21.0 to 8.25.0 - add @grafana/eslint-config to dev dependencies and pre-commit eslint deps - add @grafana/eslint-config peer dependencies to package.json * fix remaining outstanding prettier warnings * enable noUnusedLocals and noUnusedParameters and fix errors related to this * make pre-commit complain about eslint warnings * import from moment-timezone instead of moment * fix react/display-name eslint warning * add eslint-plugin-react-hooks to dev deps this is a peer dependency from @grafana/eslint-config * turn off react/prop-types * temporarily turn off react-hooks/exhaustive-deps add note that it will be turned back on and fixed in next PR * fix unused import errors after rebase to dev * fix more new prettier errors * turn react/no-unescaped-entities eslint rule off * address PR comment about useReducer * remove includeTemplateGroup from src/components/AlertTemplates/AlertTemplatesForm.helper.tsx * update arg typing for refreshPageError * update handleSyncException typing * fix strict equality in containers/IntegrationSettings/parts/Autoresolve.tsx * enhance typing in components/AlertTemplates/AlertTemplatesForm.tsx * revert small change per Maxim's comment
2022-10-24 14:27:03 +02:00
- "@grafana/eslint-config@^5.0.0"
- eslint-plugin-promise@^6.1.1
[UI] fix eslint/prettier warnings (#678) * UI spring cleaning - fix ~570 outstanding eslint warnings - make eslint force user to correct warnings - remove .css files that are not referenced - remove dummy.tsx as it is not consumed anywhere - remove a few functions that were "dead code" (ie. not consumed anywhere) - remove commented out blocks of code that had no explanatory comments surrounding them * add prettier to pre-commit configuration * change ignoreRestSiblings to true we have a few spots in the codebase where we destructure an object key and then use something like ...restProps setting this to true allows that * upgrade from eslint 7.21.0 to 8.25.0 - add @grafana/eslint-config to dev dependencies and pre-commit eslint deps - add @grafana/eslint-config peer dependencies to package.json * fix remaining outstanding prettier warnings * enable noUnusedLocals and noUnusedParameters and fix errors related to this * make pre-commit complain about eslint warnings * import from moment-timezone instead of moment * fix react/display-name eslint warning * add eslint-plugin-react-hooks to dev deps this is a peer dependency from @grafana/eslint-config * turn off react/prop-types * temporarily turn off react-hooks/exhaustive-deps add note that it will be turned back on and fixed in next PR * fix unused import errors after rebase to dev * fix more new prettier errors * turn react/no-unescaped-entities eslint rule off * address PR comment about useReducer * remove includeTemplateGroup from src/components/AlertTemplates/AlertTemplatesForm.helper.tsx * update arg typing for refreshPageError * update handleSyncException typing * fix strict equality in containers/IntegrationSettings/parts/Autoresolve.tsx * enhance typing in components/AlertTemplates/AlertTemplatesForm.tsx * revert small change per Maxim's comment
2022-10-24 14:27:03 +02:00
# - repo: https://github.com/pre-commit/mirrors-prettier
# rev: "v2.7.1"
# hooks:
# - id: prettier
# name: prettier
# types_or: [css, javascript, jsx, ts, tsx]
# files: ^grafana-plugin/src
# additional_dependencies:
# - prettier@2.8.2
# - id: prettier
# name: prettier - json
# types_or: [json]
# additional_dependencies:
# - prettier@2.8.2
- repo: https://github.com/thibaudcolas/pre-commit-stylelint
rev: v13.13.1
hooks:
- id: stylelint
entry: bash -c "cd grafana-plugin && stylelint --fix ${@/grafana-plugin\//}" --
types: [file]
files: ^grafana-plugin/src/.*\.css$
additional_dependencies:
- stylelint@^13.13.1
[UI] fix eslint/prettier warnings (#678) * UI spring cleaning - fix ~570 outstanding eslint warnings - make eslint force user to correct warnings - remove .css files that are not referenced - remove dummy.tsx as it is not consumed anywhere - remove a few functions that were "dead code" (ie. not consumed anywhere) - remove commented out blocks of code that had no explanatory comments surrounding them * add prettier to pre-commit configuration * change ignoreRestSiblings to true we have a few spots in the codebase where we destructure an object key and then use something like ...restProps setting this to true allows that * upgrade from eslint 7.21.0 to 8.25.0 - add @grafana/eslint-config to dev dependencies and pre-commit eslint deps - add @grafana/eslint-config peer dependencies to package.json * fix remaining outstanding prettier warnings * enable noUnusedLocals and noUnusedParameters and fix errors related to this * make pre-commit complain about eslint warnings * import from moment-timezone instead of moment * fix react/display-name eslint warning * add eslint-plugin-react-hooks to dev deps this is a peer dependency from @grafana/eslint-config * turn off react/prop-types * temporarily turn off react-hooks/exhaustive-deps add note that it will be turned back on and fixed in next PR * fix unused import errors after rebase to dev * fix more new prettier errors * turn react/no-unescaped-entities eslint rule off * address PR comment about useReducer * remove includeTemplateGroup from src/components/AlertTemplates/AlertTemplatesForm.helper.tsx * update arg typing for refreshPageError * update handleSyncException typing * fix strict equality in containers/IntegrationSettings/parts/Autoresolve.tsx * enhance typing in components/AlertTemplates/AlertTemplatesForm.tsx * revert small change per Maxim's comment
2022-10-24 14:27:03 +02:00
- stylelint-prettier@^2.0.0
- stylelint-config-standard@^22.0.0
[UI] fix eslint/prettier warnings (#678) * UI spring cleaning - fix ~570 outstanding eslint warnings - make eslint force user to correct warnings - remove .css files that are not referenced - remove dummy.tsx as it is not consumed anywhere - remove a few functions that were "dead code" (ie. not consumed anywhere) - remove commented out blocks of code that had no explanatory comments surrounding them * add prettier to pre-commit configuration * change ignoreRestSiblings to true we have a few spots in the codebase where we destructure an object key and then use something like ...restProps setting this to true allows that * upgrade from eslint 7.21.0 to 8.25.0 - add @grafana/eslint-config to dev dependencies and pre-commit eslint deps - add @grafana/eslint-config peer dependencies to package.json * fix remaining outstanding prettier warnings * enable noUnusedLocals and noUnusedParameters and fix errors related to this * make pre-commit complain about eslint warnings * import from moment-timezone instead of moment * fix react/display-name eslint warning * add eslint-plugin-react-hooks to dev deps this is a peer dependency from @grafana/eslint-config * turn off react/prop-types * temporarily turn off react-hooks/exhaustive-deps add note that it will be turned back on and fixed in next PR * fix unused import errors after rebase to dev * fix more new prettier errors * turn react/no-unescaped-entities eslint rule off * address PR comment about useReducer * remove includeTemplateGroup from src/components/AlertTemplates/AlertTemplatesForm.helper.tsx * update arg typing for refreshPageError * update handleSyncException typing * fix strict equality in containers/IntegrationSettings/parts/Autoresolve.tsx * enhance typing in components/AlertTemplates/AlertTemplatesForm.tsx * revert small change per Maxim's comment
2022-10-24 14:27:03 +02:00
- stylelint-config-prettier@^9.0.3
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.32.2
hooks:
- id: markdownlint
name: markdownlint
entry: >
markdownlint --fix --ignore grafana-plugin/node_modules --ignore grafana-plugin/dist --ignore docs **/*.md
- id: markdownlint
Update all links to use `docs/reference` style (#2456) # What this PR does The `docs/reference` shortcode supports contextual destinations and version inference. `<ONCALL VERSION>` is inferred to match the version of the documentation set. For example, the inferred version for the page /docs/grafana/oncall/latest/get-started/ is "latest". It can also be overriden using front matter. Given the same page, but with the additional front matter `oncall_version: next`, the variable is substituted with "next" rather than "latest". Contextual destinations are achieved using repeated labels in the shortcode inner text. The format is [<LABEL>]: "<PAGE PATH PREFIX> -> <HUGO REFERENCE>". - _`<LABEL>`_ matches the reference style link label used in the rest of the text. - _`<PAGE PATH PREFIX>`_ is matched against the page during the production build. If the match is successful, the destination that is used is _`<HUGO REFERENCE>`_. The first matching prefix is used, not the longest matching prefix. ## Which issue(s) this PR fixes - Broken links due to ambiguous relref resolution. Any relref parameter that does not start with either `/`, `./`, or `../` can resolve ambiguously and is resulting in broken link behavior on the current site. - Broken links in Grafana Cloud. We mount OnCall documentation in Grafana Cloud. In https://github.com/grafana/website/pull/13872 the location will become /docs/grafana-cloud/alerting-and-irm/oncall. This PR is intended to be merged alongside that PR. --------- Signed-off-by: Jack Baldry <jack.baldry@grafana.com> Co-authored-by: Joey Orlando <joey.orlando@grafana.com>
2023-07-13 15:38:35 +01:00
name: markdownlint - docs/sources
entry: markdownlint --fix --ignore README.md -c ./docs/.markdownlint.json ./docs/sources/**/*.md
- repo: https://github.com/adrienverge/yamllint
rev: v1.32.0
hooks:
- id: yamllint
name: yamllint
entry: yamllint -c .yamllint.yml
types: [yaml]