diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 88fecea..4b6a53e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -2,7 +2,7 @@ name: tests on: pull_request: push: - branches: [ master, main ] + branches: [ main ] schedule: - cron: '01 07 * * *' @@ -29,12 +29,11 @@ jobs: strategy: matrix: -# ddev_version: [latest, edge, HEAD] - ddev_version: [edge, HEAD] + ddev_version: [latest, HEAD] # ddev_version: [PR] fail-fast: false - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v2 @@ -76,3 +75,6 @@ jobs: - name: tests run: bats tests + # keepalive-workflow adds a dummy commit if there's no other action here, keeps + # GitHub from turning off tests after 60 days + - uses: gautamkrishnar/keepalive-workflow@v1 diff --git a/README.md b/README.md index 2051ea8..0eeb115 100644 --- a/README.md +++ b/README.md @@ -12,32 +12,20 @@ with no _external_ plugins. It contains all official plugins and themes and allo to easily chose one by editing the `docker-compose.adminer.yaml` file after installation. -The official container supports: +This currently supports: * MySQL / MariaDB * PostgreSQL -* SQLite -* SimpleDB -* Elasticsearch - -## Why? - -Because you might need something other than MySQL / MariaDB in your DDEV project. We got you covered. ## Installation * `ddev get bserem/ddev-adminer && ddev restart` -## Caveats - -You need to pass database credentials manually for the time being. If you have -any ideas on how to overcome this issue please let me know. +Then you can just `ddev launch -a` or use `ddev describe` to get the URL (`https://.ddev.site:9101`). -Default ddev database credentials are: +## What does this add-on do? -* user `db` -* password `db` -* database `db` +* Adds the adminer container as a service +* Overrides the `ddev launch` command at the project level with a `ddev launch -a` (or `ddev launch --adminer`) option. ---- **Contributed and maintained by [@bserem](https://github.com/bserem).** diff --git a/adminer/Dockerfile b/adminer/Dockerfile new file mode 100644 index 0000000..8a21407 --- /dev/null +++ b/adminer/Dockerfile @@ -0,0 +1,3 @@ +#ddev-generated +FROM adminer:standalone +ADD ddev-login.php /var/www/html/plugins-enabled/ diff --git a/adminer/ddev-login.php b/adminer/ddev-login.php new file mode 100644 index 0000000..ab526d3 --- /dev/null +++ b/adminer/ddev-login.php @@ -0,0 +1,28 @@ + + + &2 + ;; + *) # Default case: No more options, so break out of the loop. + break + esac + + shift + done + +if [ -n "${1:-}" ] ; then + if [[ ${1::1} != "/" ]] ; then + FULLURL="${FULLURL}/"; + fi + + FULLURL="${FULLURL}${1}"; +fi + +if [ ! -z ${DDEV_DEBUG:-} ]; then + printf "FULLURL $FULLURL\n" && exit 0 +fi + +case $OSTYPE in + linux-gnu) + xdg-open ${FULLURL} + ;; + "darwin"*) + open ${FULLURL} + ;; + "win*"* | "msys"*) + start ${FULLURL} + ;; +esac diff --git a/docker-compose.adminer.yaml b/docker-compose.adminer.yaml index 6cbe3ab..8b53931 100644 --- a/docker-compose.adminer.yaml +++ b/docker-compose.adminer.yaml @@ -1,23 +1,28 @@ +#ddev-generated version: '3.6' services: adminer: container_name: ddev-${DDEV_SITENAME}-adminer - image: adminer:standalone + build: + context: './adminer' environment: # Use the line below to change the adminer theme. # - ADMINER_DESIGN=nette - - ADMINER_DEFAULT_SERVER=ddev-${DDEV_SITENAME}-db + - ADMINER_DEFAULT_SERVER=db - ADMINER_PLUGINS=tables-filter - VIRTUAL_HOST=$DDEV_HOSTNAME - - HTTP_EXPOSE=8080:8080 + - HTTP_EXPOSE=9100:8080 + - HTTPS_EXPOSE=9101:8080 + - DDEV_DBIMAGE + - DDEV_DB_NAME=db + - DDEV_DB_USER=db + - DDEV_DB_PASS=db labels: com.ddev.site-name: ${DDEV_SITENAME} com.ddev.approot: $DDEV_APPROOT + depends_on: + - db - # We do not ship any plugin configuration at the moment, - # but keep this here for future reference. - #volumes: - # - "./adminer:/var/www/html/plugins-enabled" web: links: - adminer:adminer diff --git a/install.yaml b/install.yaml index e8a6dd0..841b235 100644 --- a/install.yaml +++ b/install.yaml @@ -2,4 +2,8 @@ name: adminer # list of files and directories listed that are copied into project .ddev directory project_files: -- docker-compose.adminer.yaml \ No newline at end of file +- docker-compose.adminer.yaml +- adminer + +global_files: +- commands/host/launcha diff --git a/tests/test.bats b/tests/test.bats index f76b160..4077209 100644 --- a/tests/test.bats +++ b/tests/test.bats @@ -1,13 +1,14 @@ setup() { + mkcert -install >/dev/null export DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )/.." export TESTDIR=$(mktemp -d -t testadminer-XXXXXXXXXX) export PROJNAME=testadminer export DDEV_NON_INTERACTIVE=true - ddev delete -Oy ${PROJNAME} || true + ddev delete -Oy ${PROJNAME} >/dev/null || true cd "${TESTDIR}" ddev config --project-name=${PROJNAME} echo ${PROJNAME} - ddev start + ddev start -y >/dev/null } teardown() { @@ -17,12 +18,12 @@ teardown() { } @test "basic installation" { - cd ${TESTDIR} || ( printf "unable to cd to ${TESTDIR}\n" && exit 1 ) + set -o pipefail + cd ${TESTDIR} || ( printf "# unable to cd to ${TESTDIR}\n" >&3 && false ) echo "# ddev get ${DIR} with project ${PROJNAME} in ${TESTDIR} ($(pwd))" >&3 ddev get ${DIR} - ddev restart - # This would be a clearer test, but doesn't work - # status=$(ddev describe | grep adminer | head -1 | awk '{print $4}') - # [[ "${status}" = "OK" ]] - ddev describe | grep adminer | head -1 | awk '{print $4}' + (ddev restart >/dev/null || (echo "# ddev restart returned exit code=%?" >&3 && false)) + ddev help launcha | grep adminer >/dev/null +# echo "# Trying curl -s -L -k https://${PROJNAME}.ddev.site:9101/" >&3 + curl --fail -s -L -k https://${PROJNAME}.ddev.site:9101/ | grep 'document.querySelector.*auth.*db' >/dev/null }