Files
Test-Runner/.gitea/workflows/dotnet-test.yml
Workflow config file is invalid. Please check your config file: yaml: line 51: could not find expected ':'
thecoderatekid 5e956ff566
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
Update .gitea/workflows/dotnet-test.yml
2025-08-07 20:25:05 +00:00

63 lines
2.0 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: .NET Test
on: [push]
jobs:
dotnet-test:
runs-on: ubuntu-latest
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Detect & build/test
shell: bash
run: |
set -euo pipefail
has_solution=false
# Group the -name tests so -o doesnt mess with precedence
if find . -maxdepth 2 \( -name '*.sln' -o -name '*.csproj' \) | grep -q .; then
has_solution=true
fi
if $has_solution; then
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
dotnet test --no-build -c Release --verbosity normal
else
echo "No test projects found; build succeeded, skipping tests."
fi
else
echo "No .NET project found; creating a tiny solution for a smoke test."
dotnet new sln -n HelloCI
dotnet new console -o src/App -n App
dotnet new xunit -o tests/App.Tests -n App.Tests
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
dotnet restore
dotnet build -c Release
dotnet test -c Release --no-build --verbosity normal
fi