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

improve travis-ci defaults to leverage build stages #172

Merged
merged 7 commits into from
Mar 26, 2019

Conversation

rtib
Copy link
Contributor

@rtib rtib commented Dec 20, 2018

Hi there, I'd propose some changes to travis-ci defaults. Main goal is to leverage build stages by default. Along with some maintenance and bug fixing the main changes in this PR are:

  • (improvement) define stages: static, spec, beaker, deploy
  • (feature) deploy stage is limited to version tag
  • (maintenance) remove unnecessary global env
  • (bugfix) add bundler_args "--with system_tests" to docker_defaults
  • (improvement) split static code analysis jobs to multiple jobs on static stage
  • (improvement) move spec test jobs to spec stage
  • (maintenance) replace default spec job with explicit Puppet 6 job
  • (maintenance) order spec test jobs by major version
  • (improvement) introduce deploy job on deploy stage

I've been using such a setup for some time now and would like to push them upstream. As an working example, have a look on

@scotje
Copy link
Contributor

scotje commented Dec 20, 2018

Hi @rtib !

These changes look solid to me. Given their wide impact I think we should wait for a bit and let other community members weigh in as well.

Thanks for your contribution!

@bmjen
Copy link
Contributor

bmjen commented Dec 20, 2018

/cc @cdenneen @dhollinger @bastelfreak @rnelson0

This PR touches a lot of parts of the base pdk-templates, please take a look and see if any of these changes will impact you negatively.

@bastelfreak
Copy link
Contributor

Hi everybody.
thanks for pinging, @bmjen. I don't think that this effects Vox Pupuli modules, we currently don't use pdk and still rely on modulesync. It might be a good idea to adapt this. Did you test if this as any speed impacts? Puppet and Vox Pupuli have more than the usual two concurrent travis jobs. Does this change make the average run faster or slower?

@rtib
Copy link
Contributor Author

rtib commented Dec 21, 2018

Hi @bastelfreak. It's hard to predict the impact on average runtime. The idea behind this is to order the tasks and use the results of cheaper tests to predict the results of more resource and time consuming tests.

Having the cheap static analysis jobs e.g. syntax, lint and rubocop run first. On the next stage more expensive spec tests will run only if the first stage was completed and fine. The most expensive beaker tests will start only if all spec tests were successful. Finally, if the commit has a version tag, the deploy job is carried out.

This makes the average runtime of a fully successful CI build longer. But if you have some syntax, lint or rubocop offences, the process will stop very early and does not allocate resources for more expensive jobs. Most of all, if any of your spec tests fail, then you don't need to waste time and resources on beaker.

@rtib rtib mentioned this pull request Dec 29, 2018
Copy link
Contributor

@npwalker npwalker left a comment

Choose a reason for hiding this comment

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

Almost all of the time spent on the static code analysis steps comes from spinning up the container and installing dependencies. This is why I moved them all into one step in #88.

All of those should stay as one step to reduce waste of resources.

How does the DEPLOY_TO_FORGE setting work? Are we suddenly opting everyone into something by putting that there?

@rtib
Copy link
Contributor Author

rtib commented Jan 8, 2019

Hi @npwalker ,

it's a trade-off between reducing CI resources, the time producing feedback and grouping the checks. Having many checks in one step makes it hard to see the cause if a single one was failed. I found it more valuable to have distinct jobs for git sanity, puppet code validation and rubocop. Indeed, this consumes more resources at travis, but these jobs are still running in parallel, therefore the time impact should not be as high.

The deployment logic works as follows (see details on the generated travis.yml in the above example):

  1. the deploy stage exists as last stage only if the build has a version tag (see rtib/puppet-geoip/.travis.yml#L21)

  2. if all stages succeeded, the deploy stage will run and set DEPLOY_TO_FORGE=1 (.travis.yml#L57)

  3. deployment will happen only if the condition is met (.travis.yml#L73).

That makes a puppet module to be tested and deployed to forge automatically if you push a version tag. Note, that user and secret also needs to be set otherwise the deploy job will fail.

@ghoneycutt
Copy link
Contributor

I really like this approach of stages because it makes it really easy to understand what is failing the tests from a glance.

I don't recommend we use this functionality as is though because it adds a lot of extra time to the tests. The test at https://travis-ci.org/rtib/puppet-geoip/jobs/470712805 runs for 2m11s with 20s running the actual tests and the other time setting up the testing environment. This would greatly impact the time to test by adding more environments.

Suggest that we combine the static and spec tests into one stage which would alleviate the issue above. This also fits better with how people test now, which is to runs static and spec tests for each puppet version, run a bunch of beaker tests and optionally run a deploy.

@dhollinger
Copy link
Contributor

I'm with @ghoneycutt - having multiple stages and multiple "jobs" in those stages allows a developer to get quick results on specific types of tests instead of having to dig through the test logs to find what failed. If rubocop fails, then all I have to do is look at the bottom of the rubocop log. Similar process for syntax, linting, and metadata checks. If they are all pulled together into one, it can occasionally become difficult to find the log that tells you what and where something failed.

The separate stages fit with the "Fail fast and Early" mantra.

@npwalker
Copy link
Contributor

npwalker commented Mar 5, 2019

I like the PR as it stands now because it adds in build stages which is an improvement and we don't have to hash out whether the checks should be split apart or not. In order to get this change in I think we should agree to limit the scope to just adding build stages.

It looks like the PR needs to be rebased then I suspect it's good to go.

If we want to discuss breaking apart the static checks it should be moved to another ticket or PR. Although I'm still of the opinion that we should not break them apart as to be responsible users of Travis' free offering.

bmjen
bmjen previously requested changes Mar 6, 2019
config_defaults.yml Outdated Show resolved Hide resolved
@scotje
Copy link
Contributor

scotje commented Mar 19, 2019

Sounds like this just needs a rebase at this point?

Thanks @bastelfreak @npwalker @ghoneycutt @dhollinger for weighing in and helping this get to a good compromise!

And thank you to @rtib for diligently answering questions and integrating everyone's feedback!

@scotje scotje requested a review from bmjen March 20, 2019 00:03
@rtib
Copy link
Contributor Author

rtib commented Mar 23, 2019

Have rebased it.

Additionally, I renamed the "beaker" stage to "acceptance" which better fit the purpose rather than the name of the tool currently used.

@scotje scotje dismissed bmjen’s stale review March 26, 2019 00:40

concerns addressed

@rodjek rodjek merged commit a6554ab into puppetlabs:master Mar 26, 2019
@rtib rtib deleted the improve-travis-defaults branch March 26, 2019 08:39
rtib added a commit to rtib/pdk-templates that referenced this pull request May 6, 2019
scotje pushed a commit to rtib/pdk-templates that referenced this pull request Jun 25, 2019
scotje pushed a commit to rtib/pdk-templates that referenced this pull request Jun 25, 2019
@rtib rtib mentioned this pull request Jun 27, 2019
treydock pushed a commit to treydock/pdk-templates that referenced this pull request Oct 7, 2019
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.

8 participants