From 7c00f6dabf82bed0ce978379df955477bc960d45 Mon Sep 17 00:00:00 2001 From: Stanislav Zhuk Date: Fri, 21 Feb 2025 19:27:26 +0200 Subject: [PATCH] feat: apply changes from ddev-addon-template --- .github/ISSUE_TEMPLATE/bug_report.yml | 45 +++++++++++ .github/ISSUE_TEMPLATE/feature_request.yml | 35 +++++++++ .github/workflows/tests.yml | 24 +++--- README.md | 14 +--- commands/host/adminer | 2 +- install.yaml | 2 + tests/test.bats | 87 ++++++++++++++-------- 7 files changed, 157 insertions(+), 52 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml create mode 100644 .github/ISSUE_TEMPLATE/feature_request.yml diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..d35875f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,45 @@ +name: 🐞 Bug report or Support Request +description: Create a report to help us improve. +labels: [bug] +body: + - type: checkboxes + attributes: + label: Preliminary checklist + description: Please complete the following checks before submitting an issue. + options: + - label: I am using the latest stable version of DDEV + required: true + - label: I am using the latest stable version of this add-on + required: true + - type: textarea + attributes: + label: Expected Behavior + description: What did you expect to happen? + validations: + required: true + - type: textarea + attributes: + label: Actual Behavior + description: What actually happened instead? + validations: + required: true + - type: textarea + attributes: + label: Steps To Reproduce + description: Specific steps to reproduce the behavior. + placeholder: | + 1. In this environment... + 2. With this config... + 3. Run `...` + 4. See error... + validations: + required: false + - type: textarea + attributes: + label: Anything else? + description: | + Links? References? Screenshots? Anything that will give us more context about your issue! + + 💡 Attach images or log files by clicking this area to highlight it and dragging files in. + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..db21167 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,35 @@ +name: 🚀 Feature request +description: Suggest an idea for this project. +labels: [enhancement] +body: + - type: checkboxes + attributes: + label: Is there an existing issue for this? + description: Please search existing issues to see if one already exists for your request. + options: + - label: I have searched the existing issues + required: true + - type: textarea + attributes: + label: Is your feature request related to a problem? + description: Clearly and concisely describe the problem. (Ex. I'm always frustrated when...) + validations: + required: true + - type: textarea + attributes: + label: Describe your solution + description: Clearly and concisely describe what you want to happen. + validations: + required: true + - type: textarea + attributes: + label: Describe alternatives + description: Clearly and concisely describe any alternative solutions or features you've considered. + validations: + required: false + - type: textarea + attributes: + label: Additional context + description: Add any other context or screenshots about the feature request. + validations: + required: false diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 52b2991..bc74316 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,10 +10,16 @@ on: workflow_dispatch: inputs: debug_enabled: - description: 'Debug with tmate set "debug_enabled"' + type: boolean + description: Debug with tmate required: false - default: "false" + default: false +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +# This is required for "gautamkrishnar/keepalive-workflow", see "ddev/github-action-add-on-test" permissions: actions: write @@ -27,10 +33,10 @@ jobs: runs-on: ubuntu-latest steps: - - 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 }} + - 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/README.md b/README.md index a7cd76a..28a9201 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![tests](https://github.com/ddev/ddev-adminer/actions/workflows/tests.yml/badge.svg)](https://github.com/ddev/ddev-adminer/actions/workflows/tests.yml) ![project is maintained](https://img.shields.io/maintenance/yes/2024.svg) +[![tests](https://github.com/ddev/ddev-adminer/actions/workflows/tests.yml/badge.svg)](https://github.com/ddev/ddev-adminer/actions/workflows/tests.yml) ![project is maintained](https://img.shields.io/maintenance/yes/2025.svg) # DDEV Adminer Service @@ -16,20 +16,10 @@ AdminerEvo works with MySQL, MariaDB, PostgreSQL, SQLite, MS SQL, Oracle, Elasti ## Installation -For DDEV v1.23.5 or above run - -```sh -ddev add-on get ddev/ddev-adminer -``` - -For earlier versions of DDEV run - ```sh -ddev get ddev/ddev-adminer +ddev add-on get ddev/ddev-adminer && ddev restart ``` -Afterward run `ddev restart` - Then you can just `ddev adminer` or use `ddev describe` to get the URL (`https://.ddev.site:9101`). ## What does this add-on do? diff --git a/commands/host/adminer b/commands/host/adminer index 5c09b57..37f9de6 100755 --- a/commands/host/adminer +++ b/commands/host/adminer @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash ## #ddev-generated: If you want to edit and own this file, remove this line. ## Description: Launch a browser with Adminer diff --git a/install.yaml b/install.yaml index c71da54..2b6a1bc 100644 --- a/install.yaml +++ b/install.yaml @@ -6,6 +6,8 @@ project_files: - docker-compose.adminer_norouter.yaml - commands/host/adminer +ddev_version_constraint: '>= v1.24.2' + pre_install_actions: # Ensure we're on DDEV 1.23+. It's required for the `adminer` command (launch by port). - | diff --git a/tests/test.bats b/tests/test.bats index 21597bc..d72b550 100644 --- a/tests/test.bats +++ b/tests/test.bats @@ -1,27 +1,50 @@ +#!/usr/bin/env bats + +# Bats is a testing framework for Bash +# Documentation https://bats-core.readthedocs.io/en/stable/ +# Bats libraries documentation https://github.com/ztombol/bats-docs + +# For local tests, install bats-core, bats-assert, bats-file, bats-support +# And run this in the add-on root directory: +# bats ./tests/test.bats +# To exclude release tests: +# bats ./tests/test.bats --filter-tags '!release' +# For debugging: +# bats ./tests/test.bats --show-output-of-passing-tests --verbose-run --print-output-on-failure + setup() { set -eu -o pipefail - brew_prefix=$(brew --prefix) - load "${brew_prefix}/lib/bats-support/load.bash" - load "${brew_prefix}/lib/bats-assert/load.bash" - export DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )/.." - export TESTDIR=~/tmp/test-adminer - mkdir -p $TESTDIR - export PROJNAME=test-adminer - export DDEV_NON_INTERACTIVE=true - ddev delete -Oy ${PROJNAME} >/dev/null 2>&1 || true + # Override this variable for your add-on: + export GITHUB_REPO=ddev/ddev-adminer + + TEST_BREW_PREFIX="$(brew --prefix 2>/dev/null || true)" + export BATS_LIB_PATH="${BATS_LIB_PATH}:${TEST_BREW_PREFIX}/lib:/usr/lib/bats" + bats_load_library bats-assert + bats_load_library bats-file + bats_load_library bats-support + + export DIR="$(cd "$(dirname "${BATS_TEST_FILENAME}")/.." >/dev/null 2>&1 && pwd)" + export PROJNAME="test-$(basename "${GITHUB_REPO}")" + mkdir -p ~/tmp + export TESTDIR=$(mktemp -d ~/tmp/${PROJNAME}.XXXXXX) + export DDEV_NONINTERACTIVE=true + export DDEV_NO_INSTRUMENTATION=true + ddev delete -Oy "${PROJNAME}" >/dev/null 2>&1 || true cd "${TESTDIR}" - ddev config --project-name=${PROJNAME} - ddev start -y >/dev/null 2>&1 + run ddev config --project-name="${PROJNAME}" --project-tld=ddev.site + assert_success + run ddev start -y + assert_success } health_checks() { - set +u # bats-assert has unset variables so turn off unset check - # ddev restart is required because we have done `ddev add-on get` on a new service - run ddev restart - assert_success # Make sure we can hit the 9101 port successfully - curl -s -I -f https://${PROJNAME}.ddev.site:9101 >/tmp/curlout.txt + run curl -sfI https://${PROJNAME}.ddev.site:9101 + assert_success + assert_output --partial "HTTP/2 200" + assert_output --partial "adminer" + # Make sure `ddev adminer` works DDEV_DEBUG=true run ddev adminer assert_success @@ -30,35 +53,39 @@ health_checks() { 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 add-on get ${DIR} with project ${PROJNAME} in ${TESTDIR} ($(pwd))" >&3 - ddev add-on get ${DIR} >/dev/null 2>&1 - ddev mutagen sync >/dev/null 2>&1 + echo "# ddev add-on get ${DIR} with project ${PROJNAME} in $(pwd)" >&3 + run ddev add-on get "${DIR}" + assert_success + run ddev restart -y + assert_success health_checks } +# bats test_tags=release @test "install from release" { set -eu -o pipefail - cd ${TESTDIR} || ( printf "unable to cd to ${TESTDIR}\n" && exit 1 ) - echo "# ddev add-on get ddev/ddev-adminer with project ${PROJNAME} in ${TESTDIR} ($(pwd))" >&3 - ddev add-on get ddev/ddev-adminer >/dev/null 2>&1 - ddev restart >/dev/null 2>&1 + echo "# ddev add-on get ${GITHUB_REPO} with project ${PROJNAME} in $(pwd)" >&3 + run ddev add-on get "${GITHUB_REPO}" + assert_success + run ddev restart -y + assert_success health_checks } @test "install from directory with nonstandard port" { set -eu -o pipefail - cd ${TESTDIR} - ddev config --router-http-port=8080 --router-https-port=8443 - echo "# ddev add-on get ${DIR} with project ${PROJNAME} in ${TESTDIR} ($(pwd))" >&3 - ddev add-on get ${DIR} >/dev/null 2>&1 - ddev mutagen sync >/dev/null 2>&1 + run ddev config --router-http-port=8080 --router-https-port=8443 + assert_success + echo "# ddev add-on get ${DIR} with project ${PROJNAME} in $(pwd)" >&3 + run ddev add-on get "${DIR}" + assert_success + run ddev restart -y + assert_success health_checks }