diff --git a/.gitea/workflows/dotnet-test.yml b/.gitea/workflows/dotnet-test.yml index 0c2bd80..f36e7d3 100644 --- a/.gitea/workflows/dotnet-test.yml +++ b/.gitea/workflows/dotnet-test.yml @@ -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 'true' {} + | grep -q .; then + if find . \( -name '*Tests.csproj' -o -name '*.csproj' \) -exec grep -l 'true' {} + | 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