diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 198efcd58be..7e84952eeef 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -7,8 +7,9 @@ RUN apt-get install --no-install-recommends -y build-essential file nano && \ apt-get autoremove --yes && \ rm -rf /var/lib/apt/lists/* -RUN wget https://dl.google.com/go/go1.17.9.linux-amd64.tar.gz && \ - tar -xvf go1.17.9.linux-amd64.tar.gz && \ +ARG TARGETARCH +RUN wget https://dl.google.com/go/go1.17.9.linux-${TARGETARCH}.tar.gz && \ + tar -xvf go1.17.9.linux-${TARGETARCH}.tar.gz && \ mv go /usr/local RUN GOROOT=/usr/local/go /usr/local/go/bin/go install golang.org/x/tools/gopls@latest 2>&1 diff --git a/Makefile b/Makefile index e4da07db5b0..9090ee66807 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,7 @@ DOKKU_VERSION ?= master +TARGETARCH ?= amd64 + DOCKER_IMAGE_LABELER_VERSION ?= 0.5.0 HEROKUISH_VERSION ?= 0.5.37 LAMBDA_BUILDER_VERSION ?= 0.4.0 @@ -8,12 +10,12 @@ PLUGN_VERSION ?= 0.12.0 PROCFILE_VERSION ?= 0.15.0 SIGIL_VERSION ?= 0.9.0 SSHCOMMAND_VERSION ?= 0.16.0 -DOCKER_IMAGE_LABELER_URL ?= https://github.com/dokku/docker-image-labeler/releases/download/v${DOCKER_IMAGE_LABELER_VERSION}/docker-image-labeler_${DOCKER_IMAGE_LABELER_VERSION}_linux_amd64.tgz -LAMBDA_BUILDER_URL ?= https://github.com/dokku/lambda-builder/releases/download/v${LAMBDA_BUILDER_VERSION}/lambda-builder_${LAMBDA_BUILDER_VERSION}_linux_amd64.tgz -NETRC_URL ?= https://github.com/dokku/netrc/releases/download/v${NETRC_VERSION}/netrc_${NETRC_VERSION}_linux_amd64.tgz -PLUGN_URL ?= https://github.com/dokku/plugn/releases/download/v${PLUGN_VERSION}/plugn_${PLUGN_VERSION}_linux_amd64.tgz -PROCFILE_UTIL_URL ?= https://github.com/josegonzalez/go-procfile-util/releases/download/v${PROCFILE_VERSION}/procfile-util_${PROCFILE_VERSION}_linux_amd64.tgz -SIGIL_URL ?= https://github.com/gliderlabs/sigil/releases/download/v${SIGIL_VERSION}/gliderlabs-sigil_${SIGIL_VERSION}_linux_amd64.tgz +DOCKER_IMAGE_LABELER_URL ?= https://github.com/dokku/docker-image-labeler/releases/download/v${DOCKER_IMAGE_LABELER_VERSION}/docker-image-labeler_${DOCKER_IMAGE_LABELER_VERSION}_linux_${TARGETARCH}.tgz +LAMBDA_BUILDER_URL ?= https://github.com/dokku/lambda-builder/releases/download/v${LAMBDA_BUILDER_VERSION}/lambda-builder_${LAMBDA_BUILDER_VERSION}_linux_${TARGETARCH}.tgz +NETRC_URL ?= https://github.com/dokku/netrc/releases/download/v${NETRC_VERSION}/netrc_${NETRC_VERSION}_linux_${TARGETARCH}.tgz +PLUGN_URL ?= https://github.com/dokku/plugn/releases/download/v${PLUGN_VERSION}/plugn_${PLUGN_VERSION}_linux_${TARGETARCH}.tgz +PROCFILE_UTIL_URL ?= https://github.com/josegonzalez/go-procfile-util/releases/download/v${PROCFILE_VERSION}/procfile-util_${PROCFILE_VERSION}_linux_${TARGETARCH}.tgz +SIGIL_URL ?= https://github.com/gliderlabs/sigil/releases/download/v${SIGIL_VERSION}/gliderlabs-sigil_${SIGIL_VERSION}_linux_${TARGETARCH}.tgz SSHCOMMAND_URL ?= https://github.com/dokku/sshcommand/releases/download/v${SSHCOMMAND_VERSION}/sshcommand_${SSHCOMMAND_VERSION}_linux_x86_64.tgz STACK_URL ?= https://github.com/gliderlabs/herokuish.git PREBUILT_STACK_URL ?= gliderlabs/herokuish:latest-20 @@ -157,32 +159,32 @@ man-db: docker-image-labeler: wget -qO /tmp/docker-image-labeler_latest.tgz ${DOCKER_IMAGE_LABELER_URL} tar xzf /tmp/docker-image-labeler_latest.tgz -C /usr/local/bin - mv /usr/local/bin/docker-image-labeler-amd64 /usr/local/bin/docker-image-labeler + mv /usr/local/bin/docker-image-labeler-${TARGETARCH} /usr/local/bin/docker-image-labeler lambda-builder: wget -qO /tmp/lambda-builder_latest.tgz ${LAMBDA_BUILDER_URL} tar xzf /tmp/lambda-builder_latest.tgz -C /usr/local/bin - mv /usr/local/bin/lambda-builder-amd64 /usr/local/bin/lambda-builder + mv /usr/local/bin/lambda-builder-${TARGETARCH} /usr/local/bin/lambda-builder netrc: wget -qO /tmp/netrc_latest.tgz ${NETRC_URL} tar xzf /tmp/netrc_latest.tgz -C /usr/local/bin - mv /usr/local/bin/netrc-amd64 /usr/local/bin/netrc + mv /usr/local/bin/netrc-${TARGETARCH} /usr/local/bin/netrc procfile-util: wget -qO /tmp/procfile-util_latest.tgz ${PROCFILE_UTIL_URL} tar xzf /tmp/procfile-util_latest.tgz -C /usr/local/bin - mv /usr/local/bin/procfile-util-amd64 /usr/local/bin/procfile-util + mv /usr/local/bin/procfile-util-${TARGETARCH} /usr/local/bin/procfile-util plugn: wget -qO /tmp/plugn_latest.tgz ${PLUGN_URL} tar xzf /tmp/plugn_latest.tgz -C /usr/local/bin - mv /usr/local/bin/plugn-amd64 /usr/local/bin/plugn + mv /usr/local/bin/plugn-${TARGETARCH} /usr/local/bin/plugn sigil: wget -qO /tmp/sigil_latest.tgz ${SIGIL_URL} tar xzf /tmp/sigil_latest.tgz -C /usr/local/bin - mv /usr/local/bin/gliderlabs-sigil-amd64 /usr/local/bin/sigil + mv /usr/local/bin/gliderlabs-sigil-${TARGETARCH} /usr/local/bin/sigil sshcommand: wget -qO /tmp/sshcommand_latest.tgz ${SSHCOMMAND_URL} diff --git a/docs/development/testing.md b/docs/development/testing.md index fc32963a015..e195546767f 100644 --- a/docs/development/testing.md +++ b/docs/development/testing.md @@ -17,6 +17,8 @@ While we do provide official packages for a variety of platforms, as our test su ## Local Test Execution +### Vagrant VM + - Setup Dokku in a [Vagrant VM](/docs/getting-started/install/vagrant.md). - Run the following to setup tests and execute them: @@ -25,18 +27,25 @@ While we do provide official packages for a variety of platforms, as our test su sudo su - cd ~/dokku make ci-dependencies setup-deploy-tests + ``` + +After making changes to your local Dokku clone, don't forget to update the Vagrant Dokku install. + +```shell +# update vagrant dokku install from local git clone +make copyfiles - # execute the entire test suite (linter, bats tests, and app deployment tests) - make test +# build a specific plugin +make go-build-plugin copyplugin PLUGIN_NAME=apps +``` - # run linter - make lint +### VSCode Dev Container - # execute all bats tests - make unit-tests +- Open Dokku in a VSCode DevContainer +- Run the following in the VSCode terminal to setup tests and execute them: - # execute all app deployment tests - make deploy-tests + ```shell + make ci-dependencies setup-deploy-tests ``` After making changes to your local Dokku clone, don't forget to update the Vagrant Dokku install. @@ -49,7 +58,35 @@ make copyfiles make go-build-plugin copyplugin PLUGIN_NAME=apps ``` -Additionally you may run a specific app deployment tests with a target similar to: +### Executing tests + +Execute the entire test suite (linter, bats tests, and app deployment tests): + +```shell +make test +``` + +Run the linter + +```shell +make lint +``` + +Execute all bats tests + +```shell +make unit-tests +``` + +Execute all app deployment tests + +```shell +make deploy-tests +``` + +#### Executing App Tests + +You may run a specific app deployment tests with a target similar to: ```shell make deploy-test-nodejs-express @@ -57,32 +94,32 @@ make deploy-test-nodejs-express For a full list of test make targets check out `tests.mk` in the root of the Dokku repository. -## Executing a single test suite +#### Executing a single test suite When working on a particular plugin, it may be useful to run _only_ a particular test suite. This can be done by specifying the test suite path: ```shell -bats tests/unit/10_apps.bats +bats tests/unit/apps_1.bats ``` It is also possible to target multiple test suites at a time. ```shell -bats tests/unit/10_apps.bats tests/unit/10_certs.bats +bats tests/unit/apps_1.bats tests/unit/certs.bats ``` -## Executing a single test +#### Executing a single test In order to increase testing velocity, a wrapper script around Bats is available that can be used to run a single test case within a suite. Tests within a suite may be listed by specifying the suite as a parameter to `bats`. ```shell -bats tests/unit/10_apps.bats +bats tests/unit/apps_1.bats ``` A single test can be specified via the `--filter` argument. The tests are selected via regex match, and all matches are executed. ```shell -bats --filter clone tests/unit/10_apps.bats +bats --filter list tests/unit/apps_1.bats ``` diff --git a/tests.mk b/tests.mk index 663ae332625..67c18906852 100644 --- a/tests.mk +++ b/tests.mk @@ -26,7 +26,7 @@ ifneq ($(shell shfmt --version >/dev/null 2>&1 ; echo $$?),0) ifeq ($(shfmt),Darwin) brew install shfmt else - wget -qO /tmp/shfmt https://github.com/mvdan/sh/releases/download/v2.6.2/shfmt_v2.6.2_linux_amd64 + wget -qO /tmp/shfmt https://github.com/mvdan/sh/releases/download/v3.5.1/shfmt_v3.5.1_linux_${TARGETARCH} chmod +x /tmp/shfmt sudo mv /tmp/shfmt /usr/local/bin/shfmt endif