pre-commit-ci / issues

public issues for https://pre-commit.ci
16 stars 3 forks source link

Feature request: PRE_COMMIT_CI=true env var #109

Closed sirosen closed 2 years ago

sirosen commented 2 years ago

I have a hook which makes HTTP requests. In pre-commit.ci, that would fail, so I've defined a "failover" behavior. It would be better to avoid using the network at all in this case.

To detect that a hook is running in pre-commit.ci, it would be handy to have an env var that I can check.

asottile commented 2 years ago

it's an intentional design that it's not differentiable from a local run. if you want to skip hooks I'd recommend using the skip functionality

sirosen commented 2 years ago

it's an intentional design that it's not differentiable from a local run.

Understood! I'm not bothered by this. It forces me to handle the offline case, which is a good thing anyway.

I was trying to figure out from the docs how to do this because vars like CI=true are common for generalized CI systems. If you get other inquiries like this, it might be nice to add an FAQ page or section to the docs. But don't do it on my account!

As always, thanks for all your efforts!

asottile commented 2 years ago

it's an intentional design that it's not differentiable from a local run.

Understood! I'm not bothered by this. It forces me to handle the offline case, which is a good thing anyway.

I was trying to figure out from the docs how to do this because vars like CI=true are common for generalized CI systems. If you get other inquiries like this, it might be nice to add an FAQ page or section to the docs. But don't do it on my account!

As always, thanks for all your efforts!

the image is listed in each run -- you can run that image locally

asottile commented 2 years ago

the easiest way to simulate no-network is with docker and --net=none