From baa5eac3c5735dd2770a341c3d3a9d75e8b37f86 Mon Sep 17 00:00:00 2001 From: Vibe Myass Date: Mon, 16 Mar 2026 04:39:20 +0000 Subject: [PATCH] Reuse preinstalled .NET 10 SDK in CI --- .gitea/workflows/smoke.yml | 21 +++++++++++++++------ README.md | 3 ++- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.gitea/workflows/smoke.yml b/.gitea/workflows/smoke.yml index be277a9..ac6976b 100644 --- a/.gitea/workflows/smoke.yml +++ b/.gitea/workflows/smoke.yml @@ -74,34 +74,43 @@ jobs: echo "Non-root runner detected; smoke-only test lane enabled." fi - - name: Install .NET SDK + - name: Resolve .NET SDK run: | set -euo pipefail + + if command -v dotnet >/dev/null 2>&1 && dotnet --list-sdks | grep -Eq '^10\.'; then + echo "Using preinstalled .NET 10 SDK from PATH." + echo "DOTNET_CMD=dotnet" >> "$GITHUB_ENV" + exit 0 + fi + + echo "Preinstalled .NET 10 SDK not found. Installing local SDK copy." curl -fsSL https://dot.net/v1/dotnet-install.sh -o dotnet-install.sh bash dotnet-install.sh --channel 10.0 --quality ga --install-dir "$HOME/.dotnet" + echo "DOTNET_CMD=$HOME/.dotnet/dotnet" >> "$GITHUB_ENV" - name: Show .NET info run: | set -euo pipefail - "$HOME/.dotnet/dotnet" --info + "${DOTNET_CMD}" --info - name: Restore run: | set -euo pipefail - "$HOME/.dotnet/dotnet" restore + "${DOTNET_CMD}" restore - name: Build run: | set -euo pipefail - "$HOME/.dotnet/dotnet" build --no-restore + "${DOTNET_CMD}" build --no-restore - name: Smoke tests run: | set -euo pipefail - LIBNFTABLES_RUN_PRIVILEGED_TESTS=0 "$HOME/.dotnet/dotnet" test LibNftables.slnx --no-build --filter "Category!=Privileged" + LIBNFTABLES_RUN_PRIVILEGED_TESTS=0 "${DOTNET_CMD}" test LibNftables.slnx --no-build --filter "Category!=Privileged" - name: Privileged tests if: env.RUN_PRIVILEGED_TESTS == '1' run: | set -euo pipefail - LIBNFTABLES_RUN_PRIVILEGED_TESTS=1 "$HOME/.dotnet/dotnet" test LibNftables.slnx --no-build --filter "Category=Privileged" + LIBNFTABLES_RUN_PRIVILEGED_TESTS=1 "${DOTNET_CMD}" test LibNftables.slnx --no-build --filter "Category=Privileged" diff --git a/README.md b/README.md index 4436be7..a8cd02b 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,8 @@ The repository includes a Gitea Actions smoke workflow at `.gitea/workflows/smok - Runner label: `debian-13` - Job model: root-aware smoke verification - Workflow actions: - - bootstrap the .NET 10 SDK inside the job + - use a preinstalled .NET 10 SDK when the runner already has one + - otherwise bootstrap a local .NET 10 SDK inside the job - restore - build - always run the non-privileged smoke test lane