Update .gitea/workflows/dotnet-test.yml
Some checks failed
CI Demo / build (push) Successful in 3s
Go Test / go-test (push) Has been cancelled
Java Test / java-hello (push) Has been cancelled
Julia Test / julia-test (push) Has been cancelled
Docker Test / docker-ops (push) Has been cancelled
Kotlin Test / kotlin-hello (push) Has been cancelled
Node.js Test / nodejs-test (push) Has been cancelled
Notebook Test / nb-test (push) Has been cancelled
Python Test / python-hello (push) Has been cancelled
R Test / r-cmdcheck (push) Has been cancelled
Rust Test / rust-test (push) Has been cancelled
Scala Test / scala-test (push) Has been cancelled
Swift Test / swift-hello (push) Has been cancelled
PHP Test / php-test (push) Successful in 35s
Some checks failed
CI Demo / build (push) Successful in 3s
Go Test / go-test (push) Has been cancelled
Java Test / java-hello (push) Has been cancelled
Julia Test / julia-test (push) Has been cancelled
Docker Test / docker-ops (push) Has been cancelled
Kotlin Test / kotlin-hello (push) Has been cancelled
Node.js Test / nodejs-test (push) Has been cancelled
Notebook Test / nb-test (push) Has been cancelled
Python Test / python-hello (push) Has been cancelled
R Test / r-cmdcheck (push) Has been cancelled
Rust Test / rust-test (push) Has been cancelled
Scala Test / scala-test (push) Has been cancelled
Swift Test / swift-hello (push) Has been cancelled
PHP Test / php-test (push) Successful in 35s
This commit is contained in:
@@ -15,14 +15,16 @@ jobs:
|
||||
- name: Set up .NET
|
||||
uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: '8.0.x' # or '7.0.x' if you prefer
|
||||
dotnet-version: '8.0.x'
|
||||
|
||||
- name: Detect & build/test
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
has_solution=false
|
||||
# Find any .sln or .csproj
|
||||
if find . -maxdepth 2 -name '*.sln' -o -name '*.csproj' | grep -q .; then
|
||||
# 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
|
||||
|
||||
@@ -30,7 +32,7 @@ jobs:
|
||||
echo "Detected .NET project; restoring/building/testing..."
|
||||
dotnet restore
|
||||
dotnet build --no-restore -c Release
|
||||
# Run tests if there are any test projects; otherwise just succeed after build
|
||||
# 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
|
||||
dotnet test --no-build -c Release --verbosity normal
|
||||
else
|
||||
@@ -44,16 +46,17 @@ 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
|
||||
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
|
||||
dotnet test -c Release --no-build --verbosity normal
|
||||
dotnet restore
|
||||
dotnet build -c Release
|
||||
dotnet test -c Release --no-build --verbosity normal
|
||||
fi
|
||||
|
Reference in New Issue
Block a user