-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Environment variables from rc file are not available in command run and skip run #877
Comments
Hey @pschirch ! Does it work when you're running Git hooks? Is it important for you to have this |
Hey @mrexox ! Yap, running git hook by IDE triggers The
Yes. We use It is possible to extend Thank you in advance. |
I have a bit different angle issue but perhaps similar. The environment variables are not extendable by the local configuration. Let's say I have a hook configuration: # hooks/mylefthook/.lefthook.yaml
---
mylefthook:
commands:
test:
env:
TEST_ENV: 1.0.0
run: |
echo ${TEST_ENV} and the local configuration: # .lefthook-local.yaml
---
extends:
- hooks/mylefthook/.lefthook.yaml
mylefthook:
commands:
test:
env:
TEST_ENV: 1.0.1 The command fails: lefthook run mylefthook --commands test --file main.tf
╭──────────────────────────────────────╮
│ 🥊 lefthook v1.6.7 hook: mylefthook │
╰──────────────────────────────────────╯
┃ test ❯
1.0.0
────────────────────────────────────
summary: (done in 0.01 seconds)
✔️ test I've tried various methods such as using references or !!merge: ---
test_env: &test_env 1.0.0
mylefthook:
commands:
test:
env:
TEST_ENV: *test_env
run: |
echo ${TEST_ENV}
# .lefthook-local.yaml
extends:
- hooks/mylefthook/.lefthook.yaml
test_env: 1.0.1 but that way also won't work. My initial goals was to distribute one single environment across all the commands in that single hook/namespace i.e.: mylefthook:
# this way I define the global variables and I can use across all my commands in this namespace
env:
TEST_ENV: 1.0.0
commands:
test:
run: |
echo ${TEST_ENV}
# .lefthook-local.yaml
extends:
- hooks/mylefthook/.lefthook.yaml
mylefthook:
env:
TEST_ENV: 1.0.1 |
@doniz , please update to the latest lefthook (1.10.10). I've changed the parser in 1.9.0, and this must fix the issue |
Lefthook wraps each command with a I'm not ready to change the behavior right now, but I will have it on my radar. |
🔧 Summary
We use an environment variable based tool stack. So it should be possible to skip specific lefthook commands by configure an environment variable, e.q.
SOME_CHECK_ENABLED
. We read aboutrc:
in docs and found our use case:Furthermore, based on the consumption that
rc:
exports all environment variables from an.env
file, it should be possible to useskip
from docs to skip a command like:I hope my explanations are sufficient. I am grateful for any advice.
Lefthook version
1.8.4
Steps to reproduce
.env
lefthook.rc
We also test
and
lefthook.yaml
lefthook install --force && lefthook --verbose run some-framework
Expected results
The environment variable
SOME_CHECK_ENABLED
processed in rc filelefthook.rc
should be available in command'ssome:check
skip run
to made the skip test.Furthermore, the command's
some:check
run
should also aware of these environment variables.Change command
some:check
run torun: env
for a test.Actual results
The environment variable
SOME_CHECK_ENABLED
is not available, theskip
test fails and the commandsome:check
will be executed.Possible Solution
Less a solution, more a workaround.
Source
. "$(cd "$(dirname "$0")" && pwd)/.env"
inskip run
every time.Logs / Screenshots
The text was updated successfully, but these errors were encountered: