Commit cc7fc7ad authored by Tomasz Maczukin's avatar Tomasz Maczukin

Add dependencies management documentation and scripting

parent 9e861f93
......@@ -8,6 +8,7 @@ dockerfiles/alpine/gitlab-ci-multi-runner-linux-amd64
dockerfiles/build/gitlab-runner-helper
dockerfiles/ubuntu/gitlab-ci-multi-runner_amd64.deb
.idea/
.editorconfig
tests/ubuntu/.vagrant
artifacts
tmp/gitlab-test
......
......@@ -14,24 +14,3 @@ By submitting code as an individual you agree to the
[individual contributor license agreement](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/legal/individual_contributor_license_agreement.md).
By submitting code as an entity you agree to the
[corporate contributor license agreement](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/legal/corporate_contributor_license_agreement.md).
## Managing build dependencies
GitLab Runner uses [Godep](https://github.com/tools/godep) to manage its dependencies - they get checked into the repository under the `vendor/` directory, with a manifest
stored in `Godeps/Godeps.json`.
If your contribution adds, removes or updates any dependencies to the runner,
please ensure the vendored copies updated in lock-step. If you're new to Go, or
Godep, here is a conservative process to follow:
* Start with a completely empty GOPATH with the right Go version (currently 1.7.1). [GVM](https://github.com/moovweb/gvm) makes this easy.
* Clone the repository into this GOPATH, e.g.: `go get gitlab.com/gitlab-org/gitlab-ci-multi-runner`
* Run `go get github.com/tools/godep`
* Change directory: `cd $GOPATH/src/gitlab.com/gitlab-org/gitlab-ci-multi-runner`
* Run `godep restore -v && rm -rf Godeps vendor` to un-vendor the dependencies.
* Make your changes, running `go get [-u] <packages>` as necessary to add or update packages.
* When finished, run `godep save -v ./...` to recreate the Godeps and vendor directories
* Check that all the added or changed dependencies are compatible with the runner's [license](LICENSE).
* Commit your changes in one commit (or set of commits), followed by the changes to `Godeps` and `vendor/` in a final commit, then push to a fork or branch.
* Check out your branch in a new clean GOPATH and ensure `make verify` runs without error.
* Open a merge request!
......@@ -384,4 +384,8 @@ development_setup:
if prlctl --version ; then $(MAKE) -C tests/ubuntu parallels ; fi
if vboxmanage --version ; then $(MAKE) -C tests/ubuntu virtualbox ; fi
update_govendor_dependencies:
# updating vendor/ dependencies
@./scripts/update-govendor-dependencies
FORCE:
......@@ -148,6 +148,58 @@ make test
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.
## Managing build dependencies
GitLab Runner uses [Govendor](https://github.com/kardianos/govendor) to manage
its dependencies - they get checked into the repository under the `vendor/` directory,
with a manifest stored in `vendor/vendor.json`.
If your contribution adds, removes or updates any dependencies to the runner,
please ensure the vendored copies updated in lock-step.
**For added/removed dependencies:**
1. Run `go get [package]` (if you haven't done this already) to download required package into your `$GOPATH`.
Repeat this for any added package.
1. Commit all added changes and stash/remove all uncommited changes to have a clean working directory.
1. Execute
```bash
$ make update_govendor_dependencies
```
This task will:
* remove all unused packages with,
* add all missing or external packages (packages that are not stored in vendor but can be found in `$GOPATH`),
* show git status and ask if changes in `vendor/` or done properly,
* show diff of `vendor/vendor.json` and ask if it is done properly,
* add and commit changes in `vendor/` directory.
**For dependencies that need update:**
1. Run `go get -u [package]` (if you haven't done this already) to upload selected package present in your `$GOPATH`
or download it if it's not present.
If you want to use specific version then go to the package directory in your `$GOPATH` and checkout it to this
version, e.g.:
```bash
$ cd $GOPATH/src/github.com/docker/docker/client
$ git checkout v1.13.0
```
Repeat this for any added package.
1. Execute
```bash
$ make update_govendor_dependencies
```
This task will behave just like described above.
## Troubleshooting
### executor_docker.go missing Asset symbol
......
#!/bin/bash
set -e
confirm_changes() {
echo -e "\nDoes this look OK [yes/no]? "
read -e input
input=$(echo "${input}" | tr '[:upper:]' '[:lower:]')
if [ "${input}" != "yes" ]; then
exit 1
fi
}
gitWorkdirStatus=$(git status --porcelain | grep -v -e "vendor/" -e scripts/update-govendor-dependencies || echo '')
if [[ -n "${gitWorkdirStatus}" ]]; then
echo "Your git working directory contains uncommited changes and/or untracked files"
echo "Please cleanup your working directory (commit, stash or remove changes) before updating govendor dependencies"
fi
echo "Removing unused packages"
govendor remove +unused
echo "Adding missing and external packages"
for package in $(govendor list --no-status +outside | grep -v "^appengine"); do
echo "Updating ${package}..."
govendor add ${package}
done
echo -e "\nChanges in vendor/"
git status --short
confirm_changes
echo -e "\nDiff of vendor/vendor.json"
git diff vendor/vendor.json
confirm_changes
git add vendor/
git commit -m "Updating govendor dependencies"
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment