diff --git a/.gitea/workflows/e2e-tests.yaml b/.gitea/workflows/e2e-tests.yaml new file mode 100644 index 0000000..5ea2b44 --- /dev/null +++ b/.gitea/workflows/e2e-tests.yaml @@ -0,0 +1,57 @@ +# ALR - Any Linux Repository +# Copyright (C) 2025 The ALR Authors +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +name: E2E + +on: + push: + branches: [ main ] + pull_request: + + +jobs: + tests: + runs-on: ubuntu-latest + + container: + image: altlinux.space/maks1ms/actions-container-runner:latest + + steps: + - name: Checkout + uses: https://github.com/actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Go + uses: https://github.com/actions/setup-go@v5 + with: + go-version: '1.24' + + - name: Cache Podman images + uses: actions/cache@v4 + with: + path: | + ~/.local/share/containers/storage + /var/lib/containers/storage + key: ${{ runner.os }}-primes + + - name: Run E2E tests + env: + DOCKER_HOST: unix:///tmp/podman.sock + IGNORE_ROOT_CHECK: 1 + run: | + podman system service -t 0 unix:///tmp/podman.sock & + make e2e-test diff --git a/e2e-tests/common_test.go b/e2e-tests/common_test.go index 88424c3..90b4fb1 100644 --- a/e2e-tests/common_test.go +++ b/e2e-tests/common_test.go @@ -25,7 +25,6 @@ import ( "io" "log" "os" - "os/exec" "testing" "time" @@ -121,29 +120,6 @@ var COMMON_SYSTEMS []string = []string{ "ubuntu-24.04", } -func init() { - for _, id := range ALL_SYSTEMS { - buildAlrTestImage(id) - } -} - -func buildAlrTestImage(id string) { - cmd := exec.Command( - "docker", - "build", - "-t", fmt.Sprintf("alr-testimage-%s", id), - "-f", fmt.Sprintf("images/Dockerfile.%s", id), - ".", - ) - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - err := cmd.Run() - if err != nil { - fmt.Println("Error:", err) - return - } -} - func dockerMultipleRun(t *testing.T, name string, ids []string, f func(t *testing.T, runnable e2e.Runnable)) { t.Run(name, func(t *testing.T) { for _, id := range ids { @@ -158,17 +134,25 @@ func dockerMultipleRun(t *testing.T, name string, ids []string, f func(t *testin e, err := e2e.New(e2e.WithVerbose(), e2e.WithName(fmt.Sprintf("alr-%s", truncatedHash))) assert.NoError(t, err) t.Cleanup(e.Close) - imageId := fmt.Sprintf("alr-testimage-%s", id) + imageId := fmt.Sprintf("ghcr.io/maks1ms/alr-e2e-test-image-%s", id) runnable := e.Runnable(dockerName).Init( e2e.StartOptions{ - Image: imageId, + Image: imageId, Volumes: []string{ - // "./alr:/usr/bin/alr", + "./alr:/tmp/alr", }, Privileged: true, }, ) assert.NoError(t, e2e.StartAndWaitReady(runnable)) + err = runnable.Exec(e2e.NewCommand("/bin/alr-test-setup", "alr-install")) + if err != nil { + panic(err) + } + err = runnable.Exec(e2e.NewCommand("/bin/alr-test-setup", "passwordless-sudo-setup")) + if err != nil { + panic(err) + } f(t, runnable) }) } diff --git a/e2e-tests/images/Dockerfile.alpine b/e2e-tests/images/Dockerfile.alpine deleted file mode 100644 index 698d0fe..0000000 --- a/e2e-tests/images/Dockerfile.alpine +++ /dev/null @@ -1,4 +0,0 @@ -FROM alpine:latest -RUN adduser -s /bin/bash alr-user -USER alr-user -ENTRYPOINT ["tail", "-f", "/dev/null"] \ No newline at end of file diff --git a/e2e-tests/images/Dockerfile.alt-sisyphus b/e2e-tests/images/Dockerfile.alt-sisyphus deleted file mode 100644 index cc48dee..0000000 --- a/e2e-tests/images/Dockerfile.alt-sisyphus +++ /dev/null @@ -1,6 +0,0 @@ -FROM registry.altlinux.org/sisyphus/alt:latest -RUN apt-get update && apt-get install -y ca-certificates rpm-build -RUN useradd -m -s /bin/bash alr-user -USER alr-user -WORKDIR /home/alr-user -ENTRYPOINT ["tail", "-f", "/dev/null"] \ No newline at end of file diff --git a/e2e-tests/images/Dockerfile.archlinux b/e2e-tests/images/Dockerfile.archlinux deleted file mode 100644 index 37484ea..0000000 --- a/e2e-tests/images/Dockerfile.archlinux +++ /dev/null @@ -1,4 +0,0 @@ -FROM archlinux:latest -RUN useradd -m -s /bin/bash alr-user -USER alr-user -ENTRYPOINT ["tail", "-f", "/dev/null"] \ No newline at end of file diff --git a/e2e-tests/images/Dockerfile.fedora-41 b/e2e-tests/images/Dockerfile.fedora-41 deleted file mode 100644 index f91b28f..0000000 --- a/e2e-tests/images/Dockerfile.fedora-41 +++ /dev/null @@ -1,18 +0,0 @@ -FROM fedora:41 -RUN dnf install -y ca-certificates sudo rpm-build bindfs -RUN <> /etc/sudoers.d/user - chmod 0440 /etc/sudoers.d/user - - useradd -m -s /bin/bash alr - mkdir -p /var/cache/alr /etc/alr - chown alr:alr /var/cache/alr /etc/alr -EOF -COPY ./alr /usr/bin -RUN <> /etc/sudoers.d/user - chmod 0440 /etc/sudoers.d/user - - useradd -m -s /bin/bash alr - mkdir -p /var/cache/alr /etc/alr - chown alr:alr /var/cache/alr /etc/alr -EOF -COPY ./alr /usr/bin -RUN <