From 97b72a4b8cf25bf56c9272712dd1e87199c896da Mon Sep 17 00:00:00 2001 From: David Edler Date: Thu, 21 Nov 2024 18:00:04 +0100 Subject: [PATCH] chore(ci) add workflow to run e2e tests from lxd-ui Signed-off-by: David Edler --- .github/workflows/tests.yml | 155 +++++++++++++++++++++++++++++++++++- 1 file changed, 154 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 143f8084e570..a3353d9eea23 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -292,7 +292,7 @@ jobs: tics: name: Tiobe TICS runs-on: ubuntu-22.04 - needs: system-tests + needs: [system-tests, ui-e2e-tests] env: CGO_CFLAGS: "-I/home/runner/go/bin/dqlite/include/" CGO_LDFLAGS: "-L/home/runner/go/bin/dqlite/libs/" @@ -445,6 +445,159 @@ jobs: name: lxd-clients-${{ runner.os }} path: bin/ + ui-e2e-tests: + name: UI e2e tests + runs-on: ubuntu-latest + needs: [code-tests, documentation] + if: ${{ github.repository == 'canonical/lxd' && github.event_name == 'push' }} + env: + GOCOVERDIR: "/home/runner/work/lxd/lxd/coverage" + LD_LIBRARY_PATH: "/home/runner/go/bin/dqlite/libs/" + LXD_DIR: "/var/lib/lxd" + LXD_OIDC_CLIENT_ID: ${{ secrets.LXD_UI_OIDC_CLIENT_ID }} + LXD_OIDC_ISSUER: ${{ secrets.LXD_UI_OIDC_ISSUER }} + LXD_OIDC_AUDIENCE: ${{ secrets.LXD_UI_OIDC_AUDIENCE }} + LXD_OIDC_USER: ${{ secrets.LXD_UI_OIDC_TEST_USER }} + LXD_OIDC_PASSWORD: ${{ secrets.LXD_UI_OIDC_TEST_PASSWORD }} + LXD_OIDC_GROUPS_CLAIM: "lxd-idp-groups" + steps: + - name: Checkout code + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Tune disk performance + uses: ./.github/actions/tune-disk-performance + + - name: Install runtime dependencies + uses: ./.github/actions/install-lxd-runtimedeps + + - name: Download minio/mc to add to system test dependencies + uses: ./.github/actions/download-minio + + - name: Download system test dependencies + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 + with: + name: system-test-deps + merge-multiple: true + path: /home/runner/go/bin + + - name: Set exec perms on LXD binaries + run: | + set -eux + ls -lR /home/runner/go/bin/ + chmod uog+x /home/runner/go/bin/* + + - name: Download docs (for the objects.inv.txt file to be available for the e2e tests) + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 + with: + name: documentation + merge-multiple: true + path: doc/_build + + - name: Make GOCOVERDIR + run: | + set -eux + mkdir -p "${GOCOVERDIR}" + if: env.GOCOVERDIR != '' + + - name: Run LXD daemon + run: | + set -eux + echo "root:1000000:1000000000" | sudo tee /etc/subuid /etc/subgid + export LXD_DOCUMENTATION="/home/runner/work/lxd/lxd/doc/_build/" + export PATH="/home/runner/go/bin:$PATH" + sudo rm -rf /var/lib/lxd + sudo --preserve-env=PATH,GOPATH,GOCOVERDIR,LD_LIBRARY_PATH,LXD_DOCUMENTATION $(go env GOPATH)/bin/lxd --group sudo & + + - name: Checkout LXD-UI + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + repository: 'canonical/lxd-ui' + ref: main + path: lxd-ui + + - name: Install Dotrun + run: sudo pip3 install dotrun + + - name: Install LXD-UI dependencies + run: | + set -eux + sudo chmod 0777 ./lxd-ui + cd lxd-ui + dotrun install + + - name: Run LXD-UI + env: + ENVIRONMENT: devel + PORT: 8407 + LXD_UI_BACKEND_IP: 172.17.0.1 + run: | + set -eux + cd lxd-ui + dotrun & + curl --head --fail --retry-delay 2 --retry 100 --retry-connrefused --insecure https://localhost:${{ env.PORT }} + + - name: Setup LXD + shell: bash + run: | + set -eux + export PATH="/home/runner/go/bin:$PATH" + sudo -E LXD_DIR=/var/lib/lxd lxc storage create default zfs + sudo -E LXD_DIR=/var/lib/lxd lxc profile device add default root disk path=/ pool=default + sudo -E LXD_DIR=/var/lib/lxd lxc network create local-network + sudo -E LXD_DIR=/var/lib/lxd lxc profile device add default eth0 nic network=local-network + sudo -E LXD_DIR=/var/lib/lxd lxc config set core.https_address "[::]:8443" + sudo -E LXD_DIR=/var/lib/lxd lxc config set cluster.https_address "127.0.0.1" + sudo -E LXD_DIR=/var/lib/lxd lxc cluster enable local + sudo -E LXD_DIR=/var/lib/lxd lxc config set user.show_permissions=true + sudo -E LXD_DIR=/var/lib/lxd lxc config trust add lxd-ui/keys/lxd-ui.crt + + - uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Install Playwright Browsers + run: | + set -eux + cd lxd-ui + npx playwright install --with-deps chromium + + - name: Setup for LXD-UI tests + shell: bash + run: | + set -eux + sudo -E LXD_DIR=/var/lib/lxd PATH=/home/runner/go/bin:$PATH ./lxd-ui/tests/scripts/setup_test + + - name: Run Playwright tests + run: | + set -eux + cd lxd-ui + sudo chown $USER -R /home/runner/.config + sudo chown $USER /var/lib/lxd/unix.socket + CI=true DISABLE_VM_TESTS=true LXD_DIR=/var/lib/lxd PATH=/home/runner/go/bin:$PATH npx playwright test --project chromium:lxd-latest-edge + #npx playwright test --project chromium:lxd-5.21-edge + #npx playwright test --project lxd-5.0-edge + + - name: Upload lxd-ui test artifacts + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 + if: always() + with: + name: lxd-ui-test-report + path: lxd-ui/blob-report + retention-days: 14 + + - name: Shutdown LXD daemon + run: | + set -eux + export PATH="/home/runner/go/bin:$PATH" + sudo --preserve-env=PATH,GOPATH,GOCOVERDIR,LD_LIBRARY_PATH $(go env GOPATH)/bin/lxd shutdown + + - name: Upload coverage data + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 + with: + name: coverage-ui-e2e-tests + path: ${{env.GOCOVERDIR}} + if: env.GOCOVERDIR != '' + documentation: name: Documentation runs-on: ubuntu-latest