Skip to content

Auto-normalize versions in input flags and from parsing of indexes. #2108

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

Closed
wants to merge 2 commits into from

Conversation

cmaglie
Copy link
Member

@cmaglie cmaglie commented Mar 14, 2023

Please check if the PR fulfills these requirements

See how to contribute

  • The PR has no duplicates (please search among the Pull Requests
    before creating one)
  • The PR follows
    our contributing guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • UPGRADING.md has been updated with a migration guide (for breaking changes)
  • configuration.schema.json updated if new parameters are added.

What kind of change does this PR introduce?

The versions parsed from command input flags and JSON indexes are now automatically "normalized", i.e. 2.0 is automatically converted to 2.0.0.

What is the current behavior?

Sometimes there are discrepancies from the command output and the accepted command input, as described in detail in #1727.

$ ./arduino-cli lib install [email protected]
Downloading [email protected]...
Installing [email protected]...
Installed [email protected]
$ ./arduino-cli lib list --format json                      
[
  {
    "library": {
      "name": "ILI9341_t3",
      "author": "Limor Fried, Adafruit, Paul Stoffregen",
      "maintainer": "Paul Stoffregen",
      "sentence": "Optimized ILI9341 (320x240 Color TFT) Display",
      "website": "https://github.com/PaulStoffregen/ILI9341_t3",
      "category": "Display",
      "architectures": [
        "*"
      ],
      "install_dir": "/Users/a.kitta/Documents/Arduino/libraries/ILI9341_t3",
      "source_dir": "/Users/a.kitta/Documents/Arduino/libraries/ILI9341_t3",
      "real_name": "ILI9341_t3",
      "version": "1.0",              <----- listed as "1.0"
      "license": "Unspecified",
      "location": 1,
      "provides_includes": [
        "ILI9341_t3.h"
      ]
    }
  }
]
$ ./arduino-cli lib install "ILI9341_t3"@1.0               <--- did not accept "1.0"
Error installing ILI9341_t3: Library '[email protected]' not found

What is the new behavior?

$ ./arduino-cli lib install [email protected]
Downloading [email protected]...
Installing [email protected]...
Installed [email protected]
$ ./arduino-cli lib list --format json                      
[
  {
    "library": {
      "name": "ILI9341_t3",
      "author": "Limor Fried, Adafruit, Paul Stoffregen",
      "maintainer": "Paul Stoffregen",
      "sentence": "Optimized ILI9341 (320x240 Color TFT) Display",
      "website": "https://github.com/PaulStoffregen/ILI9341_t3",
      "category": "Display",
      "architectures": [
        "*"
      ],
      "install_dir": "/Users/a.kitta/Documents/Arduino/libraries/ILI9341_t3",
      "source_dir": "/Users/a.kitta/Documents/Arduino/libraries/ILI9341_t3",
      "real_name": "ILI9341_t3",
      "version": "1.0.0",
      "license": "Unspecified",
      "location": 1,
      "provides_includes": [
        "ILI9341_t3.h"
      ]
    }
  }
]
$ ./arduino-cli lib install [email protected]
Already installed [email protected]

Does this PR introduce a breaking change, and is titled accordingly?

The change should be backward compatible.

Other information

Fix #1727

It is based on bugst/relaxed-semver#11, it should be merged before this one and the go.mod file updated accordingly.

@cmaglie cmaglie self-assigned this Mar 14, 2023
@cmaglie cmaglie added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project labels Mar 14, 2023
@cmaglie cmaglie force-pushed the normalize_versions branch from 172cd90 to dc8b452 Compare March 14, 2023 16:28
@cmaglie cmaglie marked this pull request as draft March 14, 2023 16:38
@cmaglie
Copy link
Member Author

cmaglie commented Mar 14, 2023

Ok, looks like it's not so simple:

    debug_test.go:70: 
        	Error Trace:	/home/runner/work/arduino-cli/arduino-cli/commands/debug/debug_test.go:70
        	Error:      	Not equal: 
        	            	expected: "/home/runner/work/arduino-cli/arduino-cli/commands/debug/testdata/data_dir/packages/arduino-test/tools/arm-none-eabi-gcc/7-2017q4/bin/arm-none-eabi-gdb --interpreter=console -ex set remotetimeout 5 -ex target extended-remote | \"/home/runner/work/arduino-cli/arduino-cli/commands/debug/testdata/data_dir/packages/arduino-test/tools/openocd/0.10.0-arduino7/bin/openocd\" -s \"/home/runner/work/arduino-cli/arduino-cli/commands/debug/testdata/data_dir/packages/arduino-test/tools/openocd/0.10.0-arduino7/share/openocd/scripts/\" --file \"/home/runner/work/arduino-cli/arduino-cli/commands/debug/testdata/custom_hardware/arduino-test/samd/variants/arduino_zero/openocd_scripts/arduino_zero.cfg\" -c \"gdb_port pipe\" -c \"telnet_port 0\" /home/runner/work/arduino-cli/arduino-cli/commands/debug/testdata/hello/build/arduino-test.samd.arduino_zero_edbg/hello.ino.elf"
        	            	actual  : "{runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/arm-none-eabi-gdb --interpreter=console -ex set remotetimeout 5 -ex target extended-remote | \"/home/runner/work/arduino-cli/arduino-cli/commands/debug/testdata/data_dir/packages/arduino-test/tools/openocd/0.10.0-arduino7/bin/openocd\" -s \"/home/runner/work/arduino-cli/arduino-cli/commands/debug/testdata/data_dir/packages/arduino-test/tools/openocd/0.10.0-arduino7/share/openocd/scripts/\" --file \"/home/runner/work/arduino-cli/arduino-cli/commands/debug/testdata/custom_hardware/arduino-test/samd/variants/arduino_zero/openocd_scripts/arduino_zero.cfg\" -c \"gdb_port pipe\" -c \"telnet_port 0\" /home/runner/work/arduino-cli/arduino-cli/commands/debug/testdata/hello/build/arduino-test.samd.arduino_zero_edbg/hello.ino.elf"

The effect of "normalize-everything" is more disruptive than expected, it seems we have to keep the relaxed version otherwise the properties {runtime.tools.arm-none-eabi-gcc-7-2017q4.path} will fail to resolve.

I'll look for another solution...

@cmaglie cmaglie closed this Mar 14, 2023
@cmaglie cmaglie deleted the normalize_versions branch March 14, 2023 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lib list/core list might list the library/platform versions in a non-semver compliant way
1 participant