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

Add try parse ini #506

Closed
wants to merge 34 commits into from
Closed

Conversation

mfirhas
Copy link

@mfirhas mfirhas commented Dec 15, 2023

Nested configs from .ini file cannot be converted automatically into struct's field types.

Add parsing for nested .ini file format.

kesyog and others added 30 commits August 2, 2022 16:32
* Attempt to convert between integer types using `TryInto`-based
conversions rather than blanket failing for some source and
destination types.
* Use `into_uint` instead of `into_int` in `Value` Deserialize
implementations for unsigned integer types. Previously, we were
converting from signed types to unsigned types using `as`, which can
lead to surprise integer values conversions (rust-cli#93).

Fixes rust-cli#352 and rust-cli#93

(cherry picked from commit 7db2e8b)
Signed-off-by: Matthias Beyer <[email protected]>
Signed-off-by: Xuanwo <[email protected]>
Signed-off-by: Matthias Beyer <[email protected]>
(cherry picked from commit 33df8d1)
I am not sure what happened that these tests suddenly fail, or where the
artifact comes from...

Signed-off-by: Matthias Beyer <[email protected]>
(cherry picked from commit 518a3ca)
Signed-off-by: Matthias Beyer <[email protected]>
Signed-off-by: Matthias Beyer <[email protected]>
This patch reverts the matrix for the clippy job to only run clippy on
our MSRV instead of stable, beta and nightly.

The recurring issue with this was that lints started failing in PRs that
couldn't have been fixed in master yet, because master was never tested
with a clippy that new (in case of nightly).

1.56.1 is good enough for now.

Signed-off-by: Matthias Beyer <[email protected]>
(cherry picked from commit 336a34e)
Signed-off-by: Matthias Beyer <[email protected]>
(cherry picked from commit d54986c)
Signed-off-by: Matthias Beyer <[email protected]>
Replace use of deprecated function with Utc.with_ymd_and_hms().

Signed-off-by: Matthias Beyer <[email protected]>
(cherry picked from commit 5d9cb27)
Signed-off-by: Matthias Beyer <[email protected]>
(cherry picked from commit 02c80a5)
Signed-off-by: Matthias Beyer <[email protected]>
Backport 379: Add clone trait to builder state
Signed-off-by: Matthias Beyer <[email protected]>
Signed-off-by: Matthias Beyer <[email protected]>
This is not so trivial.  In theory,
    cargo +nightly update -Z minimal-versions generate-lockfile
ought to work.

However, there are rather many places in our dependency tree where
some crate A depends on crate B, version V, but it actually doesn't
build with version V, but requires something considerably newer.
There seemed to be particular problems in the parts of the dependency
graph near "pest".  My attempts at starting with the minimal versions
and upgrading crates as needed, were not successful.

However, I was able to converge reasonably quickly from the other end:
starting with the lockfile generated by 1.59, using recent versions,
and then repeatedly downgrading crates whose (actual, or declared)
MSRV was too high.

I used the following recipe on 2023-10-24 to generates this lockfile:
    Bump Tokio dependency to 1.29 in Cargo.toml
    cargo +1.59 generate-lockfile
    cargo +nightly update -Z minimal-versions -p linux-raw-sys
    cargo +nightly update -Z minimal-versions -p tokio
    cargo +nightly update -Z minimal-versions -p rustix
    cargo +nightly update -Z minimal-versions -p tempfile
    cargo +nightly update -Z minimal-versions -p reqwest
    cargo +nightly update -Z minimal-versions -p byteorder
    cargo +nightly update -Z minimal-versions -p h2
    cargo +nightly update -Z minimal-versions -p log
    cargo +nightly update -Z minimal-versions -p tokio
    cargo +nightly update -Z minimal-versions -p [email protected]
    Discard the Tokio dependency update

So that is what we commit here.

This is unprincipled, and the recipe above has already rotted by
2023-11-06.  In the future (especially on the mainline) we can
hopefully have a more principled approach.

Signed-off-by: Ian Jackson <[email protected]>
This will prevent our CI breaking due to updates to our dependencies.

Because of the way the msrv.yml file is constructed, it was not
straightforward to use the committed lockfile only for the MSRV tests.

It would be better to use a different lockfile, with latest versions
of our dependencies, for non-MSRV tests.

Signed-off-by: Ian Jackson <[email protected]>
[release-0.13.x] fix(CI): Add `Cargo.lock.msrv` for CI tests
- Slight adjustments to the version fields for compatibility with
  `cargo +nightly update -Z direct-minimal-versions` for MSRV `1.56.0`
- Add `rust-version` field for leveraging 
  `cargo +nightly update -Z msrv-policy` to generate a lockfile that
  respects the MSRV, and the benefit of downstreams.
- Communicate why `dev-dependencies` are required (examples / tests).
- Avoid repeating deps in `dev-dependencies`.
- Raise fixed `warp` dev dep to a MSRV compatible version with common
  `tokio-util` implicit dep. Simplifies CI lock maintenance.

Signed-off-by: Brennan Kinney <[email protected]>
- Reduces multi-versioned deps
- Now compatible with Rust 1.56.1

Lock file was created with:

```bash
cargo +nightly update -Z msrv-policy
cargo update --package memchr --precise 2.5.0
cargo update --package ordered-multimap --precise 0.4.0
cargo update --package tokio-util --precise 0.7.8
```

Signed-off-by: Brennan Kinney <[email protected]>
- Previously raised to `1.59.0` for CI to pass.
- With an MSRV lock file committed this is no longer necessary.

Signed-off-by: Brennan Kinney <[email protected]>
Have all the various versions of sequences (arrays and various forms
of tuple) all go via ser::SerializeSeq.

This reduces some duplication.  And, we're about to change the
implementation.

Signed-off-by: Ian Jackson <[email protected]>
(cherry picked from commit ed6a3c9)
Signed-off-by: Ian Jackson <[email protected]>
We're going to want to do something more complicated.

In particular, to handle nested arrays properly, we need to do some
work at the start and end of each array.

The `new` and (inherent) `end` methods of this newtype is where that
work will be done.

Signed-off-by: Ian Jackson <[email protected]>
(cherry picked from commit 147e6c7)
Signed-off-by: Ian Jackson <[email protected]>
Change the representation of our "current location".  Previously it
was a list of increasingly-long full paths, but excepting the putative
final array index.

Now we just record the individual elements. and assemble the whole
path just before calling .set().  This saves a little memory on the
whole since the entries in keys are now a bit shorter.

It is much less confusing.  (There are perhaps still further
opportunities to use Rust's type system to better advantage to
eliminuate opportunities for bugs.)

Arrays that appear other than at the top level are now handled
correctly.  This includes nested arrays, and arrays containing
structs, etc.

Signed-off-by: Ian Jackson <[email protected]>
(cherry picked from commit 831102f)
Signed-off-by: Ian Jackson <[email protected]>
Signed-off-by: Ian Jackson <[email protected]>
(cherry picked from commit aa63d2d)
Signed-off-by: Ian Jackson <[email protected]>
[release-0.13.x] chore(Cargo.toml): Better document direct deps
Fix nested arrays (by reworking array handling) - backport
Signed-off-by: Matthias Beyer <[email protected]>
matthiasbeyer and others added 4 commits November 22, 2023 07:46
Signed-off-by: Matthias Beyer <[email protected]>
Parse non-string from env/ini file into the types
Copy link
Collaborator

@polarathene polarathene left a comment

Choose a reason for hiding this comment

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

This PR is carrying over changes from the 0.13.x branch unrelated to the actual PR intent 👎

The related issue #504 (comment) has been identified as not something that should try to be fixed in file/format/ini.rs, as a fix for one problem would introduce a regression that can affect others.

PR should not be merged.

@matthiasbeyer
Copy link
Member

PR should not be merged.

Agreed.

@mfirhas
Copy link
Author

mfirhas commented Dec 18, 2023

@polarathene Sorry for the inconvenient. I branched out from 0.13.4 in my fork, because that's work for me in my test like I explained in the issue, I though there are unmerged commits here related to the issue I explained. I though all the commits in release tags should be in master(I assume master is the most stable), turned out it should be cherry-picked.

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.

7 participants