Skip to content

Commit

Permalink
Added basic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
juanjol committed Aug 30, 2024
1 parent a32f25a commit a1f66b3
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 1 deletion.
43 changes: 43 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: tests
on:
pull_request:
push:
branches: [ main ]

schedule:
- cron: '00 07 * * *'

workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: Debug with tmate
required: false
default: false

# This is required for "gautamkrishnar/keepalive-workflow", see "ddev/github-action-add-on-test"
permissions:
actions: write

jobs:
tests:
strategy:
matrix:
ddev_version: [stable, HEAD]
fail-fast: false

runs-on: ubuntu-latest

steps:
- name: Run ShellCheck
uses: azohra/shell-linter@latest
with:
path: "scripts,commands"

- uses: ddev/github-action-add-on-test@v2
with:
ddev_version: ${{ matrix.ddev_version }}
token: ${{ secrets.GITHUB_TOKEN }}
debug_enabled: ${{ github.event.inputs.debug_enabled }}
addon_repository: ${{ env.GITHUB_REPOSITORY }}
addon_ref: ${{ env.GITHUB_REF }}
1 change: 0 additions & 1 deletion commands/host/includes/aljibe_includes
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ extract_argument() {
run_commands() {
local CMDS=("$@")
if [ ${#CMDS[@]} -gt 0 ]; then
echo
echo -e "\033[32mRunning commands: \033[0m\n"
for cmd in "${CMDS[@]}"; do
echo "- running $cmd ... "
Expand Down
40 changes: 40 additions & 0 deletions tests/test.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
setup() {
set -eu -o pipefail
export DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )/.."
export TESTDIR=~/tmp/test-addon-backstopjs
mkdir -p $TESTDIR
export PROJNAME=test-addon-backstopjs
export DDEV_NON_INTERACTIVE=true
ddev delete -Oy ${PROJNAME} >/dev/null 2>&1 || true
cd "${TESTDIR}"
ddev config --project-name=${PROJNAME}
ddev start -y >/dev/null
}

teardown() {
set -eu -o pipefail
cd ${TESTDIR} || ( printf "unable to cd to ${TESTDIR}\n" && exit 1 )
ddev delete -Oy ${PROJNAME} >/dev/null 2>&1
[ "${TESTDIR}" != "" ] && rm -rf ${TESTDIR}
}

@test "install from directory" {
set -eu -o pipefail
cd ${TESTDIR}
echo "# ddev get ${DIR} with project ${PROJNAME} in ${TESTDIR} ($(pwd))" >&3
ddev get ${DIR}
ddev restart

ddev aljibe-assistant --auto

}

@test "install from release" {
set -eu -o pipefail
cd ${TESTDIR} || ( printf "unable to cd to ${TESTDIR}\n" && exit 1 )
echo "# ddev get drud/ddev-addon-template with project ${PROJNAME} in ${TESTDIR} ($(pwd))" >&3
ddev get drud/ddev-addon-template
ddev restart >/dev/null
# Do something useful here that verifies the add-on
# ddev exec "curl -s elasticsearch:9200" | grep "${PROJNAME}-elasticsearch"
}
Empty file added tests/testdata/.gitmanaged
Empty file.

0 comments on commit a1f66b3

Please sign in to comment.