From 3570b773935dea6fb6ce0a7af1eb59f9fff9b4df Mon Sep 17 00:00:00 2001 From: Ben Abrams Date: Wed, 29 Aug 2018 14:36:00 -0700 Subject: [PATCH] Preparing the cookbook for supermarket consumption. This includes: - changelog for all previous additions - contributing guide - testing guide - some changes to how we update versions and tagging, this was dur to some feedback I got (awaiting an issue with more details) in wrapper cookbooks when pulling from the github repo rather than from the supermarket itself. - fixes/improvements to pr/issue templates - release docs Signed-off-by: Ben Abrams --- .github/ISSUE_TEMPLATE.md | 2 +- .github/PULL_REQUEST_TEMPLATE.md | 11 +++- .travis.yml | 10 ++- CHANGELOG.md | 25 ++++++++ CONTRIBUTING.md | 107 +++++++++++++++++++++++++++++++ Makefile | 29 +++++---- README.md | 17 +++++ TESTING.md | 40 ++++++++++++ metadata.rb | 4 +- 9 files changed, 223 insertions(+), 22 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 CONTRIBUTING.md create mode 100644 TESTING.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index c9a1765..0320a25 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,6 +1,6 @@ ## Expected Behavior diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index e8730d5..1d727e1 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,21 +1,28 @@ ## Pull Request Checklist -**Is this in reference to an existing issue?** + #### General - [ ] Update Changelog following the conventions laid out [here](https://github.com/sensu-plugins/community/blob/master/HOW_WE_CHANGELOG.md) -- [ ] Update README with any necessary configuration snippets +- [ ] Update README with any necessary snippets - [ ] Existing tests pass + + #### Purpose #### Known Compatibility Issues diff --git a/.travis.yml b/.travis.yml index bf9c935..eb8075b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,8 +13,7 @@ env: - INSTANCE=server-ubuntu-1804 # before_install: -# - mkdir ~/chef -# - openssl aes-256-cbc -K $encrypted_02ba4c0f2d2e_key -iv $encrypted_02ba4c0f2d2e_iv -in .travis/majormoses.pem.enc -out .travis/majormoses.pem -d +# - openssl aes-256-cbc -K $encrypted_926c7e7ff18b_iv -iv $encrypted_926c7e7ff18b_iv -in .travis/majormoses.pem.enc -out .travis/majormoses.pem -d before_script: - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) @@ -27,12 +26,11 @@ cache: script: - INSTANCE=$INSTANCE make travis -# when we are unblocked by: https://github.com/travis-ci/dpl/issues/841 + # TODO: create a bot user and encrypt that users creds instead # deploy: -# edge: true # provider: chef-supermarket -# user_id: majormoses -# client-key: .travis/majormoses.pem +# user_id: majormoses-bot +# client-key: .travis/majormoses-bot.pem # cookbook_category: Others # on: # tags: true diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..0926d7a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,25 @@ +# Change Log +This project adheres to [Semantic Versioning](http://semver.org/). + +This CHANGELOG follows the format located [here](https://github.com/sensu-plugins/community/blob/master/HOW_WE_CHANGELOG.md) + +## [Unreleased] + +## [0.1.0] - 2018-08-29 + +### Added + +- repo skel, misc project helpers (@majormoses) +- local and `travis-ci` testing: lint + integration (@majormoses) +- helper libraries to make it easy to download from `github` + `hashicorp` releases (@majormoses) +- new resource `atlantis_config` to manage the `atlantis` server config file (@majormoses) +- new resource `atlantis_installer` to install or remove `atlantis` (@majormoses) +- new resource `atlantis_service_systemd` to create or remove a `systemd` unit file for managing the `atlantis` service (@majormoses) +- new resource `atlantis_service_upstart` to create or remove an `upstart` config for managing the `atlantis` service (@majormoses) +- new resource `atlantis_terrform_installer` to install or remove `terraform` for use with atlantis (@majormoses) +- new resource `atlantis_user_group_setup` which sets up or removes users, groups, and directories for atlantis service to use (@majormoses) +- use Apache 2 license (@majormoses) + + +[Unreleased]: https://github.com/majormoses/atlantis-chef/compare/v0.1.0...HEAD +[0.1.0]: https://github.com/majormoses/atlantis-chef/comapre/40189cb9ae94bd6dadfc312856a98e224a7c839f...0.1.0 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..f835bb6 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,107 @@ +# Contributing + +Thank you for wanting to contribute back to the Chef Community. Please submit an [issue](https://github.com/majormoses/atlantis-chef/issues) if you notice a requirement that is missing from this document. + +## Guidelines +We ask that you keep the following guidelines in mind when planning your contribution: + +* Whether your contribution is for a bug fix or a feature request, **create an [Issue](https://github.com/majormoses/atlantis-chef/issues)** to let us know what you are thinking before you fix it. It helps us give a LGTM much faster (with fewer cases of saying no to a PR) +* **For bugs**, if you have already found a fix, feel free to submit a Pull Request referencing the Issue you created. Include the `Fixes #` syntax to link it to the issue you're addressing. +* **For feature requests**, we want to improve incrementally which means small changes at a time. In order to ensure your PR can be reviewed in a timely manner, please keep PRs small. If you think this is unrealistic, then mention that within the issue and we can discuss it. + +## Workflow + +Once you're ready to contribute code back to this repo, ensure you setup your environment to be prepared for upstream contributions. + +### 1) Fork on GitHub + +Fork the appropriate repository by clicking the Fork button (top right) on GitHub. + +### 2) Create a Local Fork + +From whatever directory you want to have this code, clone this repository and setup some sane defaults: + +``` +$ git clone https://github.com/$user/chef-atlantis/ +# if you are a collaborator you can use the @git notation + +$ cd chef-catlantis + +$ git remote add upstream https://github.com/majormoses/chef-atlantis.git +# if you are a collaborator you can use the @git notation + +# Never allow a push to upstream master +$ git remote set-url --push upstream no_push + +# Confirm that your remotes make sense: +$ git remote -v +``` + +### 3) Create a Branch for Your Contribution + +Begin by updating your local fork of the cookbook: + +``` +$ git fetch upstream +$ git checkout master +$ git rebase upstream/master +``` + +Create a new, descriptively named branch to contain your change: + +``` +$ git checkout -b feature/myfeature +``` + +Now hack away at your awesome feature on the `feature/myfeature` branch. + +### 4) Testing Your Code + +Please see [Our testing documentation](TESTING.md) + +### 5) Committing Code + +Commit your changes with a thoughtful commit message. + +``` +$ git commit -am "Adding a feature that does Foo + +Foo is a particularly helpful status when working with Bar. Designed to gather XYZ from the foobar interface." +``` + +Repeat the commit process as often as you need and then edit/test/repeat. Minor edits can be added to your last commit quite easily: + +``` +$ git add -u +$ git commit --amend +``` + +### 6) Pushing to GitHub + +When ready to review (or just to establish an offsite backup or your work), push your branch to your fork on GitHub: + +``` +$ git push origin feature/myfeature +``` + +If you recently used `commit --amend`, you may need to force push: + +``` +$ git push -f origin feature/myfeature +``` + +### 7) Create a Pull Request + +Create a pull request by visiting https://github.com/majormoses/chef-atlantis/ and following the instructions at the top of the screen. + +After the PR is submitted, project maintainers will review it. + +### 8) Responding to your Pull Request + +PRs are rarely merged without some discussion with a maintainer. This is to ensure the larger Chef community benefits from all code contributions. + +They will use a system of labels, like `Status: Awaiting Response`, to indicate they need your feedback. Please regularly check your open PRs, easily found at https://github.com/pulls, to help maintainer's get the information needed to merge your code. + +## Thank You + +We :heart: your participation and appreciate the unique perspective you bring to our community. diff --git a/Makefile b/Makefile index 20423bc..77257d9 100644 --- a/Makefile +++ b/Makefile @@ -1,20 +1,25 @@ -bumpmajor: ## bumps version for a major release - bundle exec semver inc major +# create some global variables +CHEF_METADATA_FILE := metadata.rb +CURRENT_COOKBOOK_VERSION := $(shell egrep "^version\s+" $(CHEF_METADATA_FILE) | awk '{ print $$2}' | tr -d \') -bumpminor: ## bumps version for a minor release - bundle exec semver inc minor -bumppatch: ## bumps version for path/hotfix release - bundle exec semver inc patch +# TODO: come back and review the versioning +# bumpmajor: ## bumps version for a major release +# bundle exec semver inc major + +# bumpminor: ## bumps version for a minor release +# bundle exec semver inc minor + +# bumppatch: ## bumps version for path/hotfix release +# bundle exec semver inc patch foodtest: ## run foodcritic - bundle exec foodcritic -t ~FC019 -t ~FC052 -t ~license . + bundle exec foodcritic -t ~FC019 -t ~FC052 . + +gittag: ## tags the repo with the version in `metadata.rb` + git tag -a $(CURRENT_COOKBOOK_VERSION) -m "tagging $(CURRENT_COOKBOOK_VERSION) for release" + @echo git push origin $(CURRENT_COOKBOOK_VERSION) -gittag: ## tags the repo with the version in `.semver` - -git tag -d `bundle exec semver` - -git push origin :refs/tags/`bundle exec semver` - git tag -a `bundle exec semver tag` -m "tagging `bundle exec semver` for release" - git push origin `bundle exec semver` gemdeps: ## install the gem dependencies locally in vendor/bundle bundle install --path vendor/bundle diff --git a/README.md b/README.md index 2043179..fc1932d 100644 --- a/README.md +++ b/README.md @@ -11,3 +11,20 @@ Install os packages such as `unzip` which is required to use the providers. For ```ruby package 'unzip' ``` + +### Build and Release + +Maintainers are expected to cut releases within 24 hours after each functional pull request is merged into master. Updates to docs, testing, etc do not apply. If you are awaiting a release please open an issue and ping `@majormoses`. + +#### Versioning + +We follow [semver2](https://semver.org/spec/v2.0.0.html) very strictly and any notable exceptions are outlined [here](https://github.com/sensu-plugins/community/blob/master/HOW_WE_VERSION.md) + +#### Process + +1. Manually bump the version in `metadata.rb` +1. Update Changelog to include any missing features. +1. Update Changelog to include a version header and diff links +1. Pull request their changes into the `default` (will typically be `master` branch) +1. Once it has been merged into the default branch you can tag the commit using tools such as [hub](https://github.com/github/hub) via `hub release create $MAJOR.$MINOR.$PATCH` or using `make gittag`. To push to the supermarket you can run `stove --no-git` if you have permission on the supermarket. +1. Put a link to the pull request with a link to the supermarket release to inform the contributor that their change has been released. diff --git a/TESTING.md b/TESTING.md new file mode 100644 index 0000000..4ec6742 --- /dev/null +++ b/TESTING.md @@ -0,0 +1,40 @@ +# Testing this cookbook + +The repo contains a `Makefile` to provide a standard interface to testing both locally and in travis. See the `Makefile` for advanced usage. + +## Basic Testing + +### Dependencies + +Run: +``` +bundle install +``` + +If you do not `bundler` installed you can get it by running `gem install bundler` + +### Lint + +#### Cookstyle + +We use `cookstyle` which is an opinionated set of `rubocop` rules that are targeted to chef cookbooks, we also have some custom rules in `.rubocop.yml` that override these. + +``` +make rubotest +``` + +#### Foodcritic + +We use `foodcritic` which looks for bad cookbook patterns. + +``` +make foodtest +``` + +### Integration tests + +We use `test-kitchen`, `kitchen-dokken`, and `inspec` for integration testing. For advanced usage please see the respective projects. + +``` +bundle exec kitchen test [optional regex] [optional args] +``` diff --git a/metadata.rb b/metadata.rb index f05ef6f..430cee0 100644 --- a/metadata.rb +++ b/metadata.rb @@ -16,6 +16,8 @@ supports 'ubuntu', '= 16.04' supports 'ubuntu', '= 18.04' -version SemVer.find.format '%M.%m.%p' +# TODO: come back and revisit an automated workflow +# version SemVer.find.format '%M.%m.%p' +version '0.1.0' depends 'ark', '~> 4.0'