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

implement "minDubVersion" field #1532

Merged
merged 9 commits into from
Oct 2, 2018
Merged

Conversation

rtbo
Copy link
Contributor

@rtbo rtbo commented Aug 18, 2018

see #1531

@dlang-bot
Copy link
Collaborator

Thanks for your pull request and interest in making D better, @rtbo! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the annotated coverage diff directly on GitHub with CodeCov's browser extension
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Copy link
Member

@WebFreak001 WebFreak001 left a comment

Choose a reason for hiding this comment

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

Looking good, add a changelog entry and imo this can be merged

@WebFreak001
Copy link
Member

let's speed this up a little, I think this is a fairly straightforward change that wouldn't get a lot of negative feedback and formally everything is there: changelog, tests, code

Copy link
Member

@wilzbach wilzbach left a comment

Choose a reason for hiding this comment

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

I like the idea, but please add a real test script for this.

static assert(isValidVersion(dv));

enforce(compareVersions(dv, mdv) >= 0,
"dub-"~dv~" does not comply with minDubVersion specification: "~mdv);
Copy link
Member

Choose a reason for hiding this comment

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

Maybe state something like: "please upgrade your D installation to at least dub X.Y.Z"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

did this:

dub-1.10.0 does not comply with minDubVersion specification: 99.0.0.
Please consider upgrading your dub installation.

@@ -0,0 +1,3 @@
module app;

void main() {}
Copy link
Member

Choose a reason for hiding this comment

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

This test is never run!
It needs a shell test (see the .sh scripts in the test folder).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

run_unittest.sh also iterates the directories under test.
i.e. the package is built and build passes or fail depending on the minDubVersion specified. (checked out a one that passes)

$ DUB=... test/run_unittest.sh
Testing summary:
[INFO]  Building /home/remi/dev/dlang/dub/test/issue1531-min-dub-version/...

Now I guess I can have a script to test for both success and failure.

@@ -0,0 +1,6 @@
Dub now supports a $(D_INLINECODE "minDubVersion") field, that will abort build if
Copy link
Member

Choose a reason for hiding this comment

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

Just using backticks would be fine too...

the user does not have a recent enough version of dub and miss essential feature
to perform the build.
-------
"minDubVersion": "1.10"
Copy link
Member

Choose a reason for hiding this comment

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

minDubVersion can be added to a projects's dub.json:

{
...
    "minDubVersion": "1.10"
...
}

Or the respective dub.sdl:

minDubVersion "1.10"

@wilzbach
Copy link
Member

formally everything is there: changelog, tests, code

No this doesn't get tested at the moment.

@AntonMeep
Copy link
Member

Discussing this in #1021 it got me thinking about minDubVersion. Maybe this is not the best name, since in the (bright) future we would have DMD following semver which will make it possible to add the same version-checking feature for dub and we would want to add minDmdVersion, minLdcVersion, minGdcVersion.

Why don't we use some new namespace for that, for example:

{
  "name": "test",
  ...
  "devDependencies": {
    "dmd": "~>2.81.0",
    "dub": "~>1.10.0"
  }
}

It could be requirements or something like that. Actually, since LDC already follows semver and GDC too (well, when it gets merged into GCC), it could be implemented too.

@wilzbach, @WebFreak001 what's your opinion on that? Otherwise, this PR is fully complete with test and changelog.

@WebFreak001
Copy link
Member

I like the idea but something else than devDependencies would be good. Node already uses it, making it even harder to differentiate between the files if they are called package.json and because they are not actual dependencies but only for checking. requirements would be good as it would also not imply that all dmd, ldc and gdc are required to be installed for the project to build if the project specifies versions for all 3 of them

Copy link
Member

@wilzbach wilzbach left a comment

Choose a reason for hiding this comment

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

LGTM minus:

  • update to the docs (dub-docs)
  • mutation of checked in files (in theory the test suite might stop any second and leave the source directory in a dirty state)

Feel free to merge this once these nits have been addressed.

rm -rf $DIR1531/.dub/
rm -rf $DIR1531/test-application*

sed -i 's/^minDubVersion ".*"$/minDubVersion "1.0"/' ${DIR1531}/dub.sdl
Copy link
Member

Choose a reason for hiding this comment

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

It's not a good idea to mutate files that are checked in the source tree by the testsuite, better put the dub.sdl into a temporary directory.
Also since the last version dub supports passing files in from stdin, so you could use --single plus pass the file in via stdin which would eliminate the need for a temporary directory entirely.


sed -i 's/^minDubVersion ".*"$/minDubVersion "99.0"/' $DIR1531/dub.sdl
! ${DUB} run --root ${DIR1531} || die "Did pass minDubVersion \"99.0\"!"

Copy link
Member

Choose a reason for hiding this comment

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

Maybe a good idea to add one test that works, e.g. with 2.068 or similar?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean by this? I already test for success and for failure.

rtbo added a commit to rtbo/dub-docs that referenced this pull request Sep 30, 2018
@WebFreak001
Copy link
Member

Seems to be good now, will merge if there are no more objections

@wilzbach wilzbach merged commit bb62065 into dlang:master Oct 2, 2018
@PetarKirov
Copy link
Member

I think this change was aiming in the right direction, but it has one significant drawback - it doesn't integrate through the established dependency system.
dmd and dub are build dependencies just like any other package yours depends on, because without all the right versions of all of the above you can't build your package.
Not being able to specify "dub": "~>1.0" means that we won't be able to make a breaking change to dub and release version dub 2.0, since any package with "minDubVersion": "1.10" will happily accept 2.0.

@PetarKirov
Copy link
Member

I mean essentially what @ohdatboi was proposing, but either putting dub, dmd, ldc, etc. next to the other dependencies, or having a separate toolchainDependencies section.

@MartinNowak
Copy link
Member

Compatibility is a reasonable argument for ~> style dependencies.
How about coming up with a PR that implements this instead of minDubVersion?

@rtbo
Copy link
Contributor Author

rtbo commented Oct 6, 2018

I agree with this. We should have this done before the first v1.12 beta is out (in a week or so?), or otherwise have minDubVersion reverted.

@MartinNowak
Copy link
Member

Kudos for taking action on this, was a bit sad to see this leaking into the release. Very glad to see #1571 :).

@wilzbach
Copy link
Member

@MartinNowak this shouldn't be part of the real release anymore as it's reverted: #1581

@rtbo
Copy link
Contributor Author

rtbo commented Oct 25, 2018

This has leaked in changelog and beta1unfortunately.

@wilzbach
Copy link
Member

Yes, and that's not ideal, but it won't be part of the official release and that's what really matters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants