Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into feature/laravel-s…
Browse files Browse the repository at this point in the history
…upport
  • Loading branch information
NBZ4live committed May 19, 2020
2 parents 4a878b8 + e02a377 commit 968215e
Show file tree
Hide file tree
Showing 15 changed files with 82 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ workflows:
release_build:
jobs:
- release_build:
context: org-global
context: ddev-local
filters:
tags:
only:
Expand Down
9 changes: 0 additions & 9 deletions .githooks/pre-push.allchecks
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
#!/bin/sh

# markdownlint
markdownlint -o /tmp/mdlint.out *.md docs
if [ "$?" != "0" ]; then
echo "Markdownlint failed on these files:"
awk -F: '{ print $1 }' < "/tmp/mdlint.out" | sort -u
exit 1
fi
set -o errexit

# Look for uncommitted files, http://stackoverflow.com/a/2659808/215713
git diff-index --quiet HEAD || (echo "There are uncommitted files" && exit 1)

Expand Down
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ GOLANGCI_LINT_ARGS ?= --out-format=line-number --disable-all --enable=gofmt --en
WINDOWS_SUDO_VERSION=v0.0.1
WINNFSD_VERSION=2.4.0
NSSM_VERSION=2.24-101-g897c7ad
MKCERT_VERSION=v1.3.0
MKCERT_VERSION=v1.4.1

GOTESTSUM_FORMAT ?= short-verbose
TESTTMP=/tmp/testresults
Expand Down Expand Up @@ -129,9 +129,13 @@ packr2:
staticrequired: setup golangci-lint markdownlint mkdocs

markdownlint:
markdownlint *.md docs >/dev/null
@echo "markdownlint: "
@$(DOCKERTESTCMD) \
bash -c "markdownlint *.md docs >/dev/null 2>&1"
mkdocs:
mkdocs build -d /tmp/mkdocsbuild >/dev/null 2>&1
@echo "mkdocs: "
@$(DOCKERTESTCMD) \
bash -c "mkdocs build -d /tmp/mkdocsbuld >/dev/null 2>&1"

darwin_signed: darwin
@if [ -z "$(DDEV_MACOS_SIGNING_PASSWORD)" ] ; then echo "Skipping signing ddev for macOS, no DDEV_MACOS_SIGNING_PASSWORD provided"; else echo "Signing macOS ddev..."; \
Expand Down
8 changes: 5 additions & 3 deletions build-tools/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Build tools for standard makefile

**These build tools live at https://github.com/drud/build-tools**. If you are viewing this README in any other repository, it's important to know that modifications should **never** be made directly, and instead should be made to the base repository and pulled in via the instructions below.
**These build tools live at <https://github.com/drud/build-tools>**. If you are viewing this README in any other repository, it's important to know that modifications should **never** be made directly, and instead should be made to the base repository and pulled in via the instructions below.

These tools add standard components (sub-makefiles and build scripts) as well as example starters for the Makefile and .circleci/config.yml.

Expand All @@ -25,7 +25,7 @@ chmod +x build_update.sh
* Edit the sub-Makefiles included
* Update the variables at the top of the Makefile

## Additional chores when installing:
## Additional chores when installing

* Add the items from gitignore_example to the .gitignore in each directory that has a Makefile
* Update the project README.md to explain how to build - the target reminders in the paragraph below may be helpful.
Expand Down Expand Up @@ -71,11 +71,13 @@ If you're using Powershell instead of cmd, just prepend an `&` on the command, a
## Installed requirements

You'll need:

* docker-ce (will work with move versions and platforms)
* gnu make
* golang

On windows the building is somewhat more difficult due to the build being bash/linux/make-oriented, but support is provided. You need:

* [chocolatey](https://chocolatey.org/install) installed
* make for Windows 3.81 (Recommended package [choco install make](https://chocolatey.org/packages/make) on chocolatey.org)
* git for windows (Recommended package [choco install git](https://chocolatey.org/packages/git.install))
Expand All @@ -85,4 +87,4 @@ On windows the building is somewhat more difficult due to the build being bash/l

## Golang compiler component

golang projects and static analysis functions like gofmt are built in a container from drud/golang-build-container (from https://github.com/drud/golang-build-container). The version of the container is specified in build-tools.
golang projects and static analysis functions like gofmt are built in a container from drud/golang-build-container (from <https://github.com/drud/golang-build-container).> The version of the container is specified in build-tools.
File renamed without changes.
9 changes: 6 additions & 3 deletions build-tools/build_update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

set -e

base_url=$(curl -s -I https://github.com/drud/build-tools/releases/latest | awk '/^Location/ {gsub(/[\n\r]/,"",$2); printf "%s", $2}')
tag=${base_url##*/}
LATEST_RELEASE=$(curl -L -s -H 'Accept: application/json' https://github.com/drud/build-tools/releases/latest)
# The releases are returned in the format {"id":3622206,"tag_name":"hello-1.0.0.11",...}, we have to extract the tag_name.
LATEST_VERSION=$(echo $LATEST_RELEASE | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
URL="https://github.com/drud/build-tools/releases/download/$LATEST_VERSION"
tag=${LATEST_VERSION}

tarball_url="https://github.com/drud/build-tools/archive/$tag.tar.gz"
internal_name=build-tools-$tag
internal_name=build-tools-${tag#v}
local_file=/tmp/$internal_name.tgz

# If there is a current build-tools, get permission and remove
Expand Down
1 change: 0 additions & 1 deletion build-tools/makefile_components/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
Please do not change these files. They're intended to be replaceable globally in all repositories as our needs changed.

If one of these sections does not meet your needs, consider copying its contents into ../Makefile and commenting out the include and adding a comment about what you did and why.

2 changes: 1 addition & 1 deletion build-tools/makefile_components/base_build_go.mak
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ GOFILES = $(shell find $(SRC_DIRS) -name "*.go")

BUILD_OS = $(shell go env GOHOSTOS)

BUILD_IMAGE ?= drud/golang-build-container:v1.14.0
BUILD_IMAGE ?= drud/golang-build-container:v1.14.2

BUILD_BASE_DIR ?= $(PWD)

Expand Down
6 changes: 6 additions & 0 deletions cmd/ddev/cmd/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"github.com/drud/ddev/pkg/dockerutil"
"github.com/stretchr/testify/require"
"runtime"
"strings"
"testing"

Expand Down Expand Up @@ -219,6 +220,11 @@ func unmarshalJSONLogs(in string) ([]log.Fields, error) {
func TestCmdDescribeMissingProjectDirectory(t *testing.T) {
var err error
var out string

if runtime.GOOS == "windows" {
t.Skip("Skipping because unreliable on Windows")
}

assert := asrt.New(t)

projDir, _ := os.Getwd()
Expand Down
6 changes: 6 additions & 0 deletions cmd/ddev/cmd/pause_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/drud/ddev/pkg/dockerutil"
"github.com/stretchr/testify/require"
"os"
"runtime"
"testing"

"path/filepath"
Expand Down Expand Up @@ -64,6 +65,11 @@ func TestCmdPauseContainers(t *testing.T) {
func TestCmdPauseContainersMissingProjectDirectory(t *testing.T) {
var err error
var out string

if runtime.GOOS == "windows" {
t.Skip("Skipping because unreliable on Windows")
}

assert := asrt.New(t)

projDir, _ := os.Getwd()
Expand Down
2 changes: 1 addition & 1 deletion cmd/ddev/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Support: https://ddev.readthedocs.io/en/stable/#support`,
err := dockerutil.CheckDockerVersion(version.DockerVersionConstraint)
if err != nil {
if err.Error() == "no docker" {
if os.Args[1] != "version" && os.Args[1] != "config" {
if os.Args[1] != "version" {
util.Failed("Could not connect to docker. Please ensure Docker is installed and running.")
}
} else {
Expand Down
6 changes: 6 additions & 0 deletions cmd/ddev/cmd/start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/drud/ddev/pkg/dockerutil"
"github.com/stretchr/testify/require"
"path/filepath"
"runtime"
"testing"

"os"
Expand Down Expand Up @@ -62,6 +63,11 @@ func TestCmdStart(t *testing.T) {
func TestCmdStartMissingProjectDirectory(t *testing.T) {
var err error
var out string

if runtime.GOOS == "windows" {
t.Skip("Skipping because unreliable on Windows")
}

assert := asrt.New(t)

projDir, _ := os.Getwd()
Expand Down
5 changes: 5 additions & 0 deletions cmd/ddev/cmd/stop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ func TestCmdStop(t *testing.T) {
func TestCmdStopMissingProjectDirectory(t *testing.T) {
var err error
var out string

if runtime.GOOS == "windows" {
t.Skip("Skipping because unreliable on Windows")
}

assert := asrt.New(t)
projDir, _ := os.Getwd()

Expand Down
36 changes: 27 additions & 9 deletions docs/developers/building-contributing.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
# Building, Testing, and Contributing

## Pull Requests and PR Preparation

When preparing your pull request, please use a branch name like "2020_<your_username>_short_description" so that it's easy to track to you.

If you're doing a docs-only PR that does not require full testing, please add "[skip ci][ci skip]" to your commit messages; it saves a lot of testing resources.

## Docker Image changes

If you make changes to a docker image (like ddev-webserver), it won't have any effect unless you:

* You can build an image with a specific tag by going to the image directory (like containers/ddev-webserver) by just doing `make container VERSION=<branchname>` in the containers/ddev-webserver directory.
* Push a container to hub.docker.com. Push with the tag that matches your branch. Pushing to drud/ddev-webserver repo is easy to accomplish with `make push VERSION=<branchname>` **in the container directory**. You might have to use other techniques to push to another repo (`docker push`)
* Update pkg/version/version.go with the WebImg and WebTag that relate to the docker image you pushed.

## Building

If you have `make` and docker, you can build for your environment with just `make`. Since the Makefile uses docker to build, it's not generally essential to install go on your machine, although it will make things easier.
Build the project with `make` and your resulting executable will end up in .gotmp/bin/ddev (for Linux) or .gotmp/bin/windows_amd64/ddev.exe (for Windows) or .gotmp/bin/darwin/ddev (for macOS).

Build/test/check static analysis with:
Build/test/check static analysis with

```
make
Expand All @@ -16,26 +30,30 @@ Build/test/check static analysis with:
make staticrequired
```

The binaries are built into .gotmp/bin; although normal command-line `go build` or `go install` will work (and everything works fine with IDEs like Goland or vscode) the official build technique is via `make` which uses a completely consistent golang-build-container so that the build is identical no matter what machine or OS it might be built on.

## Testing

Normal test invocation is just `make test`. Run a single test with an invocation like `go test -v -run TestDevAddSites ./pkg/...` or `make testpkg TESTARGS="-run TestDevAddSites"`.
Normal test invocation is just `make test`. Run a single test with an invocation like `go test -v -run TestDevAddSites ./pkg/...` or `make testpkg TESTARGS="-run TestDevAddSites"`. The easiest way to run tests is from inside the excellent golang IDE Goland. Just click the arrowhead to the left of the test name.

To see which ddev commands the tests are executing, set the environment variable DDEV_DEBUG=true.

Use GOTEST_SHORT=true to run just one CMS in each test.
Use GOTEST_SHORT=true to run just one CMS in each test, or GOTEST_SHORT=<integer> to run exactly one project type from the list of project types in the [TestSites array](https://github.com/drud/ddev/blob/a4ab2827d8b6e706b2420700045d889a3a69f3f2/pkg/ddevapp/ddevapp_test.go#L43). For example, GOTEST_SHORT=5 will run many tests only against TYPO3.

## Automated testing

Anybody can view the CircleCI automated tests, and they usually show up any problems that are not OS-specific. Just click through on the testing section of the PR to see them.

The Buildkite automated tests require special access, which we typically grant to any PR contributor that asks for it.

## Docker container development
## Docker image development

The docker containers that ddev uses are included in the containers/ directory:
The docker images that ddev uses are included in the containers/ directory:

* containers/ddev-webserver: Provides the web servers (the "web" container).
* containers/ddev-dbserver: Provides the "db" container.
* containers/phpmyadmin: Provides the phpmyadmin (dba) container
* containers/ddev-router: The router image

When changes are made to a container, they have to be temporarily pushed to a tag that is preferably the same as the branch name of the PR, and the tag updated in pkg/version/version.go. Just ask if you need a container pushed to support a PR.
When changes are made to an image, they have to be temporarily pushed to a tag that is preferably the same as the branch name of the PR, and the tag updated in pkg/version/version.go. Just ask if you need a container pushed to support a PR.

## Contributing

Expand Down
11 changes: 11 additions & 0 deletions pkg/ddevapp/ddevapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1973,6 +1973,10 @@ func TestDdevPause(t *testing.T) {

// TestDdevStopMissingDirectory tests that the 'ddev stop' command works properly on sites with missing directories or ddev configs.
func TestDdevStopMissingDirectory(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("Skipping because unreliable on Windows")
}

assert := asrt.New(t)

site := TestSites[0]
Expand Down Expand Up @@ -2075,6 +2079,10 @@ func TestDdevDescribe(t *testing.T) {

// TestDdevDescribeMissingDirectory tests that the describe command works properly on sites with missing directories or ddev configs.
func TestDdevDescribeMissingDirectory(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("Skipping because unreliable on Windows")
}

assert := asrt.New(t)
site := TestSites[0]
tempPath := testcommon.CreateTmpDir("site-copy")
Expand Down Expand Up @@ -2291,6 +2299,9 @@ func TestRouterNotRunning(t *testing.T) {
// TestListWithoutDir prevents regression where ddev list panics if one of the
// sites found is missing a directory
func TestListWithoutDir(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("Skipping because unreliable on Windows")
}
// Set up tests and give ourselves a working directory.
assert := asrt.New(t)
testcommon.ClearDockerEnv()
Expand Down

0 comments on commit 968215e

Please sign in to comment.