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

Adapt examples to be recognised as such by Cargo #147

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

WhyNotHugo
Copy link
Contributor

@WhyNotHugo WhyNotHugo commented Jun 26, 2023

Currently examples are binary modules inside the workspace. As a result, these are not treated as examples by cargo, e.g.:

> cargo run --example
error: "--example" takes one argument.
No examples available.

This patch moves files around a bit so that examples are actually recognised as such by cargo. This has a few effects:

  • cargo test will ensure that they compile.
  • They will share the lock file with the main project. This ensure that their dependencies are aligned and avoids potentially downloading and compiling multiple different versions of the same dependency.
  • cargo run --example provides useful output:
> cargo run --example
error: "--example" takes one argument.
Available examples:
    editor-libcosmic
    editor-orbclient
    editor-test
    rich-text
    terminal

Depending on the shell's setup, shell completion may also be available when using cargo run --example.

Currently examples are binary modules inside the workspace. As a result,
these are not treated as examples by cargo, e.g.:

    > cargo run --example
    error: "--example" takes one argument.
    No examples available.

This patch moves files around a bit so that examples are actually
recognised as such by cargo. This has a few effects:

* `cargo test` will ensure that they compile.
* They will share the lock file with the main project. This ensure that
  their dependencies are aligned and avoids potentially downloading and
  compiling multiple different versions of the same dependency.
* `cargo run --example` provides useful output:

    > cargo run --example
    error: "--example" takes one argument.
    Available examples:
        editor-libcosmic
        editor-orbclient
        editor-test
        rich-text
        terminal

Depending on the shell's setup, shell completion may also be available
when using `cargo run --example`.
@WhyNotHugo
Copy link
Contributor Author

CI seems to be failing because some of the dependencies used by examples have licenses that are not explicitly allowed: BSD-3-Clause, Apache-2.0, BSL-1.0, BSD-2-Clause, ISC, MIT, OFL-1.1.

I guess that the previous setup wasn't checking all licences correctly? Note that these are now development dependencies, not dependencies that are built into the crate itself.

@notgull
Copy link
Contributor

notgull commented Jul 21, 2023

-1 to this. Some of these examples have crates with deep dependency trees, and including those in every dev compilation would slow down my own development time.

@WhyNotHugo
Copy link
Contributor Author

WhyNotHugo commented Jul 21, 2023 via email

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.

None yet

2 participants