docs: add vagrant documentation/scripts

This commit is contained in:
Mike Crowe 2022-02-26 10:05:44 -05:00
parent 6873f1b5be
commit 9db40056dd
5 changed files with 104 additions and 25 deletions

View file

@ -240,10 +240,17 @@ platforms that could be forked and stuffed.
- [New questions](https://github.com/xxh/xxh/wiki#new-questions)
## Development
### xxh Development Environment
In the [xxh development environment](https://github.com/xxh/xxh/tree/master/xde) there is full [dockerised](https://www.docker.com/) environment
for development, testing and contribution. The process of testing and development is orchestrated by `xde` tool and is as
easy as possible.
### Vagrant based Plugin Development
To develop plugins, [Vagrant](https://www.vagrantup.com) supports starting [many configurations](https://app.vagrantup.com/boxes/search) of
**We have teams.** If you're in a team it does not mean you have an obligation to do something. The main goal of teams is to create groups
of passionate people who could help or support solving complex problems. Some people could be an expert in one shell and a
newbie in another shell and mutual assistance is the key to xxh evolution. [Ask join.](https://github.com/xxh/xxh/issues/50)

View file

@ -0,0 +1,44 @@
# Plugin Development using Vagrant
[Vagrant](https://www.vagrantup.com) from HashiCorp creates virtual environments that can easily allow unique testing destinations for your plugin development.
To develop using `Vagrant`, copy this folder to a new location and change the `config.vm.box` to the [a supported VN](https://app.vagrantup.com/boxes/search) that you would like to target.
## Functionality
You can start the VM using the following `Vagrantfile`:
```Vagrantfile
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/jammy64"
end
```
Start the environment using:
```sh
vagrant up
```
A typical development folder might look like this:
```
-rwxrwxr-x 1 mcrowe mcrowe 940 Feb 13 11:32 start.sh*
-rw-rw-r-- 1 mcrowe mcrowe 3020 Feb 13 08:05 Vagrantfile
drwxrwxr-x 4 mcrowe mcrowe 4096 Feb 13 10:08 xxh-plugin-bash-bashit/
drwxrwxr-x 4 mcrowe mcrowe 4096 Feb 13 08:56 xxh-plugin-prerun-dotbare/
```
The `start.sh` script starts an `xxh` session to the VM and maps in any `xxh-` folders in the session. For example:
To reset everything and start again:
```sh
vagrant destroy && vagrant up
```
## Demo
![demo](demo.gif)

4
plugin-development/Vagrantfile vendored Normal file
View file

@ -0,0 +1,4 @@
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/jammy64"
end

BIN
plugin-development/demo.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

24
plugin-development/start.sh Executable file
View file

@ -0,0 +1,24 @@
#!/usr/bin/env bash
SHELL=${1:-bash}
VAGRANT_IP="$(VBoxManage showvminfo $(cat .vagrant/machines/default/virtualbox/id) --details | grep 'name = ssh' | cut -b 18- | egrep -o 'host ip = [0-9.]*' | cut -b 11-)"
VAGRANT_PORT="$(VBoxManage showvminfo $(cat .vagrant/machines/default/virtualbox/id) --details | grep 'name = ssh' | cut -b 18- | egrep -o 'host port = [0-9]*' | cut -b 13-
)"
SSH="-i .vagrant/machines/default/virtualbox/private_key -o PasswordAuthentication=no vagrant@$VAGRANT_IP -p $VAGRANT_PORT"
TESTING=""
CURR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
for item in $(shopt -s dotglob && cd $CURR_DIR && find . -type d -name 'xxh-*'); do
TODO="$(basename $item)"
TESTING="+RI $TODO+path+$CURR_DIR/$TODO $TESTING"
done
echo "Starting with params: $TESTING"
ssh $SSH "ls -l"
if [ $? != 0 ]; then
ssh-keygen -f "$HOME/.ssh/known_hosts" -R "[$VAGRANT_IP]:$VAGRANT_PORT"
fi
xxh $SSH +s $SHELL $TESTING