diff --git a/.drone.jsonnet b/.drone.jsonnet index 37656cc..d51df79 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -3,10 +3,8 @@ local openwebui = '0.9.2'; local ollama = '0.14.2'; local nginx = '1.29.3-alpine3.22'; local debian = 'bookworm-slim'; -local platforms = { - bookworm: '26.04.9', - buster: '25.02', -}; +local platform = '26.04.10'; +local dind = '20.10.21-dind'; local playwright = 'v1.59.1-jammy'; local deployer = 'https://github.com/syncloud/store/releases/download/4/syncloud-release'; local python = '3.12-slim-bookworm'; @@ -14,8 +12,10 @@ local go = '1.25'; local distro_default = 'bookworm'; local distros = ['bookworm', 'buster']; +local platform_image(distro, arch) = + 'syncloud/platform-' + distro + '-' + arch + ':' + platform; -local build(arch, test_ui, dind) = [{ +local build(arch, test_ui) = [{ kind: 'pipeline', type: 'docker', name: arch, @@ -33,68 +33,54 @@ local build(arch, test_ui, dind) = [{ }, { name: 'ollama', - image: "ollama/ollama:" + ollama, + image: 'ollama/ollama:' + ollama, commands: [ './ollama/build.sh', ], }, + ] + [ { - name: 'ollama test', - image: 'syncloud/platform-' + distro_default + '-' + arch + ':' + platforms[distro_default], + name: 'ollama test ' + distro, + image: platform_image(distro, arch), commands: [ './ollama/test.sh', ], - }, - { - name: 'ollama test buster', - image: 'syncloud/platform-buster-' + arch + ':' + platforms.buster, - commands: [ - './ollama/test.sh', - ], - }, + } + for distro in distros + ] + [ { name: 'openwebui', - image: "ghcr.io/open-webui/open-webui:" + openwebui, + image: 'ghcr.io/open-webui/open-webui:' + openwebui, commands: [ './openwebui/build.sh', ], }, + ] + [ { - name: 'openwebui test', - image: 'syncloud/platform-' + distro_default + '-' + arch + ':' + platforms[distro_default], + name: 'openwebui test ' + distro, + image: platform_image(distro, arch), commands: [ './openwebui/test.sh', ], + } + for distro in distros + ] + [ + { + name: 'cli', + image: 'golang:' + go, + commands: [ + './cli/build.sh', + ], }, { - name: 'openwebui test buster', - image: 'syncloud/platform-buster-' + arch + ':' + platforms.buster, + name: 'package', + image: 'debian:' + debian, commands: [ - './openwebui/test.sh', + 'VERSION=$(cat version)', + './package.sh ' + name + ' $VERSION ', ], }, - - { - name: 'cli', - image: 'golang:' + go, - commands: [ - 'cd cli', - 'CGO_ENABLED=0 go build -o ../build/snap/meta/hooks/install ./cmd/install', - 'CGO_ENABLED=0 go build -o ../build/snap/meta/hooks/configure ./cmd/configure', - 'CGO_ENABLED=0 go build -o ../build/snap/meta/hooks/pre-refresh ./cmd/pre-refresh', - 'CGO_ENABLED=0 go build -o ../build/snap/meta/hooks/post-refresh ./cmd/post-refresh', - 'CGO_ENABLED=0 go build -o ../build/snap/bin/cli ./cmd/cli', - ], - }, - { - name: 'package', - image: 'debian:' + debian, - commands: [ - 'VERSION=$(cat version)', - './package.sh ' + name + ' $VERSION ', - ], - }, - ] + [ + ] + [ { name: 'test ' + distro, image: 'python:' + python, @@ -115,15 +101,41 @@ local build(arch, test_ui, dind) = [{ ], }, { - name: 'test-upgrade', + name: 'test-upgrade-install-old', image: 'python:' + python, commands: [ 'cd test', './deps.sh', - 'py.test -x -s upgrade.py --distro=' + distro_default + ' --ver=$DRONE_BUILD_NUMBER --app=' + name, + 'py.test -x -s upgrade.py -k "test_start or test_install_old" --distro=' + distro_default + ' --ver=$DRONE_BUILD_NUMBER --app=' + name, ], privileged: true, }, + { + name: 'test-ui-on-old', + image: 'mcr.microsoft.com/playwright:' + playwright, + environment: { DEVICE_USER: 'user', DEVICE_PASSWORD: 'Password1' }, + commands: [ + './ci/ui.sh desktop ' + name + ' ' + distro_default + ' $DRONE_BUILD_NUMBER on-old admin-login.spec.ts', + ], + }, + { + name: 'test-upgrade-refresh-new', + image: 'python:' + python, + commands: [ + 'cd test', + './deps.sh', + 'py.test -x -s upgrade.py -k "test_start or test_refresh_to_new" --distro=' + distro_default + ' --ver=$DRONE_BUILD_NUMBER --app=' + name, + ], + privileged: true, + }, + { + name: 'test-ui-after-upgrade', + image: 'mcr.microsoft.com/playwright:' + playwright, + environment: { DEVICE_USER: 'user', DEVICE_PASSWORD: 'Password1' }, + commands: [ + './ci/ui.sh desktop ' + name + ' ' + distro_default + ' $DRONE_BUILD_NUMBER after-upgrade no-email-login.spec.ts', + ], + }, ] else []) + [ { name: 'upload', @@ -202,7 +214,6 @@ local build(arch, test_ui, dind) = [{ trigger: { event: [ 'push', - 'pull_request', ], }, services: [ @@ -220,8 +231,9 @@ local build(arch, test_ui, dind) = [{ ] + [ { name: name + '.' + distro + '.com', - image: 'syncloud/platform-' + distro + '-' + arch + ':' + platforms[distro], + image: platform_image(distro, arch), privileged: true, + entrypoint: ['/bin/sh', '-c', "mkdir -p /etc/systemd/system/snapd.service.d && printf '[Service]\\nExecStartPost=/bin/sh -c \"/usr/bin/snap set system refresh.hold=2099-01-01T00:00:00Z\"\\n' > /etc/systemd/system/snapd.service.d/disable-refresh.conf && exec /sbin/init"], volumes: [ { name: 'dbus', @@ -256,5 +268,5 @@ local build(arch, test_ui, dind) = [{ }, ]; -build('amd64', true, '20.10.21-dind') + -build('arm64', false, '20.10.21-dind') +build('amd64', true) + +build('arm64', false) diff --git a/ci/ui.sh b/ci/ui.sh index a67720a..9eb8e9f 100755 --- a/ci/ui.sh +++ b/ci/ui.sh @@ -4,10 +4,12 @@ PROJECT=$1 APP=$2 DISTRO=$3 VERSION=$4 +TAG=${5:-} +SPEC=${6:-} getent hosts ${APP}.${DISTRO}.com | sed "s/${APP}.${DISTRO}.com/auth.${DISTRO}.com/g" | tee -a /etc/hosts -ART=/drone/src/artifact/${PROJECT} +ART=/drone/src/artifact/${PROJECT}${TAG:+-${TAG}} mkdir -p "$ART" trap 'cp -r /drone/src/web/test-results "$ART/" 2>/dev/null; cp -r /drone/src/web/playwright-report "$ART/" 2>/dev/null; chmod -R a+r "$ART" 2>/dev/null; exit' EXIT INT TERM @@ -18,4 +20,4 @@ PLAYWRIGHT_APP=${APP} \ PLAYWRIGHT_VERSION=${VERSION} \ NO_EMAIL_USER=noemail \ NO_EMAIL_PASSWORD=Password1 \ - npx playwright test --project=${PROJECT} + npx playwright test --project=${PROJECT} ${SPEC} diff --git a/cli/build.sh b/cli/build.sh new file mode 100755 index 0000000..aca21f1 --- /dev/null +++ b/cli/build.sh @@ -0,0 +1,11 @@ +#!/bin/bash -ex + +DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +cd ${DIR} +BUILD_DIR=${DIR}/../build/snap + +CGO_ENABLED=0 go build -o ${BUILD_DIR}/meta/hooks/install ./cmd/install +CGO_ENABLED=0 go build -o ${BUILD_DIR}/meta/hooks/configure ./cmd/configure +CGO_ENABLED=0 go build -o ${BUILD_DIR}/meta/hooks/pre-refresh ./cmd/pre-refresh +CGO_ENABLED=0 go build -o ${BUILD_DIR}/meta/hooks/post-refresh ./cmd/post-refresh +CGO_ENABLED=0 go build -o ${BUILD_DIR}/bin/cli ./cmd/cli diff --git a/test/upgrade.py b/test/upgrade.py index 7dcb448..c3a1d92 100644 --- a/test/upgrade.py +++ b/test/upgrade.py @@ -25,9 +25,21 @@ def test_start(module_setup, app, device_host, domain, device): device.run_ssh('mkdir {0}'.format(TMP_DIR), throw=False) -def test_upgrade(device, device_user, device_password, device_host, app_archive_path, app_domain, app_dir): - device.run_ssh('snap remove openwebui') - device.run_ssh('snap install openwebui', retries=10) +OLD_REV = '121' + + +def test_install_old(device, app_domain): + device.run_ssh('snap remove openwebui', throw=False) + device.run_ssh( + 'curl -fsSL --retry 10 --retry-delay 10 --retry-all-errors ' + '-o /tmp/openwebui_old.snap ' + 'http://apps.syncloud.org/apps/openwebui_{rev}_amd64.snap'.format(rev=OLD_REV), + ) + device.run_ssh('snap install --dangerous /tmp/openwebui_old.snap') + wait_for_rest(requests.session(), "https://{0}".format(app_domain), 200, 100) + + +def test_refresh_to_new(device, device_host, device_password, app_archive_path, app_domain): local_install(device_host, device_password, app_archive_path) wait_for_rest(requests.session(), "https://{0}".format(app_domain), 200, 100) diff --git a/web/e2e/login.spec.ts b/web/e2e/admin-login.spec.ts similarity index 100% rename from web/e2e/login.spec.ts rename to web/e2e/admin-login.spec.ts