{"action":"created","issue":{"url":"https://api.github.com/repos/dogtools/dog/issues/113","repository_url":"https://api.github.com/repos/dogtools/dog","labels_url":"https://api.github.com/repos/dogtools/dog/issues/113/labels{/name}","comments_url":"https://api.github.com/repos/dogtools/dog/issues/113/comments","events_url":"https://api.github.com/repos/dogtools/dog/issues/113/events","html_url":"https://github.com/dogtools/dog/pull/113","id":201947102,"number":113,"title":"Create dog and dog/run packages","user":{"login":"xsb","id":148317,"avatar_url":"https://avatars.githubusercontent.com/u/148317?v=3","gravatar_id":"","url":"https://api.github.com/users/xsb","html_url":"https://github.com/xsb","followers_url":"https://api.github.com/users/xsb/followers","following_url":"https://api.github.com/users/xsb/following{/other_user}","gists_url":"https://api.github.com/users/xsb/gists{/gist_id}","starred_url":"https://api.github.com/users/xsb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xsb/subscriptions","organizations_url":"https://api.github.com/users/xsb/orgs","repos_url":"https://api.github.com/users/xsb/repos","events_url":"https://api.github.com/users/xsb/events{/privacy}","received_events_url":"https://api.github.com/users/xsb/received_events","type":"User","site_admin":false},"labels":[{"id":391620174,"url":"https://api.github.com/repos/dogtools/dog/labels/dogfile%20spec","name":"dogfile spec","color":"bfdadc","default":false},{"id":390590911,"url":"https://api.github.com/repos/dogtools/dog/labels/enhancement","name":"enhancement","color":"84b6eb","default":true},{"id":423746410,"url":"https://api.github.com/repos/dogtools/dog/labels/refactor","name":"refactor","color":"1d76db","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-01-19T19:04:10Z","updated_at":"2017-01-19T21:19:33Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/dogtools/dog/pulls/113","html_url":"https://github.com/dogtools/dog/pull/113","diff_url":"https://github.com/dogtools/dog/pull/113.diff","patch_url":"https://github.com/dogtools/dog/pull/113.patch"},"body":"## What\r\n\r\nI have been working on this PR for the past weeks. Most code has been either moved or refactored. The main purpose of this change is to make future development easier, we reached a point in which some features were simply impossible to implement without a change like this being made first.\r\n\r\n## How\r\n\r\nDog (the cli tool) has been moved to `cmd/dog` so package *main* is there now.\r\n\r\nThe root directory is now the `dog` package. Dogtools (like the dog cli) can import it to be able to parse Dogfiles and run tasks. This package replaces the old ones (`parser`, `types` and `execute`). Now there are three types: Dogfile, Task and TaskChain, each of them with methods to support the same functionality as the previous version. Most of the previous functions had been moved into type methods. Some of them had been simplified.\r\n\r\nA new package has been created to manage the low level functionality of task execution, it's called `dog/run` and can be found in the `run/` directory. This package exposes the Runner interface with methods to start tasks, collect their outputs and wait for them to finish. At this moment it explicitly supports the same runners that were tested as of v0.3.0 (sh, bash, python, ruby, perl) but it opens the possibility of creating more exotic runners like docker, kubernetes, swarm, etc. New runners can be developed outside of `dog/run` and as long as they implement the Runner interface dog will support them.\r\n\r\nProper documentation has been added and can be read using Godoc. Let me know if something is not clear, having good docs is one of the main objectives of this code change.\r\n\r\n## Dogfile Spec changes\r\n\r\nThe specification has changed a little bit:\r\n\r\n- *exec* directive is now *runner*\r\n- *run* directive is now *code*\r\n\r\nThe fact that executors are now called runners implies changes all over the place. This is also the reason why the `execute` package is now the new `dog/run` package.\r\n\r\nNaming the old run directive just code have two objectives. First we avoid ambiguity with the concept of runners. Second, future runners will have this directive as optional, something that could feel unnatural if the name was run. It never made sense to use a verb as a directive name.\r\n\r\nI am also adding support for backwards compatibility when the spec changes so old Dogfiles will work as expected with this new dog version. Deprecation detection has been added at package level, and now dog uses them to print warnings on STDERR after parsing. Current Spec changes will break on version v0.6.0, two versions from now.\r\n\r\n## Implementation changes\r\n\r\nDog uses exit status 1 if the main program fails and exit status 2 if any of the task fails. This behaviour is copied from GNU Make. The actual task exit status is printed together with elapsed time if the ProvideExtraInfo flag (`-i`) is enabled.\r\n\r\nRemoved the concept of Dogfile level hierarchy, we keep task chain though. This means that we don't store the whole hierarchy anymore. What dog does now is: process it as a check/validation, and generate it when a task needs to run.\r\n\r\nAdded validation methods to both Dogfile and Task types.\r\n\r\nThe operating system is detected at package init time, and the default runner is chosen based on this. This will be more relevant in the future, as Windows (`cmd` runner) is not suported yet.\r\n\r\nSupport for dotenv has been removed, as it was confusing. Should we search for the `.env` file in the current dir where dog is launched? or in the Dockerfile path? Maybe in the task workdir? I think we can live without this, but if someone wants it we should first decide the expected behaviour.\r\n\r\nProvideExtraInfo (controled by the `-i`/`--info` flag) is now a package level variable.\r\n\r\nRenamed *status code* to *exit status* everywhere.\r\n\r\n## Other\r\n\r\nI removed the Gitter chat link from the README because no one was using it. I will remove the account after this PR is merged. We can open it again in the future if needed.\r\n\r\nThe README file is (I hope) simpler than before.\r\n\r\nCI (Travis) now also runs `errcheck` and `staticcheck`.\r\n\r\nDist task now uses a directory called `dog-{version}` instead of `dist` when compressing the release, so it will have the appropriate name when the final user uncompresses it. This was really annoying before.\r\n\r\nNew dog logo added to `img/` to be later used in the README.\r\n\r\nAdded `examples/` directory with the first example showing the use of Dog as a library.\r\n\r\nVersion bump to v0.4.0. Why changing the version number if there are no new features? The point is that I consider the fact that this can be used as a library a feature, something that was promised before but never truly worked.\r\n\r\n## Notes\r\n\r\nThe code that implements the cli is almost the same as before. I know it should be simplified but it can be done later.\r\n\r\nI know there are no unit tests, and this is something I want to change from now on. My plan is to test the packages using go test and then start a test suite using aruba. During this refactor I have been using `dog run-test-dogfiles` and it gave me enough confidence to believe this PR have feature parity with v0.3.0.\r\n\r\nThanks for reading all this! I am sure this is full of novice errors, and I want to learn. What would you improve?"},"comment":{"url":"https://api.github.com/repos/dogtools/dog/issues/comments/273901856","html_url":"https://github.com/dogtools/dog/pull/113#issuecomment-273901856","issue_url":"https://api.github.com/repos/dogtools/dog/issues/113","id":273901856,"user":{"login":"marc-gr","id":15213755,"avatar_url":"https://avatars.githubusercontent.com/u/15213755?v=3","gravatar_id":"","url":"https://api.github.com/users/marc-gr","html_url":"https://github.com/marc-gr","followers_url":"https://api.github.com/users/marc-gr/followers","following_url":"https://api.github.com/users/marc-gr/following{/other_user}","gists_url":"https://api.github.com/users/marc-gr/gists{/gist_id}","starred_url":"https://api.github.com/users/marc-gr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marc-gr/subscriptions","organizations_url":"https://api.github.com/users/marc-gr/orgs","repos_url":"https://api.github.com/users/marc-gr/repos","events_url":"https://api.github.com/users/marc-gr/events{/privacy}","received_events_url":"https://api.github.com/users/marc-gr/received_events","type":"User","site_admin":false},"created_at":"2017-01-19T21:19:33Z","updated_at":"2017-01-19T21:19:33Z","body":"Wow this looks amazing 🎉, I will need a little bit of time to go through all of it though ⏳ "}}
{"actor":{"display_login":"marc-gr"}}