Update .gitea/workflows/dotnet-test.yml
Some checks failed
CI Demo / build (push) Successful in 3s
Docker Test / docker-ops (push) Successful in 5s
.NET Test / dotnet-test (push) Failing after 17s
Go Test / go-test (push) Failing after 5s
Java Test / java-hello (push) Successful in 33s
Julia Test / julia-test (push) Failing after 4s
Kotlin Test / kotlin-hello (push) Successful in 42s
Node.js Test / nodejs-test (push) Failing after 5s
Notebook Test / nb-test (push) Failing after 8s
PHP Test / php-test (push) Successful in 36s
Python Test / python-hello (push) Successful in 4s
Rust Test / rust-test (push) Has been cancelled
Scala Test / scala-test (push) Has been cancelled
Swift Test / swift-hello (push) Has been cancelled
R Test / r-cmdcheck (push) Has been cancelled

This commit is contained in:
2025-08-07 20:28:36 +00:00
parent cd41b688d1
commit f6e7b68fdf

View File

@@ -23,7 +23,6 @@ jobs:
set -euo pipefail
has_solution=false
# Group the -name tests so -o doesn't mess with precedence
if find . -maxdepth 2 \( -name '*.sln' -o -name '*.csproj' \) | grep -q .; then
has_solution=true
fi
@@ -32,8 +31,7 @@ jobs:
echo "Detected .NET project; restoring/building/testing..."
dotnet restore
dotnet build --no-restore -c Release
# Run tests if any project is a test project
if find . -name '*Tests.csproj' -o -name '*.csproj' -exec grep -l '<IsTestProject>true</IsTestProject>' {} + | grep -q .; then
if find . \( -name '*Tests.csproj' -o -name '*.csproj' \) -exec grep -l '<IsTestProject>true</IsTestProject>' {} + | grep -q .; then
dotnet test --no-build -c Release --verbosity normal
else
echo "No test projects found; build succeeded, skipping tests."
@@ -46,15 +44,15 @@ jobs:
dotnet sln HelloCI.sln add src/App/App.csproj tests/App.Tests/App.Tests.csproj
dotnet add tests/App.Tests/App.Tests.csproj reference src/App/App.csproj
# Heredoc terminator must start at column 0 — no indentation
# Keep indentation consistent under `run: |`. YAML strips it; bash sees EOF at col 0.
cat > tests/App.Tests/UnitTest1.cs <<'EOF'
using Xunit;
namespace App.Tests;
public class UnitTest1
{
[Fact] public void Adds() => Assert.Equal(4, 2+2);
}
EOF
using Xunit;
namespace App.Tests;
public class UnitTest1
{
[Fact] public void Adds() => Assert.Equal(4, 2+2);
}
EOF
dotnet restore
dotnet build -c Release