astronomer / astronomer-airflow-version-check

Plugin to check if new version of Astronomer Certified Airflow is available
Apache License 2.0
1 stars 2 forks source link

Add pre-commit #35

Closed ephraimbuddy closed 2 years ago

ephraimbuddy commented 2 years ago

Following the error I'm getting from another PR which is related to flake8, it makes sense to add pre-commit to help check errors before commits

uranusjr commented 2 years ago

Maybe add a CI job to enforce pre-commit as well?

ephraimbuddy commented 2 years ago

We should cache the pre-commit env as shown in this example https://pre-commit.com/#circleci-example

The example you linked is using https://pre-commit.ci/ which I think is a paid service from what they mentioned on the link. I think we should do with using our normal pre-commit and because we used this only on that step, I think we can get away without caching?

ephraimbuddy commented 2 years ago

We should cache the pre-commit env as shown in this example https://pre-commit.com/#circleci-example

The example you linked is using https://pre-commit.ci/ which I think is a paid service from what they mentioned on the link. I think we should do with using our normal pre-commit and because we used this only on that step, I think we can get away without caching?

It's mentioned here on the benefits: https://pre-commit.com/#pre-commitci-example

kaxil commented 2 years ago

We should cache the pre-commit env as shown in this example https://pre-commit.com/#circleci-example

The example you linked is using https://pre-commit.ci/ which I think is a paid service from what they mentioned on the link. I think we should do with using our normal pre-commit and because we used this only on that step, I think we can get away without caching?

It's mentioned here on the benefits: https://pre-commit.com/#pre-commitci-example

You can use it without pre-commit.ci too --- check https://github.com/astronomer/astro-runtime/blob/main/.circleci/jobs/static-checks.yml#L5-L21

ashb commented 2 years ago
  steps:
  - run:
    command: |
      cp .pre-commit-config.yaml pre-commit-cache-key.txt
      python --version --version >> pre-commit-cache-key.txt
  - restore_cache:
    keys:
    - v1-pc-cache-{{ checksum "pre-commit-cache-key.txt" }}
  - run:
    command: |
      pre-commit run --diff-on-failure --all-files
  - save_cache:
    key: v1-pc-cache-{{ checksum "pre-commit-cache-key.txt" }}
    paths:
      - ~/.cache/pre-commit

give or take.

No pre-commit.ci needed.