Skip to content

Commit

Permalink
We don't need the fancy GOPATH stuff we used to use now with go v1.11 (
Browse files Browse the repository at this point in the history
…#1331)

* Use golang v1.11 outside-of-GOPATH building strategy, the new norm, with both buildkite and circleci builds
* Fiddle with .gitattributes as It was once again broken in some Windows situations.
* Bump docker-compose and golang versions in circleci build
* Introduce .editorconfig documenting use of LF not CRLF
  • Loading branch information
rfay committed Jan 2, 2019
1 parent 8121205 commit 0a13a19
Show file tree
Hide file tree
Showing 12 changed files with 110 additions and 93 deletions.
16 changes: 7 additions & 9 deletions .buildkite/test.sh
Expand Up @@ -2,15 +2,7 @@

# This script is used to build drud/ddev using buildkite

# Manufacture a $GOPATH environment that can mount on docker (when buildkite build)
if [ ! -z "$BUILDKITE_JOB_ID" ]; then
export GOPATH=~/tmp/buildkite/$BUILDKITE_JOB_ID
DRUDSRC=$GOPATH/src/github.com/drud
mkdir -p $DRUDSRC
ln -s $PWD $DRUDSRC/ddev
cd $DRUDSRC/ddev
echo "--- buildkite building $BUILDKITE_JOB_ID at $(date) on $(hostname) for OS=$(go env GOOS) in $DRUDSRC/ddev"
fi
echo "--- buildkite building ${BUILDKITE_JOB_ID:-} at $(date) on $(hostname) for OS=$(go env GOOS) in $PWD with golang=$(go version) docker=$(docker version --format '{{.Server.Version}}') and docker-compose $(docker-compose version --short)"

export GOTEST_SHORT=1
export DRUD_NONINTERACTIVE=true
Expand All @@ -32,6 +24,12 @@ set -x

rm -rf ~/.ddev/Test*

# There are discrepancies in golang hash checking in 1.11+, so kill off modcache to solve.
# See https://github.com/golang/go/issues/27925
# This can probably be removed when current work is merged 2018-12-27
# go clean -modcache (Doesn't work due to current bug in golang)
chmod -R u+w ~/go/pkg && rm -rf ~/go/pkg/*

# Our testbot should now be sane, run the testbot checker to make sure.
./.buildkite/sanetestbot.sh

Expand Down
9 changes: 8 additions & 1 deletion .buildkite/test_containers.sh
Expand Up @@ -6,7 +6,8 @@ set -o errexit
set -o pipefail
set -o nounset

echo "--- buildkite building ${BUILDKITE_JOB_ID:-} at $(date) on $(hostname) for OS=$(go env GOOS) in ${PWD}"
echo "--- buildkite building ${BUILDKITE_JOB_ID:-} at $(date) on $(hostname) for OS=$(go env GOOS) in $PWD with golang=$(go version) docker=$(docker version --format '{{.Server.Version}}') and docker-compose $(docker-compose version --short)"


function cleanup {
set +x
Expand Down Expand Up @@ -34,6 +35,12 @@ trap cleanup EXIT
# Do initial cleanup of images that might not be needed; they'll be cleaned at exit as well.
cleanup

# There are discrepancies in golang hash checking in 1.11+, so kill off modcache to solve.
# See https://github.com/golang/go/issues/27925
# This can probably be removed when current work is merged 2018-12-27
# go clean -modcache (Doesn't work due to current bug in golang)
chmod -R u+w ~/go/pkg && rm -rf ~/go/pkg/*

# Our testbot should now be sane, run the testbot checker to make sure.
./.buildkite/sanetestbot.sh

Expand Down
4 changes: 2 additions & 2 deletions .circleci/circle_vm_setup.sh
Expand Up @@ -10,13 +10,13 @@ sudo apt-get install -qq mysql-client realpath zip nsis jq expect

# golang of the version we want
sudo apt-get remove -qq golang && sudo rm -rf /usr/local/go &&
wget -q -O /tmp/golang.tgz https://dl.google.com/go/go1.11.linux-amd64.tar.gz &&
wget -q -O /tmp/golang.tgz https://dl.google.com/go/go1.11.4.linux-amd64.tar.gz &&
sudo tar -C /usr/local -xzf /tmp/golang.tgz


# docker-compose
sudo rm -f /usr/local/bin/docker-compose
sudo curl -s -L "https://github.com/docker/compose/releases/download/1.23.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo curl -s -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

# Remove existing docker and install from their apt package
Expand Down
26 changes: 8 additions & 18 deletions .circleci/config.yml
Expand Up @@ -3,12 +3,10 @@ jobs:
golang_build:
machine:
image: circleci/classic:201711-01
working_directory: ~/go/src/github.com/drud/ddev
working_directory: ~/ddev
environment:
GOPATH: /home/circleci/go
DRUD_NONINTERACTIVE: "true"
steps:
- run: mkdir -p ~/go/{lib,pkg,src/github.com/drud/ddev}
- checkout
- run:
command: ./.circleci/circle_vm_setup.sh
Expand All @@ -20,14 +18,13 @@ jobs:
name: Build the ddev executables
- persist_to_workspace:
root: ~/
paths: go
paths: ddev

golang_test_nginx_fpm:
machine:
image: circleci/classic:201711-01
working_directory: ~/go/src/github.com/drud/ddev
working_directory: ~/ddev
environment:
GOPATH: /home/circleci/go
DDEV_TEST_WEBSERVER_TYPE: nginx-fpm
DRUD_NONINTERACTIVE: "true"
steps:
Expand All @@ -48,9 +45,8 @@ jobs:
golang_test_apache_fpm:
machine:
image: circleci/classic:201711-01
working_directory: ~/go/src/github.com/drud/ddev
working_directory: ~/ddev
environment:
GOPATH: /home/circleci/go
DDEV_TEST_WEBSERVER_TYPE: apache-fpm
# Experiment with only testing TYPO3 with the apache run.
GOTEST_SHORT: 5
Expand All @@ -73,9 +69,8 @@ jobs:
golang_test_apache_cgi:
machine:
image: circleci/classic:201711-01
working_directory: ~/go/src/github.com/drud/ddev
working_directory: ~/ddev
environment:
GOPATH: /home/circleci/go
DDEV_TEST_WEBSERVER_TYPE: apache-cgi
# Experiment with only testing TYPO3 with the apache run.
GOTEST_SHORT: 5
Expand All @@ -96,9 +91,8 @@ jobs:
staticrequired:
machine:
image: circleci/classic:201711-01
working_directory: ~/go/src/github.com/drud/ddev
working_directory: ~/ddev
environment:
GOPATH: /home/circleci/go
ARTIFACTS: /artifacts
steps:
- attach_workspace:
Expand All @@ -114,9 +108,8 @@ jobs:
artifacts:
machine:
image: circleci/classic:201711-01
working_directory: ~/go/src/github.com/drud/ddev
working_directory: ~/ddev
environment:
GOPATH: /home/circleci/go
ARTIFACTS: /artifacts
steps:
- attach_workspace:
Expand All @@ -134,14 +127,11 @@ jobs:
tag_build:
machine:
image: circleci/classic:201711-01
working_directory: ~/go/src/github.com/drud/ddev
working_directory: ~/ddev
environment:
DRUD_DEBUG: "true"
GOPATH: /home/circleci/go
ARTIFACTS: /artifacts
steps:
- run: mkdir -p ~/go/{lib,pkg,src/github.com/drud/ddev}

- checkout

- run:
Expand Down
9 changes: 9 additions & 0 deletions .editorconfig
@@ -0,0 +1,9 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
20 changes: 11 additions & 9 deletions .gitattributes
@@ -1,11 +1,13 @@
# On Windows the wrong line endings break docker containers
# Article: https://help.github.com/articles/dealing-with-line-endings/
* text=auto
/containers text eol=lf
.gitignore text
*.png binary
*.jpg binary
*.tqr binary
*gz binary
*MY? binary
# Helpful examples: https://github.com/alexkaratarakis/gitattributes
# Way more than you can stand to read: https://git-scm.com/docs/gitattributes

# In general on this project there's no reason to have git changing line endings.
# Modern editors can do the right thing with lf and should be set to do so, whether
# on Windows or elsewhere.
# The incredibly big gotcha here is that if a *.sh gets checked out on WIndows with CRLF and then built
# into a container with the CRLF, it can't run in linux.

# text=false here essentially is the same as core.autocrlf=false
* text=false eol=lf

2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -86,7 +86,7 @@ testpkg: setup
DDEV_NO_SENTRY=true CGO_ENABLED=0 go test -p 1 -timeout $(TEST_TIMEOUT) -v -installsuffix static -ldflags '$(LDFLAGS)' ./pkg/... $(TESTARGS)

setup:
@(mv -f ~/.ddev/global_config.yaml ~/.ddev/global_config.yaml.bak 2>/dev/null && echo "Warning: Moved your global ddev config file") || true
@(mv -f ~/.ddev/global_config.yaml ~/.ddev/global_config.yaml.bak 2>/dev/null && echo "Warning: Removed your global ddev config file") || true
@mkdir -p bin/darwin bin/linux
@mkdir -p .go/src/$(PKG) .go/pkg .go/bin .go/std/linux
mkdir -p $(TESTTMP)
Expand Down
100 changes: 53 additions & 47 deletions docs/developers/buildkite-testmachine-setup.md
@@ -1,47 +1,53 @@
<h1>Buildkite Test Agent Setup</h1>

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.

## Windows Test Agent Setup:

0. Create the user "testbot" on the machine. The password should be the password of testbot@drud.com.
1. Install [chocolatey](https://chocolatey.org/)
2. Install golang/mysql-cli/make/git/docker-ce/nssm with `choco install -y git mysql-cli golang make docker-desktop nssm GoogleChrome zip jq composer cmder` (If docker-toolbox, use that instead; you may have to download the release separately to get correct version.)
3. Enable gd and curl extensions in /c/tools/php73/php.ini
3. Install bats: `git clone git://github.com/bats-core/bats-core; cd bats-core; git checkout v1.1.0; ./install.sh`
3. If a laptop, set the "lid closing" setting in settings to do nothing.
4. Set the "Sleep after time" setting in settings to never.
5. Install the buildkite-agent. Use the latest release from [github.com/buildkite/agent](https://github.com/buildkite/agent/releases). It should go in /c/buildkite-agent, with the buildkite-agent.exe in /c/buildkite-agent/bin and the config in /c/buildkite-agent.
6. Update the buildkite-agent.cfg with the *token* and *tags*. Tags will probably be like `"os=windows,osvariant=windows10pro,dockertype=dockerforwindows"` or `"os=windows,osvariant=windows10pro,dockertype=toolbox"`.
7. Set up the agent to [run as a service](https://buildkite.com/docs/agent/v3/windows#running-as-a-service):
- __on the "Log On" tab in the services widget it must be set up to log in as the primary user of the machine, so it inherits environment variables and home directory.__
8. Set up the machine to [automatically log in on boot](https://www.cnet.com/how-to/automatically-log-in-to-your-windows-10-pc/). Run netplwiz, provide the password for the main user, uncheck the "require a password to log in".
9. On Docker Toolbox systems, add a link to "Docker Quickstart Terminal" in C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp (see [link](http://www.thewindowsclub.com/make-programs-run-on-startup-windows)).
10. On Docker-for-windows systems, launch Docker. It will offer to reconfigure Hyper-V and do a restart.
11. On Docker-for-windows, configured the C: and other drives as shared to docker.
12. On Docker Toolbox systems, make sure that nested virtualization is enabled however you need to enable it.
13. Edit /c/ProgramData/git/config to `autocrlf: false` and verify that `git config --list` shows only autocrlf: false.
14. Run `winpty docker run -it -p 80 busybox ls` to trigger the Windows Defender warning, and "allow access".
15. Try running .buildkite/sanetestbot.sh to check your work.
16. Change the name of the machine to something in keeping with current style. Maybe `testbot-dell-toolbox-3`.
17. Reboot the machine and do a test run. (On windows the machine name only takes effect on reboot.)
18. Set the timezone properly (US MT)
19. Log into Chrome with the user testbot@drud.com and enable Chrome Remote Desktop.

### macOS Test Agent Setup

0. Create the user "testbot" on the machine. The password should be the password of testbot@drud.com.
1. Install [homebrew](https://brew.sh/)
2. Install golang/git/docker with `brew install golang git buildkite-agent mariadb jq p7zip bats-core composer`
3. Install docker with `brew cask install docker`
4. If the xcode command line tools are not yet installed, install them with `xcode select --install`
5. Edit the buildkite-agent.cfg in /usr/local/etc/buildkite-agent.cfg to add the agent token and the tags. Tags will probably be like `"os=macos,osvariant=highsierra,dockertype=dockerformac"` - Also edit with `build-path="~/tmp/buildkite-agent/builds"`
6. Install nosleep `brew cask install nosleep`
7. Enable nosleep using its shortcut in the Mac status bar.
8. In nosleep Preferences, enable "Never sleep on AC Adapter", "Never sleep on Battery", and "Start nosleep utility on system startup".
9. Set up Mac to [automatically log in on boot](https://support.apple.com/en-us/HT201476).
10. Try running .buildkite/sanetestbot.sh to check your work.
11. Change the name of the machine to something in keeping with current style. Maybe `testbot-mbp2017-macos-3`.
12. Log into Chrome with the user testbot@drud.com and enable Chrome Remote Desktop.
13. Set the timezone properly (US MT)
14. Reboot the machine and do a test run.
<h1>Buildkite Test Agent Setup</h1>

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.

## Windows Test Agent Setup:

0. Create the user "testbot" on the machine. The password should be the password of testbot@drud.com.
1. Install [chocolatey](https://chocolatey.org/)
2. Install golang/mysql-cli/make/git/docker-ce/nssm with `choco install -y git mysql-cli golang make docker-desktop nssm GoogleChrome zip jq composer cmder` (If docker-toolbox, use that instead; you may have to download the release separately to get correct version.)
3. Enable gd and curl extensions in /c/tools/php73/php.ini
3. Install bats: `git clone git://github.com/bats-core/bats-core; cd bats-core; git checkout v1.1.0; ./install.sh`
3. If a laptop, set the "lid closing" setting in settings to do nothing.
4. Set the "Sleep after time" setting in settings to never.
5. Install the buildkite-agent. Use the latest release from [github.com/buildkite/agent](https://github.com/buildkite/agent/releases). It should go in /c/buildkite-agent, with the buildkite-agent.exe in /c/buildkite-agent/bin and the config in /c/buildkite-agent.
6. Update the buildkite-agent.cfg
* *token*
* *tags*: Tags will probably be like `"os=windows,osvariant=windows10pro,dockertype=dockerforwindows"` or `"os=windows,osvariant=windows10pro,dockertype=toolbox"`
* build-path: "C:\Users\testbot\tmp\buildkite" on Windows. (This is to get it to build in the home directory; by default docker toolbox won't mount anything outside the home directory.)
7. Set up the agent to [run as a service](https://buildkite.com/docs/agent/v3/windows#running-as-a-service):
- __on the "Log On" tab in the services widget it must be set up to log in as the primary user of the machine, so it inherits environment variables and home directory.__
8. Set up the machine to [automatically log in on boot](https://www.cnet.com/how-to/automatically-log-in-to-your-windows-10-pc/). Run netplwiz, provide the password for the main user, uncheck the "require a password to log in".
9. On Docker Toolbox systems, add a link to "Docker Quickstart Terminal" in C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp (see [link](http://www.thewindowsclub.com/make-programs-run-on-startup-windows)).
10. On Docker-for-windows systems, launch Docker. It will offer to reconfigure Hyper-V and do a restart.
11. On Docker-for-windows, configured the C: and other drives as shared to docker.
12. On Docker Toolbox systems, make sure that nested virtualization is enabled however you need to enable it.
13. Edit /c/ProgramData/git/config "core" section to `autocrlf: false` and `eol: lf` verify that `git config --list` shows only autocrlf: false.
14. Run `winpty docker run -it -p 80 busybox ls` to trigger the Windows Defender warning, and "allow access".
15. Try running .buildkite/sanetestbot.sh to check your work.
16. Install ddev using the ddev_windows_installer.exe from https://github.com/drud/ddev/releases
16. Change the name of the machine to something in keeping with current style. Maybe `testbot-dell-toolbox-3`.
17. Reboot the machine and do a test run. (On windows the machine name only takes effect on reboot.)
18. Set the timezone properly (US MT)
19. Log into Chrome with the user testbot@drud.com and enable Chrome Remote Desktop.

### macOS Test Agent Setup

0. Create the user "testbot" on the machine. The password should be the password of testbot@drud.com.
1. Change the name of the machine to something in keeping with current style. Maybe `testbot-macstadium-macos-3`.
1. Install [homebrew](https://brew.sh/) `xcode select --install` and `/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"`
2. Install golang/git/docker with `brew cask install item2 google-chrome docker nosleep && brew tap buildkite/buildkite && brew tap drud/ddev && brew install golang git buildkite-agent mariadb jq p7zip bats-core composer ddev`
4. If the xcode command line tools are not yet installed, install them with `xcode select --install`
5. Edit the buildkite-agent.cfg in /usr/local/etc/buildkite-agent.cfg to add
* the agent token
* Tags, like `"os=macos,osvariant=highsierra,dockertype=dockerformac"`
* `build-path="~/tmp/buildkite-agent/builds"`
7. Enable nosleep using its shortcut in the Mac status bar.
8. In nosleep Preferences, enable "Never sleep on AC Adapter", "Never sleep on Battery", and "Start nosleep utility on system startup".
9. Set up Mac to [automatically log in on boot](https://support.apple.com/en-us/HT201476).
10. Try checking out ddev and running .buildkite/sanetestbot.sh to check your work.
12. Log into Chrome with the user testbot@drud.com and enable Chrome Remote Desktop.
13. Set the timezone properly (US MT)
14. Start the agent with `brew services start buildkite-agent`
15. Reboot the machine and do a test run.
3 changes: 1 addition & 2 deletions docs/developers/release-checklist.md
@@ -1,6 +1,5 @@
## `ddev` Release Checklist

- [ ] For each container directory in `containers/`, `make push VERSION=vXXX` to ensure the current container version exists for building and testing
- [ ] Create provisional tagged images. `git fetch upstream && git checkout upstream/master && cd containers` and `foreach item in *; do pushd $item; make push VERSION=<release_version> DOCKER_ARGS=--no-cache ; popd; done`
- [ ] Update the default container versions in `pkg/version/version.go` and create a pull request
- [ ] Once all updates have been merged into the master branch, [create a release](https://github.com/drud/ddev/releases/new) for the new version, initiating a tag build
- [ ] Add the commit list (`git log vXXX..vYYY --oneline`) to the release page
Expand Down
6 changes: 3 additions & 3 deletions go.sum
Expand Up @@ -22,7 +22,7 @@ github.com/containerd/continuity v0.0.0-20180712174259-0377f7d76720 h1:T5LkgEMAC
github.com/containerd/continuity v0.0.0-20180712174259-0377f7d76720/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/docker/docker v0.0.0-20180412203414-a422774e593b h1:U8rMuph30gZe7TXgrQDMop5ozo6NB0+HALAvdUNWbX4=
github.com/docker/docker v0.0.0-20180412203414-a422774e593b h1:o310bMt6vG6Df/APyAprOkV5DOI7nYoS3S6YB9dqxNM=
github.com/docker/docker v0.0.0-20180412203414-a422774e593b/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/go-connections v0.3.0 h1:3lOnM9cSzgGwx8VfK/NGOW5fLQ0GjIlCkaktF+n1M6o=
github.com/docker/go-connections v0.3.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
Expand Down Expand Up @@ -59,7 +59,7 @@ github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e h1:JKmoR8x90Iww1
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gosuri/uitable v0.0.0-20160404203958-36ee7e946282 h1:KFqmdzEPbU7Uck2tn50t+HQXZNVkxe8M9qRb/ZoSHaE=
github.com/gosuri/uitable v0.0.0-20160404203958-36ee7e946282/go.mod h1:tKR86bXuXPZazfOTG1FIzvjIdXzd0mo4Vtn16vt0PJo=
github.com/gotestyourself/gotestyourself v2.2.0+incompatible h1:1yOKgt0XYKUg1HOKunGOSt2ocU4bxLCjmIHt0vRtVHM=
github.com/gotestyourself/gotestyourself v2.2.0+incompatible h1:AQwinXlbQR2HvPjQZOmDhRqsv5mZf+Jb1RnSLxcqZcI=
github.com/gotestyourself/gotestyourself v2.2.0+incompatible/go.mod h1:zZKM6oeNM8k+FRljX1mnzVYeS8wiGgQyvST1/GafPbY=
github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce h1:xdsDDbiBDQTKASoGEZ+pEmF1OnWuu8AQ9I8iNbHNeno=
github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce/go.mod h1:oZtUIOe8dh44I2q6ScRibXws4Ajl+d+nod3AaR9vL5w=
Expand Down Expand Up @@ -158,5 +158,5 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkep
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gotest.tools v2.2.0+incompatible h1:y0IMTfclpMdsdIbr6uwmJn5/WZ7vFuObxDMdrylFM3A=
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=

0 comments on commit 0a13a19

Please sign in to comment.