Skip to content
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

env variable lift order requirement. #688

Merged
merged 27 commits into from
Aug 29, 2022

Conversation

indietyp
Copy link
Contributor

@indietyp indietyp commented Aug 6, 2022

This Pull Request adds the ability (when loading) to reorder the environment variables based on usage, removing the requirement that variables need to follow a specific definition order.

Even though this only does the reordering on merge_env.

This change will always be applied because merge_env is called in merge_base_config_and_external_config.

Closes #685

@indietyp
Copy link
Contributor Author

indietyp commented Aug 6, 2022

I'd like to create some acceptance tests. How would I go about doing that?

(I see that a lot of tests has #ignore, so unsure as to how to proceed)

Copy link
Owner

@sagiegurari sagiegurari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow! amazing job and super fast. love it.
gave few comments. i feel this might be a bit risky so lets see if we can try to minimize surprises to existing users.

src/lib/descriptor/mod.rs Outdated Show resolved Hide resolved
src/lib/descriptor/mod.rs Outdated Show resolved Hide resolved
src/lib/descriptor/mod_test.rs Outdated Show resolved Hide resolved
src/lib/descriptor/mod.rs Outdated Show resolved Hide resolved
src/lib/descriptor/mod.rs Outdated Show resolved Hide resolved
@sagiegurari
Copy link
Owner

@indietyp amazing work. i put some comments.
don't worry about the #ignore since cargo-make tests run in 2 phases

  1. all non ignored tests in parallel
  2. all ignored test as single thread (since they may impact each other)
    so ALL tests will run if you just do 'cargo make'

@codecov-commenter
Copy link

codecov-commenter commented Aug 7, 2022

Codecov Report

Merging #688 (7b36d46) into master (5fc673a) will increase coverage by 0.07%.
The diff coverage is 95.34%.

❗ Current head 7b36d46 differs from pull request most recent head 68b3a78. Consider uploading reports for the commit 68b3a78 to get more accurate results

@@            Coverage Diff             @@
##           master     #688      +/-   ##
==========================================
+ Coverage   93.62%   93.69%   +0.07%     
==========================================
  Files         116      118       +2     
  Lines       22408    22619     +211     
==========================================
+ Hits        20980    21194     +214     
+ Misses       1428     1425       -3     
Impacted Files Coverage Δ
src/lib/descriptor/mod_test.rs 99.01% <ø> (+1.90%) ⬆️
src/lib/descriptor/env_test.rs 94.09% <94.09%> (ø)
src/lib/descriptor/env.rs 97.89% <97.89%> (ø)
src/lib/descriptor/mod.rs 87.07% <100.00%> (-0.88%) ⬇️
src/lib/environment/mod_test.rs 96.41% <100.00%> (+0.03%) ⬆️
src/lib/types.rs 89.25% <100.00%> (+0.42%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@indietyp
Copy link
Contributor Author

indietyp commented Aug 8, 2022

I have reworked the section about env variables in the README.md. I just need to add the error-code docs and improve the coverage, and I think that's about it!

@sagiegurari
Copy link
Owner

@indietyp i'll review it again once you resolve the conflicts.
i've released a new version and seems that they conflict with your changes.

@sagiegurari
Copy link
Owner

@indietyp insane work. it will take me time to review it properly.
i did see you wrote a lot in the readme including stuff i was too lazy to write, so thanks a lot. but, the readme is generated from the content.md and nav.md so i'll lose all your great docs :) so you need to move it to there.

I need to understand everything you did there, since i saw logic to understand depends on per type and even for scripts added a new field. i'm for it, but it will just take me time to fully understand all changes there to ensure its ok.

@indietyp
Copy link
Contributor Author

indietyp commented Aug 8, 2022

Yea, I totally get it, thanks for looking into it, I didn't know that the README.md was generated from the content.md, so I will move my new content there. :D

Copy link
Owner

@sagiegurari sagiegurari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@indietyp it looks great.
I wrote few comments, mostly about the docs actually.

src/lib/descriptor/env.rs Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Show resolved Hide resolved
@sagiegurari
Copy link
Owner

@indietyp there are some CI errors to look at. I really want to merge this into the new cargo-make version

@indietyp
Copy link
Contributor Author

@sagiegurari same here, but I wanted to have some clarification: #688 (comment) and have been waiting for an answer.

@sagiegurari
Copy link
Owner

sorry missed it.

docs/_includes/content.md Outdated Show resolved Hide resolved
docs/_includes/content.md Outdated Show resolved Hide resolved
docs/_includes/content.md Outdated Show resolved Hide resolved
@sagiegurari
Copy link
Owner

@indietyp amazing work. only few small comments on the docs. so once done i'll merge it in.
thanks a lot

@indietyp
Copy link
Contributor Author

@sagiegurari what is the current status?

@sagiegurari sagiegurari changed the base branch from master to 0.36.0 August 29, 2022 11:42
@sagiegurari
Copy link
Owner

@indietyp sorry for the delay, i was not available. i'll recheck it.

Copy link
Owner

@sagiegurari sagiegurari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all the comments i put are minor and i can fix myself if you want.
but the biggest issue that i suddenly found (based on the docs you wrote) is that the support for ${env:default} is dropped?
we can't drop that as it will break peoples projects.

@@ -71,6 +71,8 @@ serde_ignored = "^0.1"
serde_json = "^1"
shell2batch = "^0.4.4"
toml = "^0.5"
petgraph = "0.6.2"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please sort crates and add ^ (i know its by default like that, but its more readable coming from other platforms).


> **Note:** The `$variable` syntax is currently not supported!

> **Note:** Extended interpolation like `${variable:-default}` is currently unsupported!
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thats not that good. we will break many makefiles that use this capability.
we can't push this PR with this backward break.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't change anything, just documented the behavior, thought envmnt didn't support default values, will remove if it actually supports it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it be that envmnt supports non-standard interpolation through: :default instead?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@indietyp you are right! it has been so long. envmnt actually supports it so i'll now add it to cargo-make.
so this can be ignored and i'll drop the comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am thinking of creating a new PR to add support for the full range of interpolation as per POSIX spec: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to envmnt? sounds good. let me check that link and we will limit it only to ${var} and not $var right

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep correct!


* [Declaration](#env-declaration)
* [Note about Ordering](#env-note-about-ordering)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feels like this should come as last sub section and not second.

Env files can also be defined globally in the Makefile.toml via **env_files** attribute as follows:
Paths to environment files can also be defined globally in the `env_files` key of the `Makefile.toml`, which will be loaded in the order they are defined. All relative paths are relative to the directory containing the `Makefile.toml` they were defined in.

> **Note:** `env_files` can also be used on a task level. Be aware that relative paths will instead be relative **to the current working directory**
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of
**to the current working directory**
change to
to the **current working directory**

@@ -24,6 +24,8 @@
* [Platform Override](#usage-platform-override)
* [Extend Attribute](#usage-task-extend-attribute)
* [Environment Variables](#usage-env)
* [Declaration](#env-declaration)
* [Note about Ordering](#env-note-about-ordering)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move as last sub section instead of second

@sagiegurari
Copy link
Owner

@indietyp thanks a lot for the PR. I know it has been a long ride :) so sorry about that.
i'll do the minor fixes i wrote in my comments and i've added the ${value:default} capability (its actually already supported in envmnt, just needed to turn it on).

@sagiegurari sagiegurari merged commit f0efd43 into sagiegurari:0.36.0 Aug 29, 2022
@sagiegurari sagiegurari added this to the 0.36.0 milestone Aug 29, 2022
sagiegurari added a commit that referenced this pull request Aug 29, 2022
…t variable to variable dependency more easily #688 (thanks @indietyp)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Env variable interpolation stops working when extending
3 participants