chore: unify with other plugins
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,2 @@
|
||||
/tmp
|
||||
/test-results
|
||||
.vagrant
|
||||
|
||||
@@ -6,3 +6,4 @@ env:
|
||||
- DOKKU_VERSION=v0.12.0
|
||||
install: make setup
|
||||
script: make test
|
||||
after_failure: make report
|
||||
|
||||
30
Makefile
30
Makefile
@@ -1,7 +1,8 @@
|
||||
SYSTEM := $(shell sh -c 'uname -s 2>/dev/null')
|
||||
HARDWARE = $(shell uname -m)
|
||||
SYSTEM_NAME = $(shell uname -s | tr '[:upper:]' '[:lower:]')
|
||||
|
||||
bats:
|
||||
ifeq ($(SYSTEM),Darwin)
|
||||
ifeq ($(SYSTEM_NAME),darwin)
|
||||
ifneq ($(shell bats --version >/dev/null 2>&1 ; echo $$?),0)
|
||||
brew install bats-core
|
||||
endif
|
||||
@@ -13,7 +14,7 @@ endif
|
||||
|
||||
shellcheck:
|
||||
ifneq ($(shell shellcheck --version >/dev/null 2>&1 ; echo $$?),0)
|
||||
ifeq ($(SYSTEM),Darwin)
|
||||
ifeq ($(SYSTEM_NAME),darwin)
|
||||
brew install shellcheck
|
||||
else
|
||||
sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse'
|
||||
@@ -44,7 +45,7 @@ endif
|
||||
ci-dependencies: shellcheck bats readlink
|
||||
|
||||
lint-setup:
|
||||
@mkdir -p test-results/shellcheck tmp/shellcheck
|
||||
@mkdir -p tmp/test-results/shellcheck tmp/shellcheck
|
||||
@find . -not -path '*/\.*' -type f | xargs file | grep text | awk -F ':' '{ print $$1 }' | xargs head -n1 | egrep -B1 "bash" | grep "==>" | awk '{ print $$2 }' > tmp/shellcheck/test-files
|
||||
@cat tests/shellcheck-exclude | sed -n -e '/^# SC/p' | cut -d' ' -f2 | paste -d, -s - > tmp/shellcheck/exclude
|
||||
|
||||
@@ -52,16 +53,31 @@ lint: lint-setup
|
||||
# these are disabled due to their expansive existence in the codebase. we should clean it up though
|
||||
@cat tests/shellcheck-exclude | sed -n -e '/^# SC/p'
|
||||
@echo linting...
|
||||
@cat tmp/shellcheck/test-files | xargs shellcheck -e $(shell cat tmp/shellcheck/exclude) | tests/shellcheck-to-junit --output test-results/shellcheck/results.xml --files tmp/shellcheck/test-files --exclude $(shell cat tmp/shellcheck/exclude)
|
||||
@cat tmp/shellcheck/test-files | xargs shellcheck -e $(shell cat tmp/shellcheck/exclude) | tests/shellcheck-to-junit --output tmp/test-results/shellcheck/results.xml --files tmp/shellcheck/test-files --exclude $(shell cat tmp/shellcheck/exclude)
|
||||
|
||||
unit-tests:
|
||||
@echo running unit tests...
|
||||
@mkdir -p test-results/bats
|
||||
@mkdir -p tmp/test-results/bats
|
||||
@cd tests && echo "executing tests: $(shell cd tests ; ls *.bats | xargs)"
|
||||
cd tests && bats --formatter bats-format-junit -e -T -o ../test-results/bats *.bats
|
||||
cd tests && bats --formatter bats-format-junit -e -T -o ../tmp/test-results/bats *.bats
|
||||
|
||||
tmp/xunit-to-github:
|
||||
mkdir -p tmp
|
||||
curl -o tmp/xunit-to-github.tgz -sL https://github.com/josegonzalez/go-xunit-to-github/releases/download/v0.3.0/xunit-to-github_0.3.0_$(SYSTEM_NAME)_$(HARDWARE).tgz
|
||||
tar xf tmp/xunit-to-github.tgz -C tmp
|
||||
chmod +x tmp/xunit-to-github
|
||||
|
||||
setup:
|
||||
bash tests/setup.sh
|
||||
$(MAKE) ci-dependencies
|
||||
|
||||
test: lint unit-tests
|
||||
|
||||
report: tmp/xunit-to-github
|
||||
ifdef TRAVIS_REPO_SLUG
|
||||
ifdef GITHUB_ACCESS_TOKEN
|
||||
ifneq ($(TRAVIS_PULL_REQUEST),false)
|
||||
tmp/xunit-to-github --skip-ok --job-url "$(TRAVIS_JOB_WEB_URL)" --pull-request-id "$(TRAVIS_PULL_REQUEST)" --repository-slug "$(TRAVIS_REPO_SLUG)" --title "DOKKU_VERSION=$(DOKKU_VERSION)" tmp/test-results/bats tmp/test-results/shellcheck
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
9
Vagrantfile
vendored
9
Vagrantfile
vendored
@@ -1,8 +1,8 @@
|
||||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
BOX_NAME = ENV["BOX_NAME"] || "bento/ubuntu-14.04"
|
||||
BOX_MEMORY = ENV["BOX_MEMORY"] || "512"
|
||||
BOX_NAME = ENV["BOX_NAME"] || "bento/ubuntu-18.04"
|
||||
BOX_MEMORY = ENV["BOX_MEMORY"] || "2048"
|
||||
DOKKU_VERSION = "master"
|
||||
|
||||
Vagrant.configure(2) do |config|
|
||||
@@ -10,9 +10,6 @@ Vagrant.configure(2) do |config|
|
||||
config.ssh.forward_agent = true
|
||||
|
||||
config.vm.provider :virtualbox do |vb|
|
||||
# Ubuntu's Raring 64-bit cloud image is set to a 32-bit Ubuntu OS type by
|
||||
# default in Virtualbox and thus will not boot. Manually override that.
|
||||
vb.customize ["modifyvm", :id, "--ostype", "Ubuntu_64"]
|
||||
vb.customize ["modifyvm", :id, "--memory", BOX_MEMORY]
|
||||
end
|
||||
|
||||
@@ -23,7 +20,7 @@ Vagrant.configure(2) do |config|
|
||||
config.vm.define "default", primary: true do |vm|
|
||||
vm.vm.synced_folder File.dirname(__FILE__), "/vagrant"
|
||||
|
||||
vm.vm.provision :shell, :inline => "apt-get update > /dev/null && apt-get install -y -qq git software-properties-common"
|
||||
vm.vm.provision :shell, :inline => "apt -q update && apt -y -qq install git software-properties-common"
|
||||
vm.vm.provision :shell, :inline => "cd /vagrant && DOKKU_VERSION=#{DOKKU_VERSION} make setup"
|
||||
vm.vm.provision :shell, :inline => "cd /vagrant && DOKKU_TRACE=1 DOKKU_VERSION=#{DOKKU_VERSION} make test"
|
||||
end
|
||||
|
||||
@@ -474,7 +474,7 @@ service_logs() {
|
||||
is_container_status "$ID" "Running" || dokku_log_warn "Service logs may not be output as service is not running"
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
docker logs $DOKKU_LOGS_ARGS "$ID" 2> /dev/null
|
||||
docker logs $DOKKU_LOGS_ARGS "$ID" 2>&1
|
||||
}
|
||||
|
||||
service_parse_args() {
|
||||
|
||||
@@ -16,7 +16,7 @@ service-clone-cmd() {
|
||||
#F -r|--root-password PASSWORD, override the root-level service password
|
||||
declare desc="create container <new-name> then copy data from <name> into <new-name>"
|
||||
local cmd="$PLUGIN_COMMAND_PREFIX:clone" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1
|
||||
declare SERVICE="$1" NEW_SERVICE="$2" CLONE_FLAGS_LIST="${@:3}"
|
||||
declare SERVICE="$1" NEW_SERVICE="$2" CLONE_FLAGS_LIST=("${@:3}")
|
||||
is_implemented_command "$cmd" || dokku_log_fail "Not yet implemented"
|
||||
|
||||
[[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service"
|
||||
|
||||
@@ -24,7 +24,7 @@ service-create-cmd() {
|
||||
#F -r|--root-password PASSWORD, override the root-level service password
|
||||
declare desc="create a $PLUGIN_SERVICE service"
|
||||
local cmd="$PLUGIN_COMMAND_PREFIX:create" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1
|
||||
declare SERVICE="$1" CREATE_FLAGS_LIST="${@:2}"
|
||||
declare SERVICE="$1" CREATE_FLAGS_LIST=("${@:2}")
|
||||
|
||||
service_create "$SERVICE" "${@:2}"
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ service-expose-cmd() {
|
||||
#A ports, a list of ports to run against
|
||||
declare desc="expose a $PLUGIN_SERVICE service on custom port if provided (random port otherwise)"
|
||||
local cmd="$PLUGIN_COMMAND_PREFIX:expose" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1
|
||||
declare SERVICE="$1" PORTS_LIST="${@:2}"
|
||||
declare SERVICE="$1" PORTS_LIST=("${@:2}")
|
||||
|
||||
[[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service"
|
||||
verify_service_name "$SERVICE"
|
||||
|
||||
@@ -43,7 +43,7 @@ service-link-cmd() {
|
||||
#F -q|--querystring "pool=5", ampersand delimited querystring arguments to append to the service link
|
||||
declare desc="link the $PLUGIN_SERVICE service to the app"
|
||||
local cmd="$PLUGIN_COMMAND_PREFIX:link" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1
|
||||
declare SERVICE="$1" APP="$2" LINK_FLAGS_LIST="${@:3}"
|
||||
declare SERVICE="$1" APP="$2" LINK_FLAGS_LIST=("${@:3}")
|
||||
APP=${APP:="$DOKKU_APP_NAME"}
|
||||
|
||||
[[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service"
|
||||
|
||||
@@ -15,7 +15,7 @@ service-upgrade-cmd() {
|
||||
#F -R|--restart-apps "true", whether to force an app restart
|
||||
declare desc="upgrade service <service> to the specified versions"
|
||||
local cmd="$PLUGIN_COMMAND_PREFIX:upgrade" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1
|
||||
declare SERVICE="$1" UPGRADE_FLAGS_LIST="${@:2}"
|
||||
declare SERVICE="$1" UPGRADE_FLAGS_LIST=("${@:2}")
|
||||
|
||||
[[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a valid name for the service"
|
||||
verify_service_name "$SERVICE"
|
||||
|
||||
@@ -11,20 +11,32 @@ teardown() {
|
||||
|
||||
@test "($PLUGIN_COMMAND_PREFIX:logs) error when there are no arguments" {
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:logs"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_contains "${lines[*]}" "Please specify a valid name for the service"
|
||||
assert_failure
|
||||
}
|
||||
|
||||
@test "($PLUGIN_COMMAND_PREFIX:logs) error when service does not exist" {
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:logs" not_existing_service
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_contains "${lines[*]}" "service not_existing_service does not exist"
|
||||
assert_failure
|
||||
}
|
||||
|
||||
@test "($PLUGIN_COMMAND_PREFIX:logs) success when not tailing" {
|
||||
skip "This may fail if there is no log output"
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:logs" l
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
}
|
||||
|
||||
# @test "($PLUGIN_COMMAND_PREFIX:logs) success when tailing" {
|
||||
# run dokku "$PLUGIN_COMMAND_PREFIX:logs" l -t
|
||||
# assert_contains "docker logs --follow testid"
|
||||
# }
|
||||
@test "($PLUGIN_COMMAND_PREFIX:logs) success when tailing" {
|
||||
skip "This will hang as it waits for log output"
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:logs" l -t
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user