diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..db4fcfa --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,44 @@ +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: "Check out code" + uses: actions/checkout@v3 + - name: "ShellChecker" + uses: a5k-actions/shellchecker@v0 + severity: error + + - 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 }} diff --git a/commands/host/aljibe-assistant b/commands/host/aljibe-assistant index 2226cf3..ad97c68 100755 --- a/commands/host/aljibe-assistant +++ b/commands/host/aljibe-assistant @@ -1,10 +1,16 @@ #!/bin/bash - #ddev-generated ## Description: Launch project creation assistant. ## Usage: aljibe-assistant ## Example: "ddev aljibe-assistant" + +if [ "$1" == "--auto" ]; then + AUTO=1 +else + AUTO=0 +fi + ddev aljibe-logo ddev aljibe-create-project ddev aljibe-create-symlinks diff --git a/commands/host/aljibe-create-project b/commands/host/aljibe-create-project index 541da8b..f5278c5 100755 --- a/commands/host/aljibe-create-project +++ b/commands/host/aljibe-create-project @@ -1,5 +1,4 @@ #!/bin/bash - #ddev-generated ## Description: Create and configure a project. @@ -32,8 +31,10 @@ processExampleFile() { setConfFiles() { cd ${DDEV_APPROOT} || exit - echo -e "${CYAN}Please enter the project name (default to ${DDEV_PROJECT}):${NC}" - read PROJECT_NAME_INPUT + if [ "$AUTO" == "0" ]; then + echo -e "${CYAN}Please enter the project name (default to ${DDEV_PROJECT}):${NC}" + read PROJECT_NAME_INPUT + fi echo "Configuring ddev environment" if [ -z "$PROJECT_NAME_INPUT" ]; then @@ -74,8 +75,13 @@ setConfFiles() { # Setup git repo setUpGit() { - echo -e "${CYAN}Do you want to initialize a git repository for your new project?${NC} [Y/n]" - read INITIALIZE_GIT + if [ "$AUTO" == "0" ]; then + echo -e "${CYAN}Do you want to initialize a git repository for your new project?${NC} [Y/n]" + read INITIALIZE_GIT + else + INITIALIZE_GIT="n" + fi + if [ "$INITIALIZE_GIT" != "n" ]; then ## Init with main branch git init -b main @@ -94,18 +100,25 @@ initGrumpPhp() { } installDrupal() { - echo -e "${CYAN}Do you want to install Drupal?${NC} [Y/n]" - read INSTALL_DRUPAL - - if [ "$INSTALL_DRUPAL" != "n" ]; then - AVAILABLE_PROFILES=("minimal" "standard" "demo_umami") - echo -e "${CYAN}What install profile you want to install?${NC}" - select PROFILE in "${AVAILABLE_PROFILES[@]}"; do - echo "Installing profile $PROFILE" - ddev drush -y si $PROFILE - ddev drush cr - break - done + if [ "$AUTO" == "0" ]; then + echo -e "${CYAN}Do you want to install Drupal?${NC} [Y/n]" + read INSTALL_DRUPAL + if [ "$INSTALL_DRUPAL" != "n" ]; then + AVAILABLE_PROFILES=("minimal" "standard" "demo_umami") + echo -e "${CYAN}What install profile you want to install?${NC}" + select PROFILE in "${AVAILABLE_PROFILES[@]}"; do + echo "Installing profile $PROFILE" + ddev drush -y si $PROFILE + ddev drush cr + break + done + fi + else + PROFILE="standard" + echo "Installing profile $PROFILE" + ddev drush -y si $PROFILE + ddev drush cr + break fi } @@ -125,8 +138,12 @@ createDirectories() { } createSubTheme() { - echo -e "${CYAN}Do you want to create a Radix sub-theme?${NC} [Y/n] " - read CREATE_SUB_THEME + if [ "$AUTO" == "0" ]; then + echo -e "${CYAN}Do you want to create a Radix sub-theme?${NC} [Y/n] " + read CREATE_SUB_THEME + else + CREATE_SUB_THEME="n" + fi if [ "$CREATE_SUB_THEME" != "n" ]; then DEFAULT_THEME_NAME=$(echo "${PROJECT_NAME}_radix" | tr '-' '_') diff --git a/commands/host/aljibe-create-symlinks b/commands/host/aljibe-create-symlinks index 0a75e8e..7024027 100755 --- a/commands/host/aljibe-create-symlinks +++ b/commands/host/aljibe-create-symlinks @@ -1,5 +1,4 @@ #!/bin/bash - #ddev-generated ## Description: Create symlinks to the scripts provided by Scripthor. diff --git a/commands/host/aljibe-logo b/commands/host/aljibe-logo index 76fd950..22ffa5f 100644 --- a/commands/host/aljibe-logo +++ b/commands/host/aljibe-logo @@ -1,14 +1,10 @@ #!/bin/bash - #ddev-generated ## Description: Show Aljibe logo. ## Usage: aljibe-logo ## Example: "ddev aljibe-logo" - -#!/bin/bash - # ANSI color codes brown='\033[0;33m' NC='\033[0m' # No Color diff --git a/tests/test.bats b/tests/test.bats new file mode 100644 index 0000000..08860de --- /dev/null +++ b/tests/test.bats @@ -0,0 +1,36 @@ +setup() { + set -eu -o pipefail + export DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )/.." + export TESTDIR=~/tmp/test-addon-aljibe-assistant + mkdir -p $TESTDIR + export PROJNAME=test-addon-aljibe-assistant + 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 +} + +@test "install from release" { + set -eu -o pipefail + cd ${TESTDIR} || ( printf "unable to cd to ${TESTDIR}\n" && exit 1 ) + echo "# ddev get drud/test-addon-aljibe-assistant with project ${PROJNAME} in ${TESTDIR} ($(pwd))" >&3 + ddev get drud/test-addon-aljibe-assistant + ddev restart >/dev/null + # Do something useful here that verifies the add-on +} diff --git a/tests/testdata/.gitmanaged b/tests/testdata/.gitmanaged new file mode 100644 index 0000000..e69de29