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

Add verify stage to TravisCI config #5621

Merged
merged 8 commits into from
Jan 27, 2020

Conversation

citizen428
Copy link
Contributor

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

As discussed on Slack, this PR adds a verify stage to the Travis pipeline which will try to start a production Rails runner to verify that the app can boot up, so we don't solely rely on deploy-tasks.sh for that purpose.

Related Tickets & Documents

n/a

Mobile & Desktop Screenshots/Recordings (if there are UI changes)

n/a

Added to documentation?

  • docs.dev.to
  • readme
  • no documentation needed

@citizen428 citizen428 added the area: sre site reliability label Jan 21, 2020
@citizen428 citizen428 requested a review from a team January 21, 2020 03:36
@citizen428 citizen428 self-assigned this Jan 21, 2020
@pr-triage pr-triage bot added the PR: unreviewed bot applied label for PR's with no review label Jan 21, 2020
@citizen428
Copy link
Contributor Author

@mstruve I guess for this to work we'd need to set up a few env variables, most likely to dummy values.

Screen Shot 2020-01-21 at 12 22 23

@citizen428 citizen428 changed the title Add verify stage to TravisCI config [WIP] Add verify stage to TravisCI config Jan 21, 2020
@pr-triage pr-triage bot removed the PR: unreviewed bot applied label for PR's with no review label Jan 21, 2020
@citizen428
Copy link
Contributor Author

Another problem is that after_scripts return code does not influence the build status 😢

The exit code of after_success, after_failure, after_script, after_deploy and subsequent stages do not affect the build result. However, if one of these stages times out, the build is marked as failed.

I'll see what else I can come up with, but we may need to move the config from simple lifecycle to actual stages.

@rhymes rhymes requested a review from mstruve January 21, 2020 10:39
@mstruve
Copy link
Contributor

mstruve commented Jan 21, 2020

Why not just add it as another step to the initial script so if it fails the build fails?

Hopefully, setting those dummy values aren't a rabbit hole 🤞

@citizen428
Copy link
Contributor Author

Why not just add it as another step to the initial script so if it fails the build fails?

I was thinking about this, but it just felt like a distinct stage to me (as does storybook updating tbh). But in lieu of stages, this is probably the only sensible approach without completely changing our Travis settings.

@maestromac
Copy link
Contributor

maestromac commented Jan 22, 2020

@citizen428 random suggestion: would
RAILS_ENV=production bundle exec rails runner 'puts "App booted successfully" || travis_terminate 1 work here?

@citizen428
Copy link
Contributor Author

@maestromac It shouldn't be necessary, as the exit code of script determines the build status. So if the Rails runner fails, the build should already fail.

@citizen428 citizen428 force-pushed the citizen428/add-verify-stage-to-travis branch from 5982870 to 23833bc Compare January 23, 2020 05:03
@citizen428 citizen428 force-pushed the citizen428/add-verify-stage-to-travis branch from 2314905 to 1e9c69c Compare January 27, 2020 08:25
@@ -21,6 +21,14 @@ env:
- RAILS_ENV=test
- CC_TEST_REPORTER_ID=f39e060a8b1a558ebd8aff75d5b9760bf1ae98f3f85d628ae28814f3c66438cd
- DATABASE_URL=postgres://postgres@localhost/
- APP_PROTOCOL=http://
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mstruve I think the amount of dummy env variables needed to get the Rails runner to start up is manageable.

@@ -101,7 +101,7 @@

# DEV uses the RedisCloud Heroku Add-On which comes with the predefined env variable REDISCLOUD_URL
redis_url = ENV["REDISCLOUD_URL"]
redis_url ||= ApplicationConfig["REDIS_URL"]
redis_url ||= ENV["REDIS_URL"]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without this I always got a uninitialized constant ApplicationConfig (NameError) on Travis and locally. I think it makes sense to keep this consistent with line 103 anyway.

@citizen428 citizen428 changed the title [WIP] Add verify stage to TravisCI config Add verify stage to TravisCI config Jan 27, 2020
@pr-triage pr-triage bot added the PR: unreviewed bot applied label for PR's with no review label Jan 27, 2020
@citizen428
Copy link
Contributor Author

@mstruve This is ready for review now.

Copy link
Contributor

@mstruve mstruve left a comment

Choose a reason for hiding this comment

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

This works, one downside is if we remove this from the release-tasks.sh script it does move us further away from actual production because we are not loading the environment with the actual production ENV variables. If a variable we stub here was misconfigured in production this would pass but production would go down. What do you think about keeping both for now approaches for now?

@pr-triage pr-triage bot added PR: reviewed-approved bot applied label for PR's where reviewer approves changes and removed PR: unreviewed bot applied label for PR's with no review labels Jan 27, 2020
- SENDGRID_USERNAME_ACCEL=dummy
- SENDGRID_PASSWORD_ACCEL=dummy
- HEROKU_APP_URL=practicaldev.herokuapp.com
- SECRET_KEY_BASE=dummydummydummy
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be nice to document that these are env variables only required for the verify stage on Travis. I can see someone looking at this down the road and wondering why we have these or whether it
s safe to change or remove them.

Can we add a comment in the travis.yml file for our future selves?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can and will, was just waiting to see if we even go ahead with this approach at all. 😃 Thanks for the reminder though! 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense! And thanks :)

@citizen428
Copy link
Contributor Author

citizen428 commented Jan 27, 2020

@mstruve Agreed, my intention was not to remove it from deploy-tasks.sh, but to catch certain cases pre-deployment. Sorry if I didn't communicate this better, admittedly

so we don't solely rely on deploy-tasks.sh for that purpose.

wasn't the most explicit.

Copy link
Contributor

@nickytonline nickytonline left a comment

Choose a reason for hiding this comment

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

LGTM :shipit:, but as @vaidehijoshi mentioned, it'd be good to document those vars.

Copy link
Contributor

@benhalpern benhalpern left a comment

Choose a reason for hiding this comment

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

This works for me. I'll let @mstruve merge this unless you have last second cold feet on it.

@mstruve mstruve merged commit 6321fba into master Jan 27, 2020
@pr-triage pr-triage bot removed the PR: reviewed-approved bot applied label for PR's where reviewer approves changes label Jan 27, 2020
@mstruve mstruve deleted the citizen428/add-verify-stage-to-travis branch January 27, 2020 19:15
@pr-triage pr-triage bot added the PR: merged bot applied label for PR's that are merged label Jan 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: sre site reliability PR: merged bot applied label for PR's that are merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants