Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Refactor to run one workflow per-environment #85

Merged
merged 4 commits into from May 11, 2020

Conversation

pauldoomgov
Copy link
Member

Why

  1. Allow for easy identification of which environment smoke test failed.
  2. Allow manual running of smoke tests for a single environment, alleviating
    the need to run from local workstations.

Changes

  • Modify circleci-run to take a single environment name as an argument
    instead of hard coding all environments and running in serial.
  • Add -r NUM option to control the number of retries for a smoke test
    run. (Previous default of 3 maintained.)
  • Refactor CircleCI definition:
    • Reusable executor definition to allow changing Ruby image in one place
    • Per-environment job definitions
    • Per-environment workflows triggered automatically (*:20 - int,
      *:25 - staging, *:30 - prod)

Testing

  • Edit .circleci/config.yaml and add your test branch name to one or more of the branch lists under the workflow trigger(s) you wish to test. Example: Run int scheduled test on branch tester/thing:
smoketest_int:
    triggers:
      - schedule:
          cron: "20 * * * *"
          filters:
            branches:
              only:
                - master
                - tester/thing
  • Push the test branch and wait for the schedule to trigger
  • Delete the branch after testing

Additional

Why:
1) Allow for easy identification of which environment smoke test failed.
2) Allow manual running of smoke tests for a single environment, alleviating
   the need to run from local workstations.

Changes:
* Modify circleci-run to take a single environment name as an argument
  instead of hard coding all environments and running in serial.
* Add -r NUM option to control the number of retries for a smoke test
  run.  (Previous default of 3 maintained.)
* Refactor CircleCI definition:
  - Reusable executor definition to allow changing Ruby image in one place
  - Per-environment job definitions
  - Per-environment workflows triggered automatically (*:20 - int,
    *:25 - staging, *:30 - prod)
Copy link
Contributor

@zachmargolis zachmargolis left a comment

Choose a reason for hiding this comment

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

LGTM this looks great, thank you!

smoketest_staging:
triggers:
- schedule:
cron: "25 * * * *"
Copy link
Contributor

Choose a reason for hiding this comment

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

WDYT of staggering these by 10 minutes instead of 5? Or is 5 minutes plenty of time?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think 10 is better. With retries these can take a while.

bin/circleci-run Outdated
puts "Smoke tests failed in #{environment}. Retrying..."
return if system "HEADLESS_BROWSER=true LOWER_ENV=#{environment} bundle exec rspec --only-failure"
extra_flags = ' --only-failure'
Copy link
Contributor

Choose a reason for hiding this comment

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

WDYT of making the command an array and joining it, rather than having to manage spaces manually?

cmd = ['HEADLESS_BROWSER=true LOWER_ENV=#{environment} bundle exec rspec']
cmd << '--only-failure'
# ...
system cmd.join(' ')

bin/circleci-run Outdated

USAGEDOC

opts.on('-r NUM', Integer, 'Times to retry test. (Default: 3)') do |r|
Copy link
Contributor

Choose a reason for hiding this comment

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

can we add a longer, more descriptive flag name as well?

opts.on('-r NUM', '--retry-count NUM', ....

filters:
branches:
only:
- master
Copy link
Member

Choose a reason for hiding this comment

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

It may make sense to have a branch for each env. Something that matches the IdP code. These frequently break because they are looking for a button label that is deployed to one env but not the other.

Copy link
Member Author

Choose a reason for hiding this comment

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

Excellent idea! Going to merge this now and if no one else beats me to it look into that later in the week.

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 the per-branch stuff might work best if these lived in the same repo as the IDP

@pauldoomgov pauldoomgov merged commit 9b62a69 into master May 11, 2020
@pauldoomgov pauldoomgov deleted the pauldoom/multi-workflow branch May 11, 2020 14:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants