Skip to content

Commit

Permalink
Remove 'run-' prefix from pre-commit jobs (apache#30597)
Browse files Browse the repository at this point in the history
* Remove 'run-' prefix from pre-commit jobs

The job ID already implies 'run', and having the additional prefix
results in weird CLI, e.g. 'pre-commit run run-mypy-core'. This changes
the CLI to 'pre-commit run mypy-core', which reads better.

* Fix table marker

* Fix outdated pre-commit hook ID references
  • Loading branch information
uranusjr authored Apr 12, 2023
1 parent e89a7ee commit 6d1444d
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 89 deletions.
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ repos:
files: ^chart
require_serial: true
additional_dependencies: ['rich>=12.4.4','requests']
- id: run-shellcheck
- id: shellcheck
name: Check Shell scripts syntax correctness
language: docker_image
entry: koalaman/shellcheck:v0.8.0 -x -a
Expand Down Expand Up @@ -893,30 +893,30 @@ repos:
pass_filenames: false
## ADD MOST PRE-COMMITS ABOVE THAT LINE
# The below pre-commits are those requiring CI image to be built
- id: run-mypy-dev
- id: mypy-dev
name: Run mypy for dev
language: python
entry: ./scripts/ci/pre_commit/pre_commit_mypy.py
files: ^dev/.*\.py$
require_serial: true
additional_dependencies: ['rich>=12.4.4', 'inputimeout', 'pyyaml']
- id: run-mypy-core
- id: mypy-core
name: Run mypy for core
language: python
entry: ./scripts/ci/pre_commit/pre_commit_mypy.py --namespace-packages
files: \.py$
exclude: ^.*/.*_vendor/|^airflow/migrations|^airflow/providers|^dev|^docs|^provider_packages|^tests/providers|^tests/system/providers
require_serial: true
additional_dependencies: ['rich>=12.4.4', 'inputimeout', 'pyyaml']
- id: run-mypy-providers
- id: mypy-providers
name: Run mypy for providers
language: python
entry: ./scripts/ci/pre_commit/pre_commit_mypy.py --namespace-packages
files: ^airflow/providers/.*\.py$|^tests/providers/\*\.py$|^tests/system/providers/\*\.py$
exclude: ^.*/.*_vendor/
require_serial: true
additional_dependencies: ['rich>=12.4.4', 'inputimeout', 'pyyaml']
- id: run-mypy-docs
- id: mypy-docs
name: Run mypy for /docs/ folder
language: python
entry: ./scripts/ci/pre_commit/pre_commit_mypy.py
Expand Down
14 changes: 8 additions & 6 deletions BREEZE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -426,33 +426,35 @@ You can run static checks via Breeze. You can also run them via pre-commit comma
Breeze makes it easier to run selective static checks. If you press <TAB> after the static-check and if
you have auto-complete setup you should see auto-completable list of all checks available.

For example, this following command:

.. code-block:: bash
breeze static-checks -t run-mypy
breeze static-checks -t mypy-core
The above will run mypy check for currently staged files.
will run mypy check for currently staged files inside ``airflow/`` excluding providers.

You can also pass specific pre-commit flags for example ``--all-files`` :
You can also pass specific pre-commit flags, such as ``--all-files``:

.. code-block:: bash
breeze static-checks -t run-mypy --all-files
breeze static-checks -t mypy-core --all-files
The above will run mypy check for all files.

There is a convenience ``--last-commit`` flag that you can use to run static check on last commit only:

.. code-block:: bash
breeze static-checks -t run-mypy --last-commit
breeze static-checks -t mypy-core --last-commit
The above will run mypy check for all files in the last commit.

There is another convenience ``--commit-ref`` flag that you can use to run static check on specific commit:

.. code-block:: bash
breeze static-checks -t run-mypy --commit-ref 639483d998ecac64d0fef7c5aa4634414065f690
breeze static-checks -t mypy-core --commit-ref 639483d998ecac64d0fef7c5aa4634414065f690
The above will run mypy check for all files in the 639483d998ecac64d0fef7c5aa4634414065f690 commit.
Any ``commit-ish`` reference from Git will work here (branch, tag, short/long hash etc.)
Expand Down
34 changes: 17 additions & 17 deletions STATIC_CODE_CHECKS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ require Breeze Docker image to be build locally.
benefits of having ``pre-commit`` installed, with some of the checks disabled. In order to disable
checks you might need to set ``SKIP`` environment variable to coma-separated list of checks to skip. For example
when you want to skip some checks (ruff/mypy for example), you should be able to do it by setting
``export SKIP=ruff,run-mypy``. You can also add this to your ``.bashrc`` or ``.zshrc`` if you
``export SKIP=ruff,mypy-core,``. You can also add this to your ``.bashrc`` or ``.zshrc`` if you
do not want to set it manually every time you enter the terminal.

In case you do not have breeze image configured locally, you can also disable all checks that require
Expand Down Expand Up @@ -286,6 +286,14 @@ require Breeze Docker image to be build locally.
+-----------------------------------------------------------+------------------------------------------------------------------+---------+
| mixed-line-ending | Detect if mixed line ending is used (\r vs. \r\n) | |
+-----------------------------------------------------------+------------------------------------------------------------------+---------+
| mypy-core | Run mypy for core | * |
+-----------------------------------------------------------+------------------------------------------------------------------+---------+
| mypy-dev | Run mypy for dev | * |
+-----------------------------------------------------------+------------------------------------------------------------------+---------+
| mypy-docs | Run mypy for /docs/ folder | * |
+-----------------------------------------------------------+------------------------------------------------------------------+---------+
| mypy-providers | Run mypy for providers | * |
+-----------------------------------------------------------+------------------------------------------------------------------+---------+
| pretty-format-json | Format JSON files | |
+-----------------------------------------------------------+------------------------------------------------------------------+---------+
| python-no-log-warn | Check if there are no deprecate log warn | |
Expand All @@ -296,15 +304,7 @@ require Breeze Docker image to be build locally.
+-----------------------------------------------------------+------------------------------------------------------------------+---------+
| ruff | ruff | |
+-----------------------------------------------------------+------------------------------------------------------------------+---------+
| run-mypy-core | Run mypy for core | * |
+-----------------------------------------------------------+------------------------------------------------------------------+---------+
| run-mypy-dev | Run mypy for dev | * |
+-----------------------------------------------------------+------------------------------------------------------------------+---------+
| run-mypy-docs | Run mypy for /docs/ folder | * |
+-----------------------------------------------------------+------------------------------------------------------------------+---------+
| run-mypy-providers | Run mypy for providers | * |
+-----------------------------------------------------------+------------------------------------------------------------------+---------+
| run-shellcheck | Check Shell scripts syntax correctness | |
| shellcheck | Check Shell scripts syntax correctness | |
+-----------------------------------------------------------+------------------------------------------------------------------+---------+
| trailing-whitespace | Remove trailing whitespace at end of line | |
+-----------------------------------------------------------+------------------------------------------------------------------+---------+
Expand Down Expand Up @@ -359,17 +359,17 @@ code. But you can run pre-commit hooks manually as needed.
pre-commit run
- Run only mypy check on your staged files by using:
- Run only mypy check on your staged files (in ``airflow/`` excluding providers) by using:

.. code-block:: bash
pre-commit run run-mypy
pre-commit run mypy-core
- Run only mypy checks on all files by using:

.. code-block:: bash
pre-commit run run-mypy --all-files
pre-commit run mypy-core --all-files
- Run all checks on all files by using:
Expand Down Expand Up @@ -397,7 +397,7 @@ code. But you can run pre-commit hooks manually as needed.

.. code-block:: bash
SKIP=run-mypy,ruff pre-commit run --all-files
SKIP=mypy-core,ruff pre-commit run --all-files
You can always skip running the tests by providing ``--no-verify`` flag to the
Expand All @@ -415,17 +415,17 @@ You run the static code checks via ``breeze static-check`` or commands.
You can see the list of available static checks either via ``--help`` flag or by using the autocomplete
option.

Run the ``mypy`` check for the currently staged changes:
Run the ``mypy`` check for the currently staged changes (in ``airflow/`` excluding providers):

.. code-block:: bash
breeze static-checks --type run-mypy
breeze static-checks --type mypy-core
Run the ``mypy`` check for all files:

.. code-block:: bash
breeze static-checks --type run-mypy --all-files
breeze static-checks --type mypy-core --all-files
Run the ``ruff`` check for the ``tests.core.py`` file with verbose output:

Expand Down
10 changes: 5 additions & 5 deletions dev/breeze/src/airflow_breeze/pre_commit_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,16 @@
"lint-markdown",
"lint-openapi",
"mixed-line-ending",
"mypy-core",
"mypy-dev",
"mypy-docs",
"mypy-providers",
"pretty-format-json",
"python-no-log-warn",
"replace-bad-characters",
"rst-backticks",
"ruff",
"run-mypy-core",
"run-mypy-dev",
"run-mypy-docs",
"run-mypy-providers",
"run-shellcheck",
"shellcheck",
"trailing-whitespace",
"ts-compile-format-lint-www",
"update-black-version",
Expand Down
2 changes: 1 addition & 1 deletion images/breeze/output-commands-hash.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ setup:version:123b462a421884dc2320ffc5e54b2478
setup:56a2ef337c354362760d247df5d05365
shell:ab07ac2d57253e25367a7200ce686703
start-airflow:5e8460ac38f8e9ea2a0ac7e248fd7bc9
static-checks:65a6af27e027ef32f006af03ac4c58c0
static-checks:543f0c776d0f198e80a0f75058445bb2
stop:e5aa686b4e53707ced4039d8414d5cd6
testing:docker-compose-tests:b86c044b24138af0659a05ed6331576c
testing:helm-tests:94a442e7f3f63b34c4831a84d165690a
Expand Down
Loading

0 comments on commit 6d1444d

Please sign in to comment.