WIP: automated integration tests #338
129
.drone.yml
129
.drone.yml
@ -2,68 +2,77 @@
|
|||||||
kind: pipeline
|
kind: pipeline
|
||||||
name: coopcloud.tech/abra
|
name: coopcloud.tech/abra
|
||||||
steps:
|
steps:
|
||||||
- name: make check
|
# - name: run gofmt
|
||||||
image: golang:1.20
|
# image: golang:1.20
|
||||||
|
# commands:
|
||||||
|
# - make check
|
||||||
|
|
||||||
|
# - name: build binaries
|
||||||
|
# image: golang:1.20
|
||||||
|
# commands:
|
||||||
|
# - make check
|
||||||
|
# depends_on:
|
||||||
|
# - run gofmt
|
||||||
|
|
||||||
|
# - name: run unit tests
|
||||||
|
# image: golang:1.20
|
||||||
|
# commands:
|
||||||
|
# - make test
|
||||||
|
# depends_on:
|
||||||
|
# - run gofmt
|
||||||
|
|
||||||
|
- name: run integration tests
|
||||||
|
image: decentral1se/abra-int-test:latest
|
||||||
commands:
|
commands:
|
||||||
- make check
|
- bats tests/integration/integration.bats
|
||||||
|
# depends_on:
|
||||||
|
# - run gofmt
|
||||||
|
|
||||||
- name: make build
|
# - name: fetch all tags
|
||||||
image: golang:1.20
|
# image: docker:git
|
||||||
commands:
|
# commands:
|
||||||
- make build
|
# - git fetch --tags
|
||||||
depends_on:
|
# depends_on:
|
||||||
- make check
|
# - run gofmt
|
||||||
|
# - build binaries
|
||||||
|
# - run unit tests
|
||||||
|
# - run integration tests
|
||||||
|
# when:
|
||||||
|
# event: tag
|
||||||
|
|
||||||
- name: make test
|
# - name: publish release
|
||||||
image: golang:1.20
|
# image: goreleaser/goreleaser:v1.18.2
|
||||||
commands:
|
# environment:
|
||||||
- make test
|
# GITEA_TOKEN:
|
||||||
depends_on:
|
# from_secret: goreleaser_gitea_token
|
||||||
- make check
|
# volumes:
|
||||||
|
# - name: deps
|
||||||
|
# path: /go
|
||||||
|
# commands:
|
||||||
|
# - goreleaser release
|
||||||
|
# depends_on:
|
||||||
|
# - fetch all tags
|
||||||
|
# when:
|
||||||
|
# event: tag
|
||||||
|
|
||||||
- name: fetch
|
# - name: publish image
|
||||||
image: docker:git
|
# image: plugins/docker
|
||||||
commands:
|
# settings:
|
||||||
- git fetch --tags
|
# auto_tag: true
|
||||||
depends_on:
|
# username: 3wordchant
|
||||||
- make check
|
# password:
|
||||||
- make build
|
# from_secret: git_coopcloud_tech_token_3wc
|
||||||
- make test
|
# repo: git.coopcloud.tech/coop-cloud/abra
|
||||||
when:
|
# tags: dev
|
||||||
event: tag
|
# registry: git.coopcloud.tech
|
||||||
|
# when:
|
||||||
|
# event:
|
||||||
|
# exclude:
|
||||||
|
# - pull_request
|
||||||
|
# depends_on:
|
||||||
|
# - run gofmt
|
||||||
|
# - build binaries
|
||||||
|
|
||||||
- name: release
|
# volumes:
|
||||||
image: goreleaser/goreleaser:v1.18.2
|
# - name: deps
|
||||||
environment:
|
# temp: {}
|
||||||
GITEA_TOKEN:
|
|
||||||
from_secret: goreleaser_gitea_token
|
|
||||||
volumes:
|
|
||||||
- name: deps
|
|
||||||
path: /go
|
|
||||||
commands:
|
|
||||||
- goreleaser release
|
|
||||||
depends_on:
|
|
||||||
- fetch
|
|
||||||
when:
|
|
||||||
event: tag
|
|
||||||
|
|
||||||
- name: publish image
|
|
||||||
image: plugins/docker
|
|
||||||
settings:
|
|
||||||
auto_tag: true
|
|
||||||
username: 3wordchant
|
|
||||||
password:
|
|
||||||
from_secret: git_coopcloud_tech_token_3wc
|
|
||||||
repo: git.coopcloud.tech/coop-cloud/abra
|
|
||||||
tags: dev
|
|
||||||
registry: git.coopcloud.tech
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
exclude:
|
|
||||||
- pull_request
|
|
||||||
depends_on:
|
|
||||||
- make check
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
- name: deps
|
|
||||||
temp: {}
|
|
||||||
|
@ -93,14 +93,14 @@ var appNewCommand = cli.Command{
|
|||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var secrets AppSecrets
|
||||||
|
var secretTable *jsontable.JSONTable
|
||||||
|
if internal.Secrets {
|
||||||
cl, err := client.New(internal.NewAppServer)
|
cl, err := client.New(internal.NewAppServer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var secrets AppSecrets
|
|
||||||
var secretTable *jsontable.JSONTable
|
|
||||||
if internal.Secrets {
|
|
||||||
secrets, err := createSecrets(cl, sanitisedAppName)
|
secrets, err := createSecrets(cl, sanitisedAppName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
|
16
tests/integration/Dockerfile
Normal file
16
tests/integration/Dockerfile
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
FROM debian:12-slim
|
||||||
|
|
||||||
|
RUN apt update && \
|
||||||
|
apt install -y --no-install-recommends \
|
||||||
|
bats \
|
||||||
|
bats-assert \
|
||||||
|
bats-support \
|
||||||
|
ca-certificates \
|
||||||
|
curl \
|
||||||
|
expect \
|
||||||
|
git \
|
||||||
|
golang \
|
||||||
|
make \
|
||||||
|
openssl
|
||||||
|
|
||||||
|
RUN curl -fsSL https://get.docker.com | sh
|
9
tests/integration/helpers.sh
Normal file
9
tests/integration/helpers.sh
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
_build_abra() {
|
||||||
|
if [[ ! -e "$ROOT/abra" ]]; then
|
||||||
|
cd "$ROOT" && make build-dev
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
}
|
61
tests/integration/integration.bats
Normal file
61
tests/integration/integration.bats
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
setup() {
|
||||||
|
load '/usr/lib/bats/bats-support/load'
|
||||||
|
load '/usr/lib/bats/bats-assert/load'
|
||||||
|
|
||||||
|
# get test binaries on $PATH for testing
|
||||||
|
DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )"
|
||||||
|
ROOT="$DIR/../.."
|
||||||
|
|
||||||
|
source "$DIR/helpers.sh"
|
||||||
|
_build_abra
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "build test abra" {
|
||||||
|
run $ROOT/abra -h
|
||||||
|
assert_output --partial 'The Co-op Cloud command-line utility belt'
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "create new recipe" {
|
||||||
|
run $ROOT/abra recipe new foobar
|
||||||
|
assert_output --partial 'Your new foobar recipe has been created'
|
||||||
|
|
||||||
|
mkdir -p "$HOME/.abra/servers/example.com"
|
||||||
|
if ! grep -R -q "example.com" "$HOME/.docker"; then
|
||||||
|
docker context create --docker host=ssh://foo@example.com:222 example.com
|
||||||
|
fi
|
||||||
|
|
||||||
|
run $ROOT/abra app new foobar \
|
||||||
|
--no-input \
|
||||||
|
--server example.com \
|
||||||
|
--domain foobar.example.com
|
||||||
|
|
||||||
|
assert_output --partial 'A new foobar app has been created!'
|
||||||
|
|
||||||
|
# TODO: abra app deploy foobar.example.com
|
||||||
|
# we need an actual server for this to ensure things work maybe we can get
|
||||||
|
# a donated server from the comrades for this?
|
||||||
|
|
||||||
|
rm -r "$HOME/.abra/recipes/foobar"
|
||||||
|
rm -r "$HOME/.abra/servers/example.com"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "upgrade and sync a recipe" {
|
||||||
|
run $ROOT/abra recipe fetch gitea
|
||||||
|
cd "$HOME/.abra/recipes/gitea" && git checkout "2.3.1+1.20.1-rootless"
|
||||||
|
|
||||||
|
run $ROOT/abra recipe upgrade gitea --offline --machine
|
||||||
|
assert_output --partial '1.20.2-rootless'
|
||||||
|
|
||||||
|
# TODO: when passing --patch, there is no output so we can't test against
|
||||||
|
# anything... we should add info logging when automation flags are passed
|
||||||
|
# so we can assert
|
||||||
|
run $ROOT/abra recipe upgrade gitea --offline --patch
|
||||||
|
|
||||||
|
run $ROOT/abra recipe sync gitea --offline --patch
|
||||||
|
assert_output --partial \
|
||||||
|
'synced label coop-cloud.${STACK_NAME}.version=2.3.2+1.20.2-rootless to service app'
|
||||||
|
|
||||||
|
# TODO: assert git output
|
||||||
|
|
||||||
|
cd "$HOME/.abra/recipes/gitea" && git checkout . && git checkout master
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user