github.com/drud/ddev@v1.21.5-alpha1.0.20230226034409-94fcc4b94453/docs/content/developers/buildkite-testmachine-setup.md (about)

     1  # Buildkite Test Agent Setup
     2  
     3  We are using [Buildkite](https://buildkite.com/drud) for Windows and macOS testing. The build machines and `buildkite-agent` must be set up before use.
     4  
     5  ## Windows Test Agent Setup
     6  
     7  1. Create the user “testbot” on the machine. Use the password for `ddevtestbot@gmail.com`, available in LastPass.
     8  2. In admin PowerShell, `wsl --install`.
     9  3. In admin PowerShell, `Set-ExecutionPolicy -Scope "CurrentUser" -ExecutionPolicy "RemoteSigned"`.
    10  4. In admin PowerShell, download and run [windows_buildkite_start.ps1](scripts/windows_buildkite_start.ps1) with `curl <url> -O windows_buildkite_start.ps1`.
    11  5. After restart, in **administrative** Git Bash window, `Rename-Computer <testbot-win10(home|pro)-<description>-1` and then `export BUILDKITE_AGENT_TOKEN=<token>`.
    12  6. Now download and run [`windows_buildkite-testmachine_setup.sh`](scripts/windows_buildkite_setup.sh).
    13  7. Download and run [windows_postinstall.sh](scripts/windows_postinstall.sh).
    14  8. Launch Docker. It may require you to take further actions.
    15  9. Log into Chrome with the user `ddevtestbot@gmail.com` and enable Chrome Remote Desktop.
    16  10. Enable gd, fileinfo, and curl extensions in `/c/tools/php*/php.ini`.
    17  11. If a laptop, set the “lid closing” setting to do nothing.
    18  12. Set the “Sleep after time” setting in settings to never.
    19  13. Install [winaero tweaker](https://winaero.com/request.php?1796) and “Enable user autologin checkbox”. Set up the machine to [automatically log in on boot](https://www.cnet.com/how-to/automatically-log-in-to-your-windows-10-pc/).  Then run netplwiz, provide the password for the main user, uncheck “require a password to log in”.
    20  14. The `buildkite/hooks/environment.bat` file must be updated to contain the Docker pull credentials:
    21  
    22      ```bash
    23      @echo off
    24      set DOCKERHUB_PULL_USERNAME=druddockerpullaccount
    25      set DOCKERHUB_PULL_PASSWORD=
    26      ```
    27  
    28  15. Set the `buildkite-agent` service to run as the testbot user and use delayed start: Choose “Automatic, delayed start” and on the “Log On” tab in the services widget it must be set up to log in as the testbot user, so it inherits environment variables and home directory (and can access NFS, has testbot git config, etc).
    29  16. `git config --global --add safe.directory '*'`.
    30  17. Manually run `testbot_maintenance.sh`, `curl -sL -O https://raw.githubusercontent.com/drud/ddev/master/.buildkite/testbot_maintenance.sh && bash testbot_maintenance.sh`.
    31  18. Run `.buildkite/sanetestbot.sh` to check your work.
    32  19. Reboot the machine and do a test run. (On Windows, the machine name only takes effect on reboot.)
    33  20. Verify that `go`, `ddev`, `git-bash` are in the path.
    34  21. In “Advanced Windows Update Settings” enable “Receive updates for other Microsoft products” to make sure you get WSL2 kernel upgrades. Make sure to run Windows Update to get the latest kernel.
    35  
    36  ## Additional Windows Setup for WSL2+Docker Desktop Testing
    37  
    38  1. Do not set up `buildkite-agent` on the Windows side, or disable it.
    39  2. Edit Ubuntu's `/etc/wsl.conf` to contain:
    40  
    41      ```
    42      [boot]
    43      systemd=true
    44      ```
    45  
    46  3. Update WSL2 to WSL2 Preview from Microsoft Store and `wsl --shutdown` and then restart.
    47  4. `wsl --update`
    48  5. Open WSL2 and check out [drud/ddev](https://github.com/drud/ddev).
    49  6. As normal user, run `.github/workflows/linux-setup.sh`.
    50  7. `export PATH=/home/linuxbrew/.linuxbrew/bin:$PATH
    51     echo "export PATH=/home/linuxbrew/.linuxbrew/bin:$PATH" >>~/.bashrc`
    52  
    53  8. As root user, add sudo capability with `echo "ALL ALL=NOPASSWD: ALL" >/etc/sudoers.d/all && chmod 440 /etc/sudoers.d/all`.
    54  9. Manually run `testbot_maintenance.sh`, `curl -sL -O https://raw.githubusercontent.com/drud/ddev/master/.buildkite/testbot_maintenance.sh && bash testbot_maintenance.sh`.
    55  10. `git config --global --add safe.directory '*'`
    56  11. Install basics in WSL2:
    57  
    58      ```bash
    59      curl https://apt.fury.io/drud/gpg.key | sudo apt-key add -
    60      echo "deb https://apt.fury.io/drud/ * *" | sudo tee -a /etc/apt/sources.list.d/ddev.list
    61      sudo mkdir -p /usr/sharekeyrings && curl -fsSL https://keys.openpgp.org/vks/v1/by-fingerprint/32A37959C2FA5C3C99EFBC32A79206696452D198 | sudo gpg --dearmor -o /usr/share/keyrings/buildkite-agent-archive-keyring.gpg
    62      echo "deb [signed-by=/usr/share/keyrings/buildkite-agent-archive-keyring.gpg] https://apt.buildkite.com/buildkite-agent stable main" | sudo tee /etc/apt/sources.list.d/buildkite-agent.list
    63      sudo apt update && sudo apt install -y build-essential buildkite-agent ca-certificates curl ddev gnupg lsb-release make mariadb-client
    64      sudo snap install ngrok
    65      ```
    66  
    67  12. [Configure `buildkite-agent` in WSL2](https://buildkite.com/docs/agent/v3/ubuntu). It needs the same changes as macOS, but tags `tags="os=wsl2,architecture=amd64,dockertype=dockerforwindows"` and build-path should be in `~/tmp/buildkite-agent`.
    68  
    69  13. The buildkite/hooks/environment file must be updated to contain the Docker pull credentials:
    70  
    71      ```bash
    72         #!/bin/bash
    73         export DOCKERHUB_PULL_USERNAME=druddockerpullaccount
    74         export DOCKERHUB_PULL_PASSWORD=xxx
    75         set -e
    76      ```
    77  
    78  14. Verify that `buildkite-agent` is running.
    79  15. In Task Scheduler, create a task that runs on User Logon and runs `C:\Windows\System32\wsl.exe` with arguments `-d Ubuntu`.
    80  16. Add `buildkite-agent` to the `docker` and `testbot` groups in `/etc/group`
    81  17. `echo "capath=/etc/ssl/certs/" >>~/.curlrc` And then do the same as `buildkite-agent` user
    82  18. `sudo chmod -R ug+w /home/linuxbrew`
    83  19. `nc.exe -l -p 9003` on Windows to trigger and allow Windows Defender.
    84  20. Run `ngrok config add-authtoken <token>` with token for free account.
    85  21. Copy ngrok config into `buildkite-agent` account, `sudo cp -r ~/.ngrok2 ~buildkite-agent/ && sudo chown -R buildkite-agent:buildkite--agent ~buildkite-agent/ngrok2`
    86  22. Add `/home/linuxbrew/.linuxbrew/bin` to `PATH` in `/etc/environment`.
    87  23. Copy ngrok config into `buildkite-agent` account, `sudo cp -r ~/.ngrok2 ~buildkite-agent/ && sudo chown -R buildkite-agent:buildkite--agent ~buildkite-agent/ngrok2`
    88  24. Add `buildkite-agent` to `sudo` group in `/etc/groups`
    89  25. Give `buildkite-agent` a password with `sudo passwd buildkite-agent`
    90  26. As `buildkite-agent` user `mkcert -install`
    91  
    92  ## Additional Windows Setup for WSL2+Docker-Inside Testing
    93  
    94  1. Uninstall Docker Desktop.
    95  2. Remove all of the entries (especially `host.docker.internal`) that Docker Desktop has added in `C:\Windows\system32\drivers\etc\hosts`.
    96  3. Install docker and basics in WSL2:
    97  
    98      ```bash
    99      sudo mkdir -p /etc/apt/keyrings
   100      sudo mkdir -p /etc/apt/keyrings && sudo rm -f /etc/apt/keyrings/docker.gpg && curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
   101      echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
   102      sudo apt update && sudo apt install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
   103      sudo usermod -aG docker $USER
   104     ```
   105  
   106  4. Configure buildkite agent in /etc/buildkite-agent:
   107      * tags="os=wsl2,architecture=amd64,dockertype=wsl2"
   108      * token="xxx"
   109      * Create `/etc/buildkite-agent/hooks/environment` and set to executable with contents:
   110  
   111      ```
   112         #!/bin/bash
   113         export DOCKERHUB_PULL_USERNAME=druddockerpullaccount
   114         export DOCKERHUB_PULL_PASSWORD=xxx
   115         set -e
   116     ```
   117  
   118  5. Run `.buildkite/sanetestbot.sh`
   119  
   120  ## macOS Test Agent Setup (Intel and Apple Silicon)
   121  
   122  1. Create the user “testbot” on the machine. Use the password for `ddevtestbot@gmail.com`, available in LastPass.
   123  2. Change the name of the machine to something in keeping with current style. Maybe `testbot-macstadium-macos-3`.
   124  3. Install [Homebrew](https://brew.sh/) `/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"`
   125  4. Install everything you’ll need with `brew install buildkite/buildkite/buildkite-agent  bats-core colima composer drud/ddev/ddev git golang jq mariadb mkcert netcat p7zip  && brew install --cask docker iterm2 google-chrome nosleep ngrok`.
   126  5. Run `ngrok config add-authtoken <token>` with token for free account.
   127  6. Run `mkcert -install`.
   128  7. Run Docker manually and go through its configuration routine.
   129  8. Run iTerm. On Mojave and higher you may need to allow full disk access permissions.
   130  9. Set up `nfsd` by running `macos_ddev_nfs_setup.sh`.
   131  10. `git config --global --add safe.directory '*'`
   132  11. Edit `/usr/local/etc/buildkite-agent/buildkite-agent.cfg` or `/opt/homebrew/etc/buildkite-agent/buildkite-agent.cfg` to add
   133      * the agent token
   134      * tags, like `"os=macos,architecture=arm64,osvariant=monterrey,dockertype=dockerformac"`
   135      * `build-path="~/tmp/buildkite-agent/builds"`
   136  12. The buildkite/hooks/environment file must be updated to contain the Docker pull credentials:
   137  
   138      ```bash
   139         #!/bin/bash
   140         export DOCKERHUB_PULL_USERNAME=druddockerpullaccount
   141         export DOCKERHUB_PULL_PASSWORD=xxx
   142         set -e
   143      ```
   144  
   145  13. Run `brew services start buildkite-agent`.
   146  14. Manually run `testbot_maintenance.sh`, `curl -sL -O https://raw.githubusercontent.com/drud/ddev/master/.buildkite/testbot_maintenance.sh && bash testbot_maintenance.sh`.
   147  15. Enable nosleep using its shortcut in the Mac status bar.
   148  16. In nosleep Preferences, enable “Never sleep on AC Adapter”, “Never sleep on Battery”, and “Start nosleep utility on system startup”.
   149  17. `sudo chown testbot /usr/local/bin`
   150  18. Set up Mac to [automatically log in on boot](https://support.apple.com/en-us/HT201476).
   151  19. Try checking out [drud/ddev](https://github.com/drud/ddev) and running `.buildkite/sanetestbot.sh` to check your work.
   152  20. Log into Chrome with the user `ddevtestbot@gmail.com` and enable Chrome Remote Desktop.
   153  21. Set the timezone (US MT).
   154  22. Start the agent with `brew services start buildkite-agent`.