github.com/secure-build/gitlab-runner@v12.5.0+incompatible/docs/development/README.md (about) 1 # Development environment 2 3 ## 1. Install dependencies and Go runtime 4 5 ### For Debian/Ubuntu 6 7 ```bash 8 sudo apt-get install -y mercurial git-core wget make build-essential 9 wget https://storage.googleapis.com/golang/go1.10.8.linux-amd64.tar.gz 10 sudo tar -C /usr/local -xzf go*-*.tar.gz 11 ``` 12 13 ### For macOS 14 15 Using binary package: 16 17 ```sh 18 wget https://storage.googleapis.com/golang/go1.10.8.darwin-amd64.tar.gz 19 sudo tar -C /usr/local -xzf go*-*.tar.gz 20 ``` 21 22 Using installation package: 23 24 ```sh 25 wget https://storage.googleapis.com/golang/go1.10.8.darwin-amd64.pkg 26 open go*-*.pkg 27 ``` 28 29 NOTE: **Note:** 30 Brew doesn't provide a [Go 1.8.x formula](https://formulae.brew.sh/formula/go). 31 32 ### For FreeBSD 33 34 ``` 35 pkg install go-1.10.8 gmake git mercurial 36 ``` 37 38 ## 2. Install Docker Engine 39 40 The Docker Engine is required to create pre-built image that is embedded into runner and loaded when using docker executor. 41 42 To install Docker, follow the Docker [installation 43 instructions](https://docs.docker.com/install/) for your OS. 44 45 Make sure that on machine that is running your Docker Engine you have a `binfmt_misc`. 46 This is required to be able to build ARM images that are embedded into GitLab Runner binary. 47 48 - For Debian/Ubuntu it's sufficient to execute: 49 50 ``` 51 sudo apt-get install binfmt-support qemu-user-static 52 ``` 53 54 - For Docker for MacOS/Windows `binfmt_misc` is enabled by default. 55 56 - For CoreOS (but also works on Debian and Ubuntu) you need to execute the following script on system start: 57 58 ``` 59 #!/bin/sh 60 61 set -xe 62 63 /sbin/modprobe binfmt_misc 64 65 mount -t binfmt_misc binfmt_misc /proc/sys/fs/binfmt_misc 66 67 # Support for ARM binaries through Qemu: 68 { echo ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-arm-static:' > /proc/sys/fs/binfmt_misc/register; } 2>/dev/null 69 { echo ':armeb:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-armeb-static:' > /proc/sys/fs/binfmt_misc/register; } 2>/dev/null 70 ``` 71 72 ## 3. Configure Go 73 74 Add to `.profile` or `.bash_profile`: 75 76 ```bash 77 export GOPATH=$HOME/Go 78 export PATH=$PATH:$GOPATH/bin:/usr/local/go/bin 79 ``` 80 81 Create new terminal session and create $GOPATH directory: 82 83 ``` 84 mkdir -p $GOPATH 85 ``` 86 87 ## 4. Download runner sources 88 89 ``` 90 go get gitlab.com/gitlab-org/gitlab-runner 91 cd $GOPATH/src/gitlab.com/gitlab-org/gitlab-runner/ 92 ``` 93 94 ## 5. Install runner dependencies 95 96 This will download and restore all dependencies required to build runner: 97 98 ``` 99 make deps 100 ``` 101 102 **For FreeBSD use `gmake deps`** 103 104 ## 6. Run runner 105 106 Normally you would use `gitlab-runner`, in order to compile and run Go source use go toolchain: 107 108 ``` 109 make install 110 gitlab-runner run 111 ``` 112 113 You can run runner in debug-mode: 114 115 ``` 116 make install 117 gitlab-runner --debug run 118 ``` 119 120 ## 7. Compile and install runner binary as `gitlab-runner` 121 122 ``` 123 make install 124 ``` 125 126 ## 8. Run test suite locally 127 128 GitLab Runner test suite consists of "core" tests and tests for executors. 129 Tests for executors require certain binaries to be installed on your local 130 machine. Some of these binaries cannot be installed on all operating 131 systems. If a binary is not installed tests requiring this binary will be 132 skipped. 133 134 These are the binaries that you can install: 135 136 1. [VirtualBox](https://www.virtualbox.org/wiki/Downloads) and [Vagrant](https://www.vagrantup.com/downloads.html) 137 1. [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) with 138 [Minikube](https://github.com/kubernetes/minikube) 139 1. [Parallels](https://www.parallels.com/products/desktop/download/) 140 1. [PowerShell](https://docs.microsoft.com/en-us/powershell/) 141 142 After installing the binaries run: 143 144 ``` 145 make development_setup 146 ``` 147 148 To execute the tests run: 149 150 ``` 151 make test 152 ``` 153 154 ## 9. Contribute 155 156 You can start hacking GitLab-Runner code. If you are interested you can use Intellij IDEA Community Edition with [go-lang-idea-plugin](https://github.com/go-lang-plugin-org/go-lang-idea-plugin) to edit and debug code. 157 158 ## Managing build dependencies 159 160 GitLab Runner uses [dep](https://github.com/golang/dep) to manage 161 its dependencies - they get checked into the repository under the `vendor/` directory, 162 with a manifest stored in `Godep.toml` and in `Godep.lock` lockfile. 163 164 If your contribution adds, removes or updates any dependencies to the runner, 165 please ensure the vendored copies is updated with the appropriate `dep ensure` command. 166 167 Don't add dependency from upstream master branch when version tags are available. 168 169 ## Developing for Windows on a non-windows environment 170 171 We provide a [Vagrantfile](https://gitlab.com/gitlab-org/gitlab-runner/tree/master/Vagrantfile) 172 to help you run a Windows Server 2019 or Windows 10 instance, since we 173 are using [multiple machines](https://www.vagrantup.com/docs/multi-machine/) inside of Vagrant. 174 175 The following are required: 176 177 - [Vagrant](https://www.vagrant.com) installed. 178 - [Virtualbox](https://www.virtualbox.com) installed. 179 - Around 30GB of free hard disk space on your computer. 180 181 Which virtual machine to use depends on your use case: 182 183 - The Windows Server machine has docker pre-installed and should always 184 be used when you are developing on Runner for Windows. 185 - The Windows 10 machine is there for you to have a windows environment 186 with a GUI which sometimes can help you debugging some Windows 187 features. Note that you cannot have Docker running inside of Windows 188 10 because nested virtualization is not supported. 189 190 Running `vagrant up windows_10` will start the Windows 10 machine for 191 you. To: 192 193 - ssh inside of the Windows 10 machine, run `vagrant ssh windows_10`. 194 - Access the GUI for the Windows 10, you can connect via 195 RDP by running `vagrant rdp windows_10`, which will connect to the 196 machine using a locally installed RDP program. 197 198 For both machines, the GitLab Runner source code is synced 199 bi-directionally so that you can edit from your machine with your 200 favorite editor. The source code can be found under the `$GOROOT` 201 environment variable. We have a `RUNNER_SRC` environment variable which 202 you can use to find out the full path so when using: 203 204 - Windows batch scripts, you can run `cd %RUNNER_SRC`. 205 - PowerShell, you can use `cd $Env:RUNNER_SRC`. 206 207 ## Troubleshooting 208 209 ### executor_docker.go missing Asset symbol 210 211 This error happens due to missing executors/docker/bindata.go file that is generated from docker prebuilts. 212 Which is especially tricky on Windows. 213 214 Try to execute: `make deps docker`, if it doesn't help you can do that in steps: 215 216 1. Execute `go get -u github.com/jteeuwen/go-bindata/...` 217 1. Download <https://gitlab-runner-downloads.s3.amazonaws.com/master/docker/prebuilt-x86_64.tar.xz> and save to `out/docker/prebuilt-x86_64.tar.xz` 218 1. Download <https://gitlab-runner-downloads.s3.amazonaws.com/master/docker/prebuilt-arm.tar.xz> and save to `out/docker/prebuilt-arm.tar.xz` 219 1. Execute `make docker` or check the Makefile how this command looks like