Slide 1

Slide 1 text

Devkit By the People, For the People. @noiselabs Vítor Brandão April 2018 ·

Slide 2

Slide 2 text

https://noiselabs.io @noiselabs Vítor Brandão member since January 2015! member Noiselabs Consulting

Slide 3

Slide 3 text

We are still not working together

Slide 4

Slide 4 text

But we should.

Slide 5

Slide 5 text

We ought to get rid of wasteful processes and strive for efficiency. But we should.

Slide 6

Slide 6 text

We ought to get rid of wasteful processes and strive for efficiency. But we should. I'm committed to this.

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

ah you need to run the db script too Hi, how do I setup my environment? I see... oh, just git clone the app repo and run docker-compose up sometimes it fails so make sure you clear the cache

Slide 9

Slide 9 text

I have a zsh script for this hmm, Matt might have a more complete script ...but it needs ruby, I think

Slide 10

Slide 10 text

Enough.

Slide 11

Slide 11 text

Sounds familiar? (if not, I'm happy for you)

Slide 12

Slide 12 text

team "A group of individuals working together to achieve a goal." noun \ ˈtēm \

Slide 13

Slide 13 text

Why are we not cooperating?

Slide 14

Slide 14 text

Collaboration requires individual effort.
 


Slide 15

Slide 15 text

Collaboration requires individual effort.
 
 You have to be mindful of others.

Slide 16

Slide 16 text

Collaboration requires individual effort.
 
 You have to be mindful of others. 
 And you'll need to make concessions.

Slide 17

Slide 17 text

Introducing a common tool may be hard.


Slide 18

Slide 18 text

Introducing a common tool may be hard.
 But it's worth it.
 


Slide 19

Slide 19 text

Introducing a common tool may be hard.
 But it's worth it.
 
 common tool ↝ common process

Slide 20

Slide 20 text

Devkit developer toolkit

Slide 21

Slide 21 text

This talk is not about a tool. It's about your team's tool.

Slide 22

Slide 22 text

By the People, For the People* * s/People/Team

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

•Pick the mainstream programming language, not just the in-house ninja- rockstar favourite.


Slide 25

Slide 25 text

•Pick the mainstream programming language, not just the in-house ninja- rockstar favourite.
 •Be inclusive: make it work across different OSes and setups and invite everyone to contribute.


Slide 26

Slide 26 text

•Pick the mainstream programming language, not just the in-house ninja- rockstar favourite.
 •Be inclusive: make it work across different OSes and setups and invite everyone to contribute.
 •...but don't go too far, apply standard setups where needed. Compromise.

Slide 27

Slide 27 text

•Make it dead easy to push fixes. This ain't production code.


Slide 28

Slide 28 text

•Make it dead easy to push fixes. This ain't production code.
 •Think about non-devs.


Slide 29

Slide 29 text

•Make it dead easy to push fixes. This ain't production code.
 •Think about non-devs.
 •Self-documentation is nice.


Slide 30

Slide 30 text

•Make it dead easy to push fixes. This ain't production code.
 •Think about non-devs.
 •Self-documentation is nice.
 •Documentation is even nicer. A simple README.md will suffice.

Slide 31

Slide 31 text

What do I get in return?

Slide 32

Slide 32 text

•Fix it once, fix it everywhere, for everybody.


Slide 33

Slide 33 text

•Fix it once, fix it everywhere, for everybody.
 •Speak a common language.


Slide 34

Slide 34 text

•Fix it once, fix it everywhere, for everybody.
 •Speak a common language.
 •The setup is now (self-)documented.
 


Slide 35

Slide 35 text

•Fix it once, fix it everywhere, for everybody.
 •Speak a common language.
 •The setup is now (self-)documented.
 
 On-boarding will be much easier, much faster.

Slide 36

Slide 36 text

"There should be one-- and preferably only one --obvious way to do it." -- The Zen of Python

Slide 37

Slide 37 text

devkit@noiselabs (a devkit to get you started)

Slide 38

Slide 38 text

https://github.com/noiselabs/devkit

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

// devkit/DevkitApplication.php abstract class DevkitApplication extends SymfonyConsoleApplication { public function __construct(?string $name = null, ?string $version = null) { // ... $this->container = new \Pimple\Container(); $this->buildContainer(); $this->registerCommands(); } private function buildContainer(): void { $this->setService('app_settings', function () { return AppSettings::fromConfig(); }); $this->setService('env', function (Container $c) { return new Environment($c['app_settings']); }); $this->setService('local_executor', function () { return new LocalExecutor(); }); $this->setService('docker_remote_executor', function (Container $c) { return new DockerRemoteExecutor($c['env']->getDockerDir()); }); $this->setService('vagrant_remote_executor', function (Container $c) { return new DockerRemoteExecutor($c['env']->getVagrantDir()); }); }

Slide 48

Slide 48 text

// devkit/DevkitApplication.php abstract class DevkitApplication extends SymfonyConsoleApplication { // ... public function setService(string $name, $service): void { $this->container[$name] = $service; } public function getService(string $name): string { if (!isset($this->container[$name])) { throw new RuntimeException(sprintf('Service "%s" is not available.', $name)); } return $this->container[$name]; } private function registerCommands(): void { $this->addCommands([ new Command\Docker\DockerLogs, new Command\Docker\DockerShell, new Command\Docker\DockerStart, new Command\Docker\DockerStop, new Command\PhpQa\Phan, new Command\PhpQa\Phpstan, new Command\Phpqa\QaList, new Command\Vagrant\VagrantHalt, new Command\Vagrant\VagrantUp, ]); } }

Slide 49

Slide 49 text

// devkit/Infra/Command/DockerCompose.php /** * Define and run multi-container applications with Docker. */ class DockerCompose { /** * build: Build or rebuild services. */ public static function build(?string $service = null, ?string $command = null, array $options = []): DockerRemoteCommand { return self::buildDockerCommand('build', $service, $command, $options); } /** * exec: Execute a command in a running container. */ public static function exec(string $service, string $command, array $options = []): DockerRemoteCommand { return self::buildDockerCommand('exec', $service, $command, $options); } /** * run: Run a one-off command. */ public static function run(string $service, string $command, array $options = []): DockerRemoteCommand { return self::buildDockerCommand('run --rm', $service, $command, $options); } // ...

Slide 50

Slide 50 text

// app/bin/devkit run();

Slide 51

Slide 51 text

setService('remote_executor', $this->getService('docker_remote_executor')); $this->addCommands([ new Command\EnvDown, new Command\EnvReload, new Command\EnvSetup, new Command\EnvUp, ]); } }

Slide 52

Slide 52 text

// app/src/Command/EnvUp.php namespace Noiselabs\DevkitApp\Command; // ... class EnvUp extends DevkitCliCommand { protected function configure() { $this->setName('env:up'); $this->setDescription('Boots the development environment'); } protected function execute(InputInterface $input, OutputInterface $output): void { $io = $this->getConsoleIo($input, $output); $io->writeln(Environment::OUTPUT_TITLE_PREFIX . 'Booting the development environment...'); $this->getApplication()->find('cache:clear')->run(new ArrayInput([]), $output); $this->executeRemoteCommand(DockerCompose::up(null, ['-d']), $input, $output); $this->getApplication()->find('database:reset')->run(new ArrayInput([]), $output); } }

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

Before you go

Slide 55

Slide 55 text

•communicate •collaborate •be efficient •be happy

Slide 56

Slide 56 text

By the People, For the People. Devkit Thank You https://joind.in/talk/96595 @noiselabs Vítor Brandão