Skip to content

Commit 884a6f6

Browse files
author
Kevin Paulisse
committed
Initial release
0 parents  commit 884a6f6

File tree

445 files changed

+30912
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

445 files changed

+30912
-0
lines changed

.github/CONTRIBUTING.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Contributing
2+
3+
Hi there! We're thrilled that you'd like to contribute to :octocat:alog-diff. Your help is essential for keeping it great.
4+
5+
Please note that this project adheres to the [Open Code of Conduct](http://todogroup.org/opencodeofconduct/#GitHub%20Octocatalog-Diff/[email protected]). By participating in this project you agree to abide by its terms.
6+
7+
We strongly recommend that you check out the [roadmap](/doc/roadmap.md) before getting started. If you have questions, or you'd like to check with us before embarking on a major development effort, please [open an issue](https://github.com/github/octocatalog-diff/issues/new).
8+
9+
## How to contribute
10+
11+
This project uses the [GitHub Flow](https://guides.github.com/introduction/flow/). That means that the `master` branch is stable and new development is done in feature branches. Feature branches are merged into the `master` branch via a Pull Request.
12+
13+
0. Fork and clone the repository
14+
0. Configure and install the dependencies: `script/bootstrap`
15+
0. Make sure the tests pass on your machine: `rake`
16+
0. Create a new branch: `git checkout -b my-branch-name`
17+
0. Make your change, add tests, and make sure the tests still pass
18+
0. Push to your fork and submit a pull request
19+
0. Pat yourself on the back and wait for your pull request to be reviewed and merged
20+
21+
We will handle updating the version, tagging the release, and releasing the gem. Please don't bump the version or otherwise attempt to take on these administrative internal tasks as part of your pull request.
22+
23+
Here are a few things you can do that will increase the likelihood of your pull request being accepted:
24+
25+
- Make sure your contribution is consistent with our [roadmap](roadmap.md).
26+
27+
- Follow the [style guide](https://github.com/bbatsov/ruby-style-guide).
28+
29+
- We support Ruby 2.0 and higher. This means, for example, that you can use the 2.0 hash syntax (e.g. `options = { font_size: 10, font_family: 'Arial' }`, but **not** the 2.1 keyword arguments for methods (e.g., `def foo(bar: 'baz')`).
30+
31+
- We use single quotes (`'`) rather than double quotes (`"`) for strings with no interpolation.
32+
33+
- We use [rubocop](http://batsov.com/rubocop/) to enforce style, because we strive for efficient code reviews. You can view our [.rubocop.yml rules file](/.rubocop.yml) or use `script/fmt` in your checkout to run Rubocop with our rule set. If you use our bootstrap script when cloning your repo, you will have installed Rubocop as a pre-commit hook in the repository.
34+
35+
- Write unit tests. Each changed or added method should be covered by [unit tests](/spec/octocatalog-diff/tests). You can create a [coverage report](/doc/dev/coverage.md) via our rake task if you wish. We'd like to maintain 100% on unit test coverage (`rake coverage:spec`). You can use simplecov comments (`# :nocov:`) to wrap portions of code that it is impractical or not worthwhile to test.
36+
37+
- Write an integration test. For any new features, e.g. when you have added a new command line flag, please consider adding an [integration test](/spec/octocatalog-diff/integration). You can check integration test coverage with `rake coverage:integration`. We do not demand 100% coverage here, as it is impractical to test all possible error conditions. However, it would be great if the important parts of your code are exercised in the integration tests.
38+
39+
- Write or update documentation. If you have added a feature or changed an existing one, please make appropriate changes to the docs. Please note that the [options reference](/doc/optionsref.md) is automatically generated, so you do not need to update that file. (Or, you can run `rake doc:build` to rebuild it.)
40+
41+
- Keep your change as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests.
42+
43+
- We target `octocatalog-diff` to support Puppet 3.8.7 and 4.5 (and subsequent releases). There were some changes to the catalog format between these versions. We have abstracted these differences with methods such as `resources` in the [catalog object](/lib/octocatalog-diff/catalog.rb), but if you are directly interacting with the JSON of the catalog, be careful of this. Our CI job will test with both Puppet 3 and Puppet 4, so writing complete tests are a good way of ensuring that your code is compatible.
44+
45+
- Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
46+
47+
## License note
48+
49+
We can only accept contributions that are compatible with the MIT license.
50+
51+
It's OK to depend on gems licensed under either Apache 2.0 or MIT, but we cannot add dependencies on any gems that are licensed under GPL.
52+
53+
Any contributions you make must be under the MIT license.
54+
55+
## Resources
56+
57+
- [Contributing to Open Source on GitHub](https://guides.github.com/activities/contributing-to-open-source/)
58+
- [Using Pull Requests](https://help.github.com/articles/using-pull-requests/)
59+
- [GitHub Help](https://help.github.com)

.github/ISSUE_TEMPLATE.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!--
2+
Hi there! If you are reporting a bug or a problem, please use this template so that we can collect the information that we need in order to help. If you are opening an issue for a reason other than reporting a problem, e.g. to make a feature request or start a discussion of new functionality, then you do not need to follow the template.
3+
4+
Please remember that all activity in this project, including issues, needs to comply with the Open Code of Conduct, found here: http://todogroup.org/opencodeofconduct/
5+
-->
6+
7+
> Description of problem
8+
9+
- What did you do?
10+
- What happened?
11+
- What did you expect to happen?
12+
- How can someone reproduce the problem?
13+
14+
> Command used and debugging output
15+
16+
<!--
17+
If you are reporting a problem or bug, please replace this text with the command you are using (including all arguments) and the output from that command. Please add the `--debug` command line flag to enable debugging output. You may redact any information you consider sensitive.
18+
-->
19+
20+
> Platform and version information
21+
22+
- Your OS: <!-- Mac OS? Linux? Which version and distribution? -->
23+
- Your Ruby version: <!-- type `ruby --version` at the command prompt -->
24+
- Your version of Puppet: <!-- version number, and whether it's open source or Puppet Enterprise -->
25+
- Your version of octocatalog-diff: <!-- type `octocatalog-diff --version` -->
26+
27+
> Do the tests pass from a clean checkout?
28+
29+
<!-- Please refer to https://github.com/github/octocatalog-diff/blob/master/doc/troubleshooting.md for instructions to check out the master branch and run the tests. If you encounter any errors from the tests, please post them here. -->
30+
31+
> Anything else to add that you think will be helpful?

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!--
2+
Hi there! We are delighted that you have chosen to contribute to octocatalog-diff.
3+
4+
If you have not already done so, please read our Contributing document, found here: https://github.com/github/octocatalog-diff/blob/master/.github/CONTRIBUTING.md
5+
6+
Please remember that all activity in this project, including pull requests, needs to comply with the Open Code of Conduct, found here: http://todogroup.org/opencodeofconduct/
7+
8+
Any contributions to this project must be made under the MIT license.
9+
10+
You do NOT need to bump the version number or regenerate the "Command line options reference" page. We will do this for you at or after the time we merge your contribution.
11+
-->
12+
13+
## Overview
14+
15+
This pull request [introduces/changes/removes] [functionality/feature].
16+
17+
(Please write a summary of your pull request here. This paragraph should go into detail about what is changing, the motivation behind this change, and the approach you took.)
18+
19+
## Checklist
20+
21+
- [ ] Make sure that all of the tests pass, and fix any that don't. Just run `rake` in your checkout directory, or review the CI job triggered whenever you push to a pull request.
22+
- [ ] Make sure that there is 100% [test coverage](https://github.com/github/octocatalog-diff/blob/master/doc/dev/coverage.md) by running `rake coverage:spec` or ignoring untestable sections of code with `# :nocov` comments. If you need help getting to 100% coverage please ask; however, don't just submit code with no tests.
23+
- [ ] If you have added a new command line option, we would greatly appreciate a corresponding [integration test](https://github.com/github/octocatalog-diff/blob/master/doc/dev/integration-tests.md) that exercises it from start to finish. This is optional but recommended.
24+
- [ ] If you have added any new gem dependencies, make sure those gems are licensed under the MIT or Apache 2.0 license. We cannot add any dependencies on gems licensed under GPL.
25+
- [ ] If you have added any new gem dependencies, make sure you've checked in a copy of the `.gem` file into the [vendor/cache](https://github.com/github/octocatalog-diff/tree/master/vendor/cache) directory.
26+
27+
/cc [related issues] [teams and individuals, making sure to mention why you're CC-ing them]

.gitignore

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
*.rbc
2+
/.config
3+
/coverage/
4+
/InstalledFiles
5+
/pkg/
6+
/spec/reports/
7+
/spec/examples.txt
8+
/test/tmp/
9+
/test/version_tmp/
10+
/tmp/
11+
12+
# Used by dotenv library to load environment variables.
13+
# .env
14+
15+
## Specific to RubyMotion:
16+
.dat*
17+
.repl_history
18+
build/
19+
*.bridgesupport
20+
build-iPhoneOS/
21+
build-iPhoneSimulator/
22+
23+
## Specific to RubyMotion (use of CocoaPods):
24+
#
25+
# We recommend against adding the Pods directory to your .gitignore. However
26+
# you should judge for yourself, the pros and cons are mentioned at:
27+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
28+
#
29+
# vendor/Pods/
30+
31+
## Documentation cache and generated files:
32+
/.yardoc/
33+
/_yardoc/
34+
/rdoc/
35+
36+
## Environment normalization:
37+
/.bundle/
38+
/vendor/bundle
39+
/lib/bundler/man/
40+
41+
# for a library or gem, you might want to ignore these files since the code is
42+
# intended to run in multiple environments; otherwise, check them in:
43+
# Gemfile.lock
44+
# .ruby-version
45+
# .ruby-gemset
46+
47+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
48+
.rvmrc
49+
50+
# Specifics for octocatalog-diff
51+
bin/bundler
52+
bin/facter
53+
bin/hiera
54+
bin/htmldiff
55+
bin/httparty
56+
bin/ldiff
57+
bin/parallel_cucumber
58+
bin/parallel_rspec
59+
bin/parallel_spinach
60+
bin/parallel_test
61+
bin/puppet
62+
bin/rake
63+
bin/rspec
64+
bin/rubocop
65+
bin/ruby-parse
66+
bin/ruby-rewrite
67+
bin/safe_yaml
68+
69+
# Ignore config created during testing
70+
.puppet_version
71+
.parallel_runtime_rspec.log
72+
.parallel_runtime_integration.log
73+
.parallel_runtime_tests.log
74+
.rspec_parallel
75+
76+
# Packaged gem
77+
/pkg/
78+
Gemfile.lock

.rubocop.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
AllCops:
2+
TargetRubyVersion: 2.0
3+
DisplayCopNames: true
4+
5+
LineLength:
6+
Max: 130
7+
Severity: warning
8+
9+
Style/OneLineConditional:
10+
Enabled: true
11+
12+
Style/StringLiterals:
13+
# Being consistent with Puppet
14+
EnforcedStyle: single_quotes
15+
16+
# Since we're using Ruby >= 2.0 we can use the new hash syntax
17+
Style/HashSyntax:
18+
Enabled: true
19+
20+
# We are setting absurdly high limits but should work to tighten these up.
21+
Metrics/AbcSize:
22+
Max: 100
23+
Severity: warning
24+
25+
Metrics/ClassLength:
26+
Max: 500
27+
Severity: warning
28+
29+
Metrics/CyclomaticComplexity:
30+
Max: 50
31+
Severity: warning
32+
33+
Metrics/MethodLength:
34+
Max: 100
35+
Severity: warning
36+
37+
Metrics/PerceivedComplexity:
38+
Max: 50
39+
Severity: warning
40+
41+
# Indentation
42+
CaseIndentation:
43+
IndentWhenRelativeTo: end
44+
IndentOneStep: false
45+
46+
Lint/EndAlignment:
47+
AlignWith: variable
48+
49+
# To let us use a '-' in the gem name
50+
Style/FileName:
51+
Enabled: false

.travis.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# octocatalog-diff
2+
3+
language: ruby
4+
install: true
5+
script: "script/cibuild"
6+
7+
matrix:
8+
include:
9+
# Build with latest ruby
10+
- rvm: 2.3.1
11+
env: RUBOCOP_TEST="true" RSPEC_TEST="true"
12+
# Build with older ruby versions
13+
- rvm: 2.2
14+
env: RUBOCOP_TEST="false" RSPEC_TEST="true"
15+
- rvm: 2.1
16+
env: RUBOCOP_TEST="false" RSPEC_TEST="true"
17+
- rvm: 2.0
18+
env: RUBOCOP_TEST="false" RSPEC_TEST="true"

.version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.5.0

Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
source 'https://rubygems.org'
2+
3+
gemspec

LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright (c) 2016 GitHub Inc.
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# octocatalog-diff
2+
3+
#### Compile Puppet catalogs from 2 branches, versions, etc., and compare them <img src="/doc/images/octocatolog-diff-logo.png" align="right" height=126 width=240>
4+
5+
`octocatalog-diff` is a tool that enables developers to be more efficient when testing changes to Puppet manifests. It is most commonly used to display differences in Puppet catalogs between stable and development branches. It does not require a working Puppet master (or puppetserver), so it is often run by developers on their workstations and in Continuous Integration environments.
6+
7+
At GitHub, we manage thousands of nodes with a Puppet code base containing 500,000+ lines of code from over 200 contributors. We run `octocatalog-diff` thousands of times per day as part of Continuous Integration testing, and developers run it on their workstations as they are working with the code.
8+
9+
`octocatalog-diff` is written in Ruby and is distributed as a gem. It runs on Mac OS and Unix/Linux platforms.
10+
11+
It is under active development at this time. We suspect that with the initial release, some people who try it out could be using configurations of Puppet that we haven't experienced within our environment. We are eager to identify and fix as many of these as we can to expand the compatibility of this tool as much as possible.
12+
13+
## How?
14+
15+
Traditional Puppet development generally takes one of two forms. Frequently, developers will test changes by running a Puppet agent (perhaps in `--noop` mode) to see if the desired change has resulted on an actual system. Others will use formal testing methodologies, such as `rspec-puppet` or the beaker framework to validate Puppet code.
16+
17+
`octocatalog-diff` uses a different pattern. In its most common invocation, it compiles Puppet catalogs for both the stable branch (e.g. master) and the development branch, and then compares them. It filters out attributes or resources that have no effect on ultimate state of the target system (e.g. tags) and displays the remaining differences. Using this strategy, one can get feedback on changes without deploying Puppet code to a server and conducting a full Puppet run, and this tool works even if test coverage is incomplete.
18+
19+
There are some [limitations](doc/limitations.md) to a catalog-based approach, meaning it will never completely replace unit, integration, or deployment testing. However, it does provide substantial time savings in both the development and testing cycle. In this repository, we provide example scripts for using `octocatalog-diff` in development and CI environments.
20+
21+
`octocatalog-diff` is currently able to get catalogs by the following methods:
22+
- Compile catalog via the command line with a Puppet agent on your machine (as GitHub uses the tool internally)
23+
- Obtain catalog over the network from PuppetDB
24+
- Obtain catalog over the network using the API to query a Puppet Master / PuppetServer (Puppet 3.x and 4.x supported)
25+
- Read catalog from a JSON file
26+
27+
## Example
28+
29+
Here is simulated output from running `octocatalog-diff` to compare the Puppet catalog changes between the master branch and the Puppet code in the current working directory:
30+
31+
<img src="doc/images/screenshot1.png" alt="[octocatalog-diff screenshot]">
32+
33+
The example above reflects the changes in the Puppet catalog from switching an underlying device for a mounted file system.
34+
35+
## Documentation
36+
37+
### Installation and use in a development environment
38+
39+
- [Installation](/doc/installation.md)
40+
- [Configuration](/doc/configuration.md)
41+
- [Basic command line usage](/doc/basic.md)
42+
- [Advanced command line usage](/doc/advanced.md)
43+
- [Troubleshooting](/doc/troubleshooting.md)
44+
45+
### Installation and use for CI
46+
47+
- [Setting up octocatalog-diff in CI](/doc/advanced-ci.md)
48+
49+
### Technical details
50+
51+
- [Requirements](/doc/requirements.md)
52+
- [Limitations](/doc/limitations.md)
53+
- [List of all command line options](/doc/optionsref.md)
54+
55+
### Project
56+
57+
- [Roadmap](/doc/roadmap.md)
58+
- [Similar tools](/doc/similar.md)
59+
- [Contributing](/.github/CONTRIBUTING.md)
60+
- [Developer documentation](/doc/dev)
61+
62+
## What's in a name?
63+
64+
During its original development at GitHub, this tool was simply called `catalog-diff`. However, there is already a [Puppet module with that name](https://forge.puppet.com/zack/catalog_diff) and we didn't want to create any confusion (in fact, a case could be made to use both approaches). So, we named the tool `octocatalog-diff` because who doesn't like the [octocat](https://octodex.github.com/)? Then one day in chat, someone referred to the tool as ":octocat:alog-diff", and that moniker caught on for electronic communication.
65+
66+
## Contributing
67+
68+
Please see our [contributing document](/.github/CONTRIBUTING.md) if you would like to participate!
69+
70+
## Getting help
71+
72+
If you have a problem or suggestion, please [open an issue](https://github.com/github/octocatalog-diff/issues/new) in this repository, and we will do our best to help. Please note that this project adheres to the [Open Code of Conduct](http://todogroup.org/opencodeofconduct/#GitHub%20Octocatalog-Diff/[email protected]).
73+
74+
## License
75+
76+
`octocatalog-diff` is licensed under the [MIT license](LICENSE).
77+
78+
It requires 3rd party ruby gems found [here](/vendor/cache). It also includes portions of other open source projects [here](/lib/octocatalog-diff/external/pson), [here](/spec/octocatalog-diff/fixtures/repos/default/modules/stdlib), [here](/spec/octocatalog-diff/support/httparty) and [here](/spec/octocatalog-diff/tests/external/pson). All 3rd party code and required gems are licensed either as MIT or Apache 2.0.
79+
80+
## Authors
81+
82+
`octocatalog-diff` was designed and authored by [Kevin Paulisse](https://github.com/kpaulisse) and is now maintained, reviewed, and tested by the Site Reliability Engineering team at GitHub.

0 commit comments

Comments
 (0)