Skip to content

Commit 3cd0494

Browse files
GabrielDufclaude
andcommitted
Run the AUR manager end to end against real paru and yay on Arch Linux
Throwaway branch: the workflow runs only on pushes to ci/aur-e2e or by hand, never on pull requests, so PR checks are unaffected. Each helper gets its own archlinux container job with only that helper installed, an unprivileged build user with passwordless sudo, and the SDK from global.json. The job captures the helper's real -Ss, -Si, -Qua and pacman -Qm/-Qn output as an artifact, then runs AurEndToEndTests (gated by UNIGETUI_AUR_E2E=1) as the build user: detection, search, details, install and uninstall of pfetch through the operation classes, and the Pacman -Qn split. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 3f30c1c commit 3cd0494

2 files changed

Lines changed: 216 additions & 0 deletions

File tree

‎.github/workflows/aur-e2e.yml‎

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: AUR end-to-end
2+
3+
on:
4+
push:
5+
branches: [ "ci/aur-e2e" ]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
aur-e2e:
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
helper: [ paru, yay ]
17+
18+
name: Arch Linux (${{ matrix.helper }})
19+
runs-on: ubuntu-latest
20+
container: archlinux:latest
21+
timeout-minutes: 45
22+
23+
steps:
24+
- name: Install base tools and an unprivileged build user
25+
run: |
26+
pacman -Syu --noconfirm --needed base-devel git sudo icu krb5 openssl zlib
27+
useradd -m builder
28+
echo 'builder ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/builder
29+
chmod 440 /etc/sudoers.d/builder
30+
31+
- name: Checkout repository
32+
uses: actions/checkout@v7
33+
34+
- name: Install .NET SDK
35+
run: |
36+
curl -sSL https://dot.net/v1/dotnet-install.sh -o /tmp/dotnet-install.sh
37+
bash /tmp/dotnet-install.sh --jsonfile global.json --install-dir /opt/dotnet
38+
ln -sf /opt/dotnet/dotnet /usr/local/bin/dotnet
39+
dotnet --version
40+
41+
- name: Install ${{ matrix.helper }} from the AUR
42+
run: |
43+
sudo -u builder bash -euo pipefail -c '
44+
cd ~
45+
git clone --depth 1 https://aur.archlinux.org/${{ matrix.helper }}-bin.git
46+
cd ${{ matrix.helper }}-bin
47+
makepkg -si --noconfirm
48+
'
49+
${{ matrix.helper }} --version
50+
51+
- name: Capture real ${{ matrix.helper }} output
52+
run: |
53+
mkdir -p "$GITHUB_WORKSPACE/aur-output"
54+
chown builder: "$GITHUB_WORKSPACE/aur-output"
55+
sudo -u builder env LANG=C LC_ALL=C bash -c '
56+
out="$1"; helper="$2"
57+
run() {
58+
name="$1"; shift
59+
"$@" > "$out/$name.stdout" 2> "$out/$name.stderr"
60+
echo "$?" > "$out/$name.exitcode"
61+
}
62+
run version "$helper" --version
63+
run search "$helper" -Ss --aur --color=never pfetch
64+
run search-multiword "$helper" -Ss --aur --color=never fetch system
65+
run search-none "$helper" -Ss --aur --color=never zzzz-unigetui-no-such-package
66+
run info "$helper" -Si --aur --color=never pfetch
67+
run info-many-deps "$helper" -Si --aur --color=never visual-studio-code-bin
68+
run updates "$helper" -Qua --color=never
69+
run foreign pacman -Qm --color=never
70+
run native pacman -Qn --color=never
71+
' _ "$GITHUB_WORKSPACE/aur-output" "${{ matrix.helper }}"
72+
for f in "$GITHUB_WORKSPACE"/aur-output/*.exitcode; do echo "$(basename "$f"): $(cat "$f")"; done
73+
74+
- name: Run the AUR tests as the build user
75+
run: |
76+
chown -R builder: "$GITHUB_WORKSPACE"
77+
sudo -u builder env \
78+
HOME=/home/builder \
79+
DOTNET_ROOT=/opt/dotnet \
80+
DOTNET_CLI_TELEMETRY_OPTOUT=1 \
81+
DOTNET_NOLOGO=1 \
82+
UNIGETUI_AUR_E2E=1 \
83+
UNIGETUI_AUR_E2E_HELPER=${{ matrix.helper }} \
84+
bash -euo pipefail -c '
85+
cd "$1/src"
86+
dotnet test UniGetUI.PackageEngine.Tests/UniGetUI.PackageEngine.Tests.csproj \
87+
--nologo \
88+
--logger "console;verbosity=detailed" \
89+
--filter "FullyQualifiedName~AurEndToEndTests|FullyQualifiedName~AurManagerTests|FullyQualifiedName~AlpmVersionTests|FullyQualifiedName~ManagerSetupGuideTests"
90+
' _ "$GITHUB_WORKSPACE"
91+
92+
- name: Upload captured helper output
93+
if: always()
94+
uses: actions/upload-artifact@v7
95+
with:
96+
name: aur-output-${{ matrix.helper }}
97+
path: aur-output
98+
if-no-files-found: warn
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
using System.Diagnostics;
2+
using UniGetUI.Core.Data;
3+
using UniGetUI.PackageEngine.Enums;
4+
using UniGetUI.PackageEngine.Interfaces;
5+
using UniGetUI.PackageEngine.Managers.AurManager;
6+
using UniGetUI.PackageEngine.Managers.PacmanManager;
7+
using UniGetUI.PackageEngine.Operations;
8+
using UniGetUI.PackageEngine.PackageClasses;
9+
using UniGetUI.PackageEngine.PackageLoader;
10+
using UniGetUI.PackageEngine.Serializable;
11+
using UniGetUI.PackageOperations;
12+
13+
namespace UniGetUI.PackageEngine.Tests;
14+
15+
public sealed class AurEndToEndFactAttribute : FactAttribute
16+
{
17+
public const string Variable = "UNIGETUI_AUR_E2E";
18+
19+
public AurEndToEndFactAttribute()
20+
{
21+
if (Environment.GetEnvironmentVariable(Variable) != "1")
22+
Skip = $"Builds and installs a real AUR package through paru or yay; set {Variable}=1 to run on Arch Linux.";
23+
}
24+
}
25+
26+
[CollectionDefinition("AUR end to end", DisableParallelization = true)]
27+
public sealed class AurEndToEndTestCollection;
28+
29+
[Collection("AUR end to end")]
30+
public sealed class AurEndToEndTests
31+
{
32+
private const string TestPackage = "pfetch";
33+
34+
private static AurHelperKind ExpectedHelper() =>
35+
Environment.GetEnvironmentVariable("UNIGETUI_AUR_E2E_HELPER") switch
36+
{
37+
"paru" => AurHelperKind.Paru,
38+
"yay" => AurHelperKind.Yay,
39+
var other => throw new InvalidOperationException($"UNIGETUI_AUR_E2E_HELPER must be paru or yay, not '{other}'"),
40+
};
41+
42+
private static Aur ReadyAur()
43+
{
44+
CoreData.ElevatorPath = "/usr/bin/sudo";
45+
CoreData.ElevatorArgs = "-A";
46+
Environment.SetEnvironmentVariable("SUDO_ASKPASS", "/usr/bin/false");
47+
48+
var aur = new Aur();
49+
aur.Initialize();
50+
Assert.True(aur.IsReady(), $"AUR manager not ready: {aur.Status.Version} ({aur.Status.ExecutablePath})");
51+
Assert.Equal(ExpectedHelper(), aur.HelperKind);
52+
Assert.Equal(Environment.GetEnvironmentVariable("UNIGETUI_AUR_E2E_HELPER"), aur.Properties.ExecutableFriendlyName);
53+
return aur;
54+
}
55+
56+
private static int CountInstalled(IPackageManager manager) =>
57+
manager.GetInstalledPackages().Count(p => p.Id == TestPackage);
58+
59+
private static async Task Completes(AbstractOperation operation)
60+
{
61+
await operation.MainThread().WaitAsync(TimeSpan.FromMinutes(10));
62+
string output = string.Join(Environment.NewLine, operation.GetOutput().Select(l => l.Item1));
63+
Console.WriteLine(output);
64+
Assert.True(operation.Status == OperationStatus.Succeeded, output);
65+
}
66+
67+
private static bool PacmanHas(string package)
68+
{
69+
using var p = Process.Start(new ProcessStartInfo("pacman", ["-Q", package]) { RedirectStandardOutput = true, RedirectStandardError = true })!;
70+
p.WaitForExit();
71+
return p.ExitCode == 0;
72+
}
73+
74+
[AurEndToEndFact]
75+
public async Task SearchesShowsDetailsInstallsListsAndRemovesARealAurPackage()
76+
{
77+
_ = new DiscoverablePackagesLoader([]);
78+
_ = new UpgradablePackagesLoader([]);
79+
_ = new InstalledPackagesLoader([]);
80+
81+
var aur = ReadyAur();
82+
Assert.False(string.IsNullOrWhiteSpace(aur.Status.Version));
83+
Assert.False(PacmanHas(TestPackage), $"{TestPackage} is already installed; the runner must start clean");
84+
85+
var found = aur.FindPackages(TestPackage, out bool searchFailed);
86+
Assert.False(searchFailed);
87+
var offered = Assert.Single(found, p => p.Id == TestPackage);
88+
Assert.Matches(@"^\d", offered.VersionString);
89+
90+
var details = new PackageDetails(offered);
91+
await details.Load();
92+
Assert.True(details.IsPopulated);
93+
Assert.False(string.IsNullOrWhiteSpace(details.Description));
94+
Assert.Equal(new Uri($"https://aur.archlinux.org/packages/{TestPackage}"), details.ManifestUrl);
95+
Assert.False(string.IsNullOrWhiteSpace(details.Publisher));
96+
97+
using (var install = new InstallPackageOperation(offered, new InstallOptions { RunAsAdministrator = true }, IgnoreParallelInstalls: true))
98+
await Completes(install);
99+
Assert.True(PacmanHas(TestPackage), $"{TestPackage} is not installed after the install operation");
100+
101+
Assert.Equal(1, CountInstalled(aur));
102+
103+
var pacman = new Pacman();
104+
pacman.Initialize();
105+
Assert.True(pacman.IsReady());
106+
Assert.Equal(1, CountInstalled(pacman));
107+
pacman.ForeignPackagesListedElsewhere = aur.IsReady;
108+
Assert.Equal(0, CountInstalled(pacman));
109+
110+
Assert.DoesNotContain(aur.GetAvailableUpdates(), p => p.Id == TestPackage);
111+
112+
var installed = aur.GetInstalledPackages().Single(p => p.Id == TestPackage);
113+
using (var uninstall = new UninstallPackageOperation(installed, new InstallOptions(), IgnoreParallelInstalls: true))
114+
await Completes(uninstall);
115+
Assert.False(PacmanHas(TestPackage), $"{TestPackage} is still installed after the uninstall operation");
116+
Assert.Equal(0, CountInstalled(aur));
117+
}
118+
}

0 commit comments

Comments
 (0)