diff --git a/.github/actions/install-lxd-runtimedeps/action.yml b/.github/actions/install-lxd-runtimedeps/action.yml index 9373baa5f0d4..185049051d0c 100644 --- a/.github/actions/install-lxd-runtimedeps/action.yml +++ b/.github/actions/install-lxd-runtimedeps/action.yml @@ -9,6 +9,7 @@ runs: run: | set -eux sudo add-apt-repository ppa:ubuntu-lxc/daily -y --no-update + sudo add-apt-repository ppa:dqlite/dev -y --no-update sudo apt-get update # mask services from lxc-utils (`lxc-*` tools are used in test/suites/lxc-to-lxd.sh) @@ -18,7 +19,18 @@ runs: sudo apt-get install --no-install-recommends -y \ curl \ git \ + libacl1-dev \ + libcap-dev \ + libdbus-1-dev \ + libdqlite-dev \ + liblxc-dev \ + libseccomp-dev \ + libselinux-dev \ + libsqlite3-dev \ + libtool \ + libudev-dev \ make \ + pkg-config\ acl \ attr \ bind9-dnsutils \ @@ -45,5 +57,3 @@ runs: xz-utils \ zfsutils-linux - # reclaim some space - sudo apt-get clean diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 143f8084e570..75a42933dadf 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,168 @@ 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: + 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 Go + uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0 + with: + go-version-file: 'go.mod' + + - 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 CGO_CFLAGS="-I/home/runner/work/lxd/lxd-test/vendor/dqlite/include/" + export CGO_LDFLAGS="-L/home/runner/work/lxd/lxd-test/vendor/dqlite/.libs/" + export LD_LIBRARY_PATH="/home/runner/work/lxd/lxd-test/vendor/dqlite/.libs/" + export LXD_DOCUMENTATION="/home/runner/work/lxd/lxd/doc/_build/" + export PATH="/home/runner/go/bin:$PATH" + sudo rm -rf /var/lib/lxd + sudo -E PATH=${PATH} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} $(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 CGO_CFLAGS="-I/home/runner/work/lxd/lxd-test/vendor/dqlite/include/" + export CGO_LDFLAGS="-L/home/runner/work/lxd/lxd-test/vendor/dqlite/.libs/" + export LD_LIBRARY_PATH="/home/runner/work/lxd/lxd-test/vendor/dqlite/.libs/" + export PATH="/home/runner/go/bin:$PATH" + sudo -E PATH=${PATH} LD_LIBRARY_PATH=${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