From f9180c44ef6e6c03f7515f1262a8f901590dbd7e Mon Sep 17 00:00:00 2001 From: Igor Pecovnik Date: Sun, 16 Feb 2025 20:26:19 +0100 Subject: [PATCH] Unit tests: change logic and fix bugs --- .github/workflows/unit-tests.yml | 42 +++++++++++------------ tests/MAN001.conf | 9 ----- tests/cockpit.conf | 11 ++++++ tests/{HAS001.conf => homeassistant.conf} | 1 + tests/{DAT001.conf => mariadb.conf} | 3 +- tests/{NAV001.conf => navidrome.conf} | 6 ++-- tests/{HAB001.conf => openhab.conf} | 2 ++ tests/{CON005.conf => portainer.conf} | 4 ++- tests/{SY206.conf => rolling.conf} | 1 + tests/{SY207.conf => stable.conf} | 1 + tests/{MON001.conf => uptimekuma.conf} | 7 ++-- 11 files changed, 48 insertions(+), 39 deletions(-) delete mode 100644 tests/MAN001.conf create mode 100644 tests/cockpit.conf rename tests/{HAS001.conf => homeassistant.conf} (81%) rename tests/{DAT001.conf => mariadb.conf} (75%) rename tests/{NAV001.conf => navidrome.conf} (54%) rename tests/{HAB001.conf => openhab.conf} (67%) rename tests/{CON005.conf => portainer.conf} (59%) rename tests/{SY206.conf => rolling.conf} (81%) rename tests/{SY207.conf => stable.conf} (81%) rename tests/{MON001.conf => uptimekuma.conf} (58%) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 527bc9f6..d1d7b653 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -15,7 +15,7 @@ env: concurrency: group: pipeline-pr-${{github.event.pull_request.number}} - cancel-in-progress: true + cancel-in-progress: false jobs: @@ -62,14 +62,14 @@ jobs: testid=($(echo $i | cut -d"/" -f2 | cut -d"." -f1)) for SELECTED_RELEASE in "${elements[@]}"; do if [[ $j == *"${SELECTED_RELEASE}"* ]]; then - echo "{\"package\":\"${i}\",\"os\":\"$j\",\"id\":\"$testid\"}" + echo "{\"package\":\"${i}\",\"name\":\"${TESTNAME}\",\"os\":\"$j\",\"id\":\"$testid\"}" fi done done else for j in ${images[@]}; do testid=($(echo $i | cut -d"/" -f2 | cut -d"." -f1)) - echo "{\"package\":\"${i}\",\"os\":\"$j\",\"id\":\"$testid\"}" + echo "{\"package\":\"${i}\",\"name\":\"${TESTNAME}\",\"os\":\"$j\",\"id\":\"$testid\"}" done fi done | jq -s >> $GITHUB_OUTPUT @@ -83,35 +83,35 @@ jobs: max-parallel: 32 matrix: server: ${{ fromJSON(needs.prepare.outputs.DEPLOYMENT_MATRIX) }} - name: "${{ matrix.server.id }} on Armbian ${{ matrix.server.os }}" + name: "${{ matrix.server.name }} (${{ matrix.server.os }})" runs-on: "${{ matrix.server.os }}" - timeout-minutes: 7 + timeout-minutes: 15 steps: - name: "Install dependencies: fastfetch" - run: sudo apt-get -y install fastfetch + run: | + if lsof /var/lib/dpkg/lock >/dev/null 2>&1; then reboot; fi + sudo dpkg --configure -a + sudo apt-get -y install fastfetch - name: "Checkout Armbian configuration tool" uses: actions/checkout@v4 with: path: 'config' - - name: "${{ env.DESCRIPTION }}" + - name: "Run fastfecth" run: | fastfetch - - name: "Run unit test: ${{ matrix.server.id }} " + - name: "Run unit test: ${{ matrix.server.name }} " run: | export TERM=linux - rm -rf test - mkdir -p test + rm -rf test; mkdir -p test cd config + # assemble armbian config bash tools/config-assemble.sh -p - RAWCOMMAND=$(./bin/armbian-config --cmd | grep "${{ matrix.server.id }}" | xargs) - COMMAND=$(echo $RAWCOMMAND | cut -d" " -f1,2) - DESCRIPTION=$(echo $RAWCOMMAND | cut -d" " -f4-) - echo "DESCRIPTION=$DESCRIPTION" >> "${GITHUB_ENV}" + # read test source "${{ matrix.server.package }}" # Test case execution @@ -119,11 +119,11 @@ jobs: figlet "RUN TEST CASE" testcase # function inside test script finish_time=$(date +%s) - - # Generate table entry - echo "|${{ matrix.server.os }}|\`armbian-config ${COMMAND}\`| ${DESCRIPTION} | $((finish_time - start_time)) sec |" > ../test/${{ matrix.server.id }}-${{ matrix.server.os }} - - name: "${{ env.DESCRIPTION }}" + # Generate table entry + echo "|${{ matrix.server.os }}| ${{ matrix.server.name }} | $((finish_time - start_time)) sec |" > ../test/${{ matrix.server.id }}-${{ matrix.server.os }} + + - name: "Run fastfecth" run: | fastfetch @@ -152,11 +152,11 @@ jobs: run: | echo "# Succesful tests:" >> $GITHUB_STEP_SUMMARY - echo "|Release|Command|Description|Duration|" >> $GITHUB_STEP_SUMMARY - echo "|:---|:---|:---|---:|" >> $GITHUB_STEP_SUMMARY + echo "|Release|Test name|Duration|" >> $GITHUB_STEP_SUMMARY + echo "|:---|:---|---:|" >> $GITHUB_STEP_SUMMARY cat test/* | sed '$ s/.$//' >> $GITHUB_STEP_SUMMARY - uses: geekyeggo/delete-artifact@v5 with: name: | - test-* \ No newline at end of file + test-* diff --git a/tests/MAN001.conf b/tests/MAN001.conf deleted file mode 100644 index 578cfd0a..00000000 --- a/tests/MAN001.conf +++ /dev/null @@ -1,9 +0,0 @@ -ENABLED=true -RELEASE="bookworm:noble" # run on specific or leave empty to run on all - -testcase() {( - set -e - ./bin/armbian-config --api module_cockpit remove || true - ./bin/armbian-config --api module_cockpit install - [[ -f /usr/bin/cockpit-bridge ]] -)} diff --git a/tests/cockpit.conf b/tests/cockpit.conf new file mode 100644 index 00000000..31b2e06a --- /dev/null +++ b/tests/cockpit.conf @@ -0,0 +1,11 @@ +ENABLED=true +RELEASE="noble" +TESTNAME="Cockpit install" + +testcase() {( + set -e + ./bin/armbian-config --api module_cockpit remove + ./bin/armbian-config --api module_cockpit install + sudo systemctl start cockpit.service + sudo systemctl is-active --quiet cockpit.service +)} diff --git a/tests/HAS001.conf b/tests/homeassistant.conf similarity index 81% rename from tests/HAS001.conf rename to tests/homeassistant.conf index 8469dec2..05b53f23 100644 --- a/tests/HAS001.conf +++ b/tests/homeassistant.conf @@ -1,5 +1,6 @@ ENABLED=false RELEASE="bookworm" +TESTNAME="Home Assistant install" testcase() {( set -e diff --git a/tests/DAT001.conf b/tests/mariadb.conf similarity index 75% rename from tests/DAT001.conf rename to tests/mariadb.conf index 58f13f49..8b60a9bf 100644 --- a/tests/DAT001.conf +++ b/tests/mariadb.conf @@ -1,8 +1,9 @@ ENABLED=false +RELEASE="bookworm" +TESTNAME="Mariadb install" testcase() {( set -e ./bin/armbian-config --api module_mariadb install ./bin/armbian-config --api module_mariadb status - docker container ls -a )} diff --git a/tests/NAV001.conf b/tests/navidrome.conf similarity index 54% rename from tests/NAV001.conf rename to tests/navidrome.conf index a3d9d4d1..3f6431ab 100644 --- a/tests/NAV001.conf +++ b/tests/navidrome.conf @@ -1,10 +1,10 @@ ENABLED=true -RELEASE="bookworm:noble" +RELEASE="noble" +TESTNAME="Navidrome install" testcase() {( set -e ./bin/armbian-config --api module_navidrome remove ./bin/armbian-config --api module_navidrome install - container=$(docker container ls -a | mawk '/navidrome?( |$)/{print $1}') - [[ -n "$container" ]] + ./bin/armbian-config --api module_navidrome status )} diff --git a/tests/HAB001.conf b/tests/openhab.conf similarity index 67% rename from tests/HAB001.conf rename to tests/openhab.conf index 7be41674..184f58f4 100644 --- a/tests/HAB001.conf +++ b/tests/openhab.conf @@ -1,8 +1,10 @@ ENABLED=true RELEASE="bookworm" +TESTNAME="OpenHab install" function testcase {( set -e + ./bin/armbian-config --api module_openhab remove ./bin/armbian-config --api module_openhab install systemctl is-active --quiet openhab.service )} diff --git a/tests/CON005.conf b/tests/portainer.conf similarity index 59% rename from tests/CON005.conf rename to tests/portainer.conf index 0ebb906c..4cc332fd 100644 --- a/tests/CON005.conf +++ b/tests/portainer.conf @@ -1,8 +1,10 @@ ENABLED=true -RELEASE="bookworm:noble" +RELEASE="noble" +TESTNAME="Portainer install" testcase() {( set -e + ./bin/armbian-config --api module_portainer remove ./bin/armbian-config --api module_portainer install ./bin/armbian-config --api module_portainer status )} diff --git a/tests/SY206.conf b/tests/rolling.conf similarity index 81% rename from tests/SY206.conf rename to tests/rolling.conf index 780ac021..a3863de5 100644 --- a/tests/SY206.conf +++ b/tests/rolling.conf @@ -1,5 +1,6 @@ ENABLED=true RELEASE="bookworm" +TESTNAME="Rolling repository" testcase() {( set -e diff --git a/tests/SY207.conf b/tests/stable.conf similarity index 81% rename from tests/SY207.conf rename to tests/stable.conf index 5f87c501..097222d6 100644 --- a/tests/SY207.conf +++ b/tests/stable.conf @@ -1,5 +1,6 @@ ENABLED=true RELEASE="bookworm" +TESTNAME="Stable repository" testcase() {( set -e diff --git a/tests/MON001.conf b/tests/uptimekuma.conf similarity index 58% rename from tests/MON001.conf rename to tests/uptimekuma.conf index ff7959ca..75fe8115 100644 --- a/tests/MON001.conf +++ b/tests/uptimekuma.conf @@ -1,11 +1,10 @@ ENABLED=true -RELEASE="bookworm:noble" +RELEASE="noble" +TESTNAME="Uptimekuma install" testcase() {( set -e - ./bin/armbian-config --api module_uptimekuma remove || true + ./bin/armbian-config --api module_uptimekuma remove ./bin/armbian-config --api module_uptimekuma install ./bin/armbian-config --api module_uptimekuma status - ./bin/armbian-config --api module_uptimekuma remove - ! ./bin/armbian-config --api module_uptimekuma status )}