azukiapp / azk

azk is a lightweight open source development environment orchestration tool. Instantly & safely run any environment on your local machine.
http://azk.io
Apache License 2.0
898 stars 63 forks source link

Azk running tests #568

Open thebergamo opened 8 years ago

thebergamo commented 8 years ago

Well, azk is an awesome tool for devs!

When I trying use it, I have a little doubt, I don't know if you have an problem/idea like this, but is very useful if I can run my tests directly in AZK. maybe: azk start test or something like this.

What you think about it? Thansk in advance!

gullitmiranda commented 8 years ago

We have planned a binStubs scheme. e.g.:

aliases({
  bundle     : { command: ["bundle", "exec"]}, // system: azkdemo (default)
  scaffold   : { alias: "bundle", append: ["rails", "g", "scaffold"]},
  test       : { alias: "bundle", append: ["rake", "test"], tty: true, context: 'test'},
  'import-db': { system: "mysql", command: ["mysql"], depends: false}
});
$ azk script generator --path ./script
  ./script/bundle
  ./script/scaffold
$ azk shell [system]
$ azk exec test
$ azk exec scaffold -- post title:string body:text
$ azk exec test -C dev -T
$ azk exec -- bundle
$ ./script/scaffold post title:string body:text

This feature was suggested by @willian a while ago.

geovanisouza92 commented 8 years ago

This is a good idea. Think not just about tests, but any kind of task or command.

Currently I use Docker + Fabric to define some tasks. Some tasks are just docker exec -it ....

Azkfile.js could support something like this:

systems({
  'app': {
    image: { docker: "azukiapp/python:3.4" },
    // ...
    tasks: {
      createsuperuser: function(run) {
        run('python manage.py createsuperuser');
      },
      migrate: function(run) {
        run('python manage.py migrate');
      },
      hello: function(run, name) {
        run('echo Hello '+name);
      }
    }
  }
);

Allowing us to execute

$ azk task createsuperuser
$ azk task migrate
$ azk task hello:world

Each task would be just a function, with an argument (run function) that connect to container and execute the command passed. I think that this is more flexible and easier to reason about than another configuration section in a JSON-like way.

It doesn't matter if in the future the azk backend will be changed from docker to VM or something else, just the run function implementation will be changed (from docker exec/tty allocation to SSH, e.g.).

thebergamo commented 8 years ago

good point @geovanisouza92

heyvito commented 8 years ago

This is really interesting! Any idea when will it be released?

gullitmiranda commented 8 years ago

as yet not @victorgama, there are some major priorities. But as soon as possible it will be done. I also like that she had already been implemented.

heyvito commented 8 years ago

@gullitmiranda No problem. Will keep watching this issue until it is implemented. Thanks!