Skip to content

misc: Fix Travis conditional build #2583

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

Merged
merged 2 commits into from
May 13, 2020

Conversation

rhcarvalho
Copy link
Contributor

@rhcarvalho rhcarvalho commented May 12, 2020

Not all environment variables that Travis set in build time are
available to conditional build evaluation.

Instead of using environment variables, we can condition on the fork
attribute, which is false for branches in the main repo, and true
for PRs sent from forks.

Reference:
https://docs.travis-ci.com/user/conditions-v1#integration

Not all environment variables that Travis set in build time are
available to conditional build evalution.

Apart from a list of known attributes, only environment variables from
.travis.yml and repository settings are available and can be matched
using env(FOO).

We then condition the build to the presence of the BROWSERSTACK_USERNAME
variable. Note that 'env(BROWSERSTACK_USERNAME) IS present' is also a
possible solution, though more verbose.

Reference:
https://docs.travis-ci.com/user/conditions-v1#integration
@rhcarvalho
Copy link
Contributor Author

rhcarvalho commented May 12, 2020

with browserstack

This is a build from a branch in the main repo to show the condition being true:

https://github.com/getsentry/sentry-javascript/runs/667219825

image

without browserstack

This PR is intentionally from a fork to test the condition being false:

https://github.com/getsentry/sentry-javascript/runs/667218127

image

@rhcarvalho
Copy link
Contributor Author

Original attempt at fixing the conditional:

Not all environment variables that Travis set in build time are
available to conditional build evalution.

Apart from a list of known attributes, only environment variables from
.travis.yml and repository settings are available and can be matched
using env(FOO).

We then condition the build to the presence of the BROWSERSTACK_USERNAME
variable. Note that 'env(BROWSERSTACK_USERNAME) IS present' is also a
possible solution, though more verbose.

Reference:
https://docs.travis-ci.com/user/conditions-v1#integration

env(BROWSERSTACK_USERNAME) didn't work, it was always true.

Checking the fork attribute works.

@rhcarvalho rhcarvalho marked this pull request as ready for review May 12, 2020 17:11
@rhcarvalho rhcarvalho requested a review from kamilogorek as a code owner May 12, 2020 17:11
@rhcarvalho
Copy link
Contributor Author

Going to merge this, travis failures are unrelated.

@rhcarvalho rhcarvalho merged commit 49f29e1 into getsentry:master May 13, 2020
@rhcarvalho rhcarvalho deleted the fix-travis-conditional-build branch May 13, 2020 12:25
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.

2 participants