japaric / trust

Travis CI and AppVeyor template to test your Rust crate on 5 architectures and publish binary releases of it for Linux, macOS and Windows
Apache License 2.0
1.26k stars 59 forks source link

Expose 'trust_ci' as a feature flag under CI #73

Open Susurrus opened 7 years ago

Susurrus commented 7 years ago

$CI was chosen instead of $TRAVIS and the ! -z check was done such that this can work on all CI platforms (at least GitLab CI, Travis CI, AppVeyor, and Circle CI).

japaric commented 7 years ago

This seems fine to me but:

Susurrus commented 7 years ago

I think this is what you were asking for. I should note that I was expecting japaric/cross#91 to block this as then we can add a default whitelist for RUSTFLAGS to a template Cross.toml.

japaric commented 7 years ago

I think this is what you were asking for.

Yes, thanks.

Now it's clear that this needs whitelisting the RUSTFLAGS variable.

Susurrus commented 7 years ago

Interesting, it actually looks like RUSTFLAGS is being passed through on mac. On Travis only the DISABLE_TEST targets should have passed, but mac also passed and shows the test as properly ignored.

japaric commented 7 years ago

Running cross on macOS doesn't use Docker at all (cross doesn't support macOS as a host) so the cross build environment on mac is the same as the Travis environment.

Susurrus commented 7 years ago

Getting back to this now that japaric/cross#91 is merged, I'm actually uncertain how to set up Cross.toml for these tests in order to pass through RUSTFLAGS.

Additionally, should this whitelist RUSTFLAGS by default by having a Cross.toml set up with it and suggesting people copy that as well?

japaric commented 7 years ago

I think whitelisting RUSTFLAGS by default in Cross, itself, makes sense.

As for avoiding copying around a Cross.toml in the general case we could use Cargo's convention of making the settings in there configurable via environment variables. For instance, in Cargo land CARGO_BUILD_RUSTFLAGS="foo bar" is equivalent to [build] rustflags = ["foo", "bar"] in .cargo/config. We could have something similar like CROSS_BUILD_ENV_PASSTHROUGH being equivalent to the build.env.passthrough in Cross.toml.

Susurrus commented 7 years ago

I think I understand. So this would require another change to cross such that it can pull config values from environment variables as you described above. And then in addition to setting RUSTFLAGS in ci/script.rs I'd also set CROSS_BUILD_ENV_PASSTHROUGH to RUSTFLAGS. I don't know how to deal with arrays in envvars, but maybe Cargo's source would be of help here.

The only issue with this is then how does the user override this behavior easily? If they a) don't want to passthrough RUSTFLAGS or b) they want to passthrough more variables. We'd need Cross.toml to append these lists together, which I don't think is what you'd expect for envvars. What were you thinking of in this case?

japaric commented 7 years ago

@Susurrus sorry, this PR fell off my radar.

I don't know how to deal with arrays in envvars, but maybe Cargo's source would be of help here.

Cargo uses spaces to split a strings into an array of strings. I think that should work here too since env variables can't have spaces in their names (or at least I think they can't).

The only issue with this is then how does the user override this behavior easily?

Maybe put the CROSS_BUILD_ENV_PASSTHROUGH variable in the env.global field of .travis.yml / AppVeyor.yml and mention what it does and that's it's meant to be user configurable.

If they a) don't want to passthrough RUSTFLAGS

They can comment out the CROSS_BUILD_ENV_PASSTHROUGH variable altogether.

or b) they want to passthrough more variables.

They can manually edit the value of the variable to append other variable names.

Susurrus commented 7 years ago

I fixed everything I think, but this relies on changes in Cross such that it will read from environment variables, IIUC. So this will block until I get that functionality added.

japaric commented 6 years ago

Opened japaric/cross#147 to track the missing support for reading configuration from the environment.