[[_TOC_]] # Development This project includes a number of helpers in the `Makefile` to streamline common development tasks. ## Local Environment Setup The following demonstrates setting up and working with a development environment: ### Creating virtualenv ``` ### create a virtualenv for development $ make virtualenv $ source env/bin/activate ### run dhwp cli application $ dhwp --help ### run pytest / coverage $ make test ``` ### Docker Environment Setup Included is a docker-compose environment that includes a database, nginx, 2 PHP instances (live and stage) and a container for dhwpcli ``` $ docker-compose up ``` Run the dhwp cli tool inside the container environment ``` $ docker-compose run dhwp --help ``` ### Metrics Command The metrics command can be run on an individual installation ``` $ docker-compose run dhwp -p /wordpress/live metrics -o /wordpress/live/test.json ``` A batch file path can also be passed to the metrics command, this is used for generating metrics on multiple installations under multiple users. The batch is added to a queue and processed 2 at a time until complete and then the output is all written to a single file. ``` $ docker-compose run dhwp metrics -b "batch-config.yaml" ``` The batch file is a yaml format like below. ``` Output: /wordpress/live/output.json Installs: - Install Id: 12345 User: dhwp Path: /wordpress/live - Install Id: 98765 User: dhwp Path: /wordpress/stage ``` ### Extras Command The extras command can be run to install plugins and themes listed in a config file. An example plugins.yaml file can be found in the main directory. ``` $ docker-compose run dhwp -p /wordpress/live -c plugins.yaml extras ``` # APT package ## Building package For now, package building process is pretty manual. We're building package on special machine `pdx1-pbuilder1`. The machine should have installed all needed libs, but the script will also install some rvm/ruby/fpm stuff locally, when it is ran under what ever user runs it. So it's recommended to have your own user there. If you don't have any there - ask someone for help, maybe `#opsdev` or `#nightmarelabs` channels in slack. To build package: 1. Go to the `pdx1-pbuilder1` 2. Switch to your own user if you're not switched already 3. Create dir, where you're going to build the package 4. Add key with which you can connect to Git to the `~/.ssh/git_key` file 5. Take script located in repo root - [build-dhwp-package.sh](build-dhwp-package.sh) 6. Save script in the dir for building you've created and add execute permissions to it 7. Run the script, where the first argument is the new version of the package, like `./building.sh '1.84'`. Current versions you can find in repo, [example](http://apt.dreamcompute.com/pool/ndn-jammy/d/dhwp/). 8. PROFIT! As the result you'll have package called like `dhwp_1.84_amd64.deb` in the dir where you ran script from. ## Pushing package to the apt repo After previous step with building package itself you need to push package to our apr repos. It could be done from the `pdx1-pbuilder1` machine as well. Under your user run similar command (don't forget to change release and version of the package): `ndnpkg-git --upload --filename dhwp_$PCKG_VERSION_amd64.deb --release jammy` where `$VERSION` is the number of the version, so the full package name would look like `dhwp_1.84_amd64.deb`. Please, be super careful about pushing new package to the repo because AFAIK rolling package's version back (from the apt repo perspective) - pretty hard manual process.