Skip to content

Commit

Permalink
Add Chef Delivery-CLI local stages
Browse files Browse the repository at this point in the history
Based on the stale branch: adec8e4

Delivery CLI: https://docs.chef.io/delivery_cli.html#delivery-local

Inspired by the default testing process that Chef uses for their cookbooks.
See https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/TESTING.MD

Chef Delivery enforces single-cookbook repositories and is thus not applicable for this cookbook
currently located under `cookbooks/cwb-server`
  • Loading branch information
joe4dev committed Aug 17, 2018
1 parent de54cfc commit 6d04df3
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
8 changes: 8 additions & 0 deletions cookbooks/cwb-server/.delivery/project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[local_phases]
unit = "chef exec rspec spec/"
lint = "chef exec cookstyle"
syntax = "chef exec foodcritic . --exclude spec -f any # -t \"~FC064\" -t \"~FC065\""
provision = "chef exec kitchen create"
deploy = "chef exec kitchen converge"
smoke = "chef exec kitchen verify"
cleanup = "chef exec kitchen destroy"
25 changes: 23 additions & 2 deletions cookbooks/cwb-server/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,29 @@ make install
make outdated
# Run integration tests
make test
# Run linter
make lint
# Run all tests
make all_tests
# Run syntax checker
make syntax
```

## Testing

This cookbook uses (Chef Delivery Local)[https://docs.chef.io/delivery_cli.html#delivery-local] to automate testing stages.

Run all tests:

```bash
delivery local all
```

Individual phases:

```bash
delivery local lint # Cookstyle (Rubocup-based Ruby style linter)
delivery local syntax # Foodcritic (cookbook checker)
delivery local unit # short-running unit tests (rspec + chefspec)
delivery local functional # long-running integration tests
```

## Debugging Vagrantfile
Expand Down
7 changes: 5 additions & 2 deletions cookbooks/cwb-server/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ integration_test:
kitchen test

unit_test:
chef exec rspec
delivery local unit

lint:
foodcritic .
delivery local lint

syntax:
delivery local syntax

vendor: install
./vendor_berks_cookbooks.sh
Binary file modified cookbooks/cwb-server/graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6d04df3

Please sign in to comment.