Skip to content

Commit 8fed301

Browse files
committed
fix: use any_changed output for reliable changed files detection
When using workflow_dispatch with no actual changes between commits, all_changed_files is empty but the -n check may not work correctly. Using any_changed boolean output provides more reliable detection.
1 parent 96463d5 commit 8fed301

File tree

3 files changed

+28
-34
lines changed

3 files changed

+28
-34
lines changed

.github/workflows/maintenance-unit-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ jobs:
5454
)
5555
images=("bookworm" "trixie" "forky" "jammy" "noble" "resolute")
5656
# read tests cases
57-
if [[ -n "${{ steps.changed-files.outputs.all_changed_files }}" ]]; then
57+
if [[ "${{ steps.changed-files.outputs.any_changed }}" == "true" ]]; then
5858
mapfile -t changed_files <<< "${{ steps.changed-files.outputs.all_changed_files }}"
5959
tests=($(grep -rwl -e "ENABLED=true" -- "${changed_files[@]}" | cut -d":" -f1))
60-
else
60+
else
6161
tests=($(grep -rwl tests/*.conf -e "ENABLED=true" | cut -d":" -f1))
6262
fi
6363
# loop enabled test cases

tests/mariadb.conf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
ENABLED=false
2-
RELEASE="bookworm"
1+
ENABLED=true
2+
RELEASE="noble"
33
TESTNAME="Mariadb install"
44

55
testcase() {(
6-
set -e
6+
./bin/armbian-config --api module_mariadb purge
77
./bin/armbian-config --api module_mariadb install
88
./bin/armbian-config --api module_mariadb status
99
)}

tools/modules/software/module_mariadb.sh

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,15 @@ module_options+=(
1111
["module_mariadb,arch"]="x86-64 arm64"
1212
)
1313
#
14-
# Module mariadb-PDF
14+
# Module mariadb
1515
#
1616
function module_mariadb () {
1717
local title="mariadb"
1818
local condition=$(which "$title" 2>/dev/null)
1919

20-
if pkg_installed docker-ce; then
21-
local container=$(docker container ls -a | mawk '/mariadb?( |$)/{print $1}')
22-
local image=$(docker image ls -a | mawk '/mariadb?( |$)/{print $3}')
23-
fi
20+
pkg_installed docker.io || module_docker install
21+
local container=$(docker container ls -a --filter "name=mariadb" --format '{{.ID}}')
22+
local image=$(docker image ls -a --format '{{.Repository}} {{.ID}}' | grep 'mariadb '| awk '{print $2}')
2423

2524
local commands
2625
IFS=' ' read -r -a commands <<< "${module_options["module_mariadb,example"]}"
@@ -29,49 +28,44 @@ function module_mariadb () {
2928

3029
case "$1" in
3130
"${commands[0]}")
32-
pkg_installed docker-ce || module_docker install
3331
[[ -d "$MARIADB_BASE" ]] || mkdir -p "$MARIADB_BASE" || { echo "Couldn't create storage directory: $MARIADB_BASE"; exit 1; }
34-
35-
# get parameters
36-
MYSQL_ROOT_PASSWORD=$($DIALOG --title "Enter root password for Mariadb SQL server" --inputbox "\nHit enter for defaults" 9 50 "armbian" 3>&1 1>&2 2>&3)
37-
MYSQL_DATABASE=$($DIALOG --title "Enter database name for Mariadb SQL server" --inputbox "\nHit enter for defaults" 9 50 "armbian" 3>&1 1>&2 2>&3)
38-
MYSQL_USER=$($DIALOG --title "Enter user name for Mariadb SQL server" --inputbox "\nHit enter for defaults" 9 50 "armbian" 3>&1 1>&2 2>&3)
39-
MYSQL_PASSWORD=$($DIALOG --title "Enter new password for ${MYSQL_USER}" --inputbox "\nHit enter for defaults" 9 50 "armbian" 3>&1 1>&2 2>&3)
4032
docker run -d \
41-
--name=mariadb \
4233
--net=lsio \
34+
--name mariadb \
35+
--restart=always \
36+
-p ${module_options["module_mariadb,port"]}:3306 \
37+
-v "${MARIADB_BASE}:/config" \
4338
-e PUID=1000 \
4439
-e PGID=1000 \
4540
-e TZ="$(cat /etc/timezone)" \
46-
-e "MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}" \
47-
-e "MYSQL_DATABASE=${MYSQL_DATABASE}" \
48-
-e "MYSQL_USER=${MYSQL_USER}" \
49-
-e "MYSQL_PASSWORD=${MYSQL_PASSWORD}" \
50-
-p ${module_options["module_mariadb,port"]}:3306 \
51-
-v "${MARIADB_BASE}/config:/config" \
52-
--restart unless-stopped \
41+
-e "MYSQL_ROOT_PASSWORD=armbian" \
42+
-e "MYSQL_DATABASE=armbian" \
43+
-e "MYSQL_USER=armbian" \
44+
-e "MYSQL_PASSWORD=armbian" \
5345
lscr.io/linuxserver/mariadb:latest
5446
for i in $(seq 1 20); do
55-
if docker inspect -f '{{ index .Config.Labels "build_version" }}' mariadb >/dev/null 2>&1 ; then
47+
state="$(docker inspect -f '{{.State.Status}}' mariadb 2>/dev/null || true)"
48+
if [[ "$state" == "running" ]]; then
5649
break
57-
else
58-
sleep 3
5950
fi
60-
if [ $i -eq 20 ] ; then
61-
echo -e "\nTimed out waiting for ${title} to start, consult your container logs for more info (\`docker logs mariadb\`)"
51+
sleep 3
52+
if [[ $i -eq 20 ]]; then
53+
echo -e "\nTimed out waiting for ${title} to start, consult logs (\`docker logs mariadb\`)"
6254
exit 1
6355
fi
6456
done
6557
;;
6658
"${commands[1]}")
6759
if [[ "${container}" ]]; then
68-
docker container rm -f "$container" >/dev/null
69-
fi
70-
if [[ "${image}" ]]; then
71-
docker image rm "$image" >/dev/null
60+
echo "Removing container: $container"
61+
docker container rm -f "$container"
7262
fi
7363
;;
7464
"${commands[2]}")
65+
${module_options["module_mariadb,feature"]} ${commands[1]}
66+
if [[ "${image}" ]]; then
67+
docker image rm "$image"
68+
fi
7569
${module_options["module_mariadb,feature"]} ${commands[1]}
7670
if [[ -n "${MARIADB_BASE}" && "${MARIADB_BASE}" != "/" ]]; then
7771
rm -rf "${MARIADB_BASE}"

0 commit comments

Comments
 (0)