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) Successful in 50s
Go Test / go-test (push) Failing after 5s
Java Test / java-hello (push) Successful in 33s
Julia Test / julia-test (push) Successful in 18s
Kotlin Test / kotlin-hello (push) Successful in 35s
Node.js Test / nodejs-test (push) Has been cancelled
Notebook Test / nb-test (push) Has been cancelled
PHP Test / php-test (push) Has been cancelled
Python Test / python-hello (push) Has been cancelled
R Test / r-cmdcheck (push) Has been cancelled
Scala Test / scala-test (push) Has been cancelled
Swift Test / swift-hello (push) Has been cancelled
Rust Test / rust-test (push) Failing after 30s

This commit is contained in:
2025-08-07 20:48:21 +00:00
parent 2c9ac7817f
commit 18d825c6bd

View File

@@ -31,6 +31,8 @@ jobs:
echo "Detected .NET project; restoring/building/testing..." echo "Detected .NET project; restoring/building/testing..."
dotnet restore dotnet restore
dotnet build --no-restore -c Release dotnet build --no-restore -c Release
# Run tests if any project appears to be 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 dotnet test --no-build -c Release --verbosity normal
else else
@@ -44,15 +46,14 @@ jobs:
dotnet sln HelloCI.sln add src/App/App.csproj tests/App.Tests/App.Tests.csproj 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 dotnet add tests/App.Tests/App.Tests.csproj reference src/App/App.csproj
# Keep indentation consistent under `run: |`. YAML strips it; bash sees EOF at col 0. mkdir -p tests/App.Tests
cat > tests/App.Tests/UnitTest1.cs <<'EOF' printf '%s\n' \
using Xunit; 'using Xunit;' \
namespace App.Tests; 'namespace App.Tests;' \
public class UnitTest1 'public class UnitTest1' \
{ '{' \
[Fact] public void Adds() => Assert.Equal(4, 2+2); ' [Fact] public void Adds() => Assert.Equal(4, 2+2);' \
} '}' > tests/App.Tests/UnitTest1.cs
EOF
dotnet restore dotnet restore
dotnet build -c Release dotnet build -c Release