diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..5340728 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,41 @@ +name: CI + +on: + push: + branches: ["dev"] + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: | + 8.0.x + 9.0.x + 10.0.x + + - name: Locate solution + id: sln + run: | + SLN=$(find . \( -name '*.slnx' -o -name '*.sln' \) -not -path '*/bin/*' -not -path '*/obj/*' | head -1) + if [ -z "$SLN" ]; then + SLN=$(find . \( -name '*.csproj' -o -name '*.fsproj' \) -not -path '*/bin/*' -not -path '*/obj/*' | head -1) + fi + echo "Target: $SLN" + echo "path=$SLN" >> "$GITHUB_OUTPUT" + + - name: Build + run: dotnet build "${{ steps.sln.outputs.path }}" -c Release + + - name: Test + run: | + if grep -rlq "Microsoft.NET.Test.Sdk" --include='*.csproj' --include='*.fsproj' .; then + dotnet test "${{ steps.sln.outputs.path }}" -c Release --verbosity normal + else + echo "No test projects found — skipping tests." + fi diff --git a/build/BuildSphere.csproj b/build/BuildSphere.csproj index 4c51569..764af89 100644 --- a/build/BuildSphere.csproj +++ b/build/BuildSphere.csproj @@ -46,6 +46,9 @@ + + + diff --git a/build/INukeBuildSphere.cs b/build/INukeBuildSphere.cs index 5d85a01..034b561 100644 --- a/build/INukeBuildSphere.cs +++ b/build/INukeBuildSphere.cs @@ -3,7 +3,7 @@ public interface INukeBuildSphere : INukeBuild { - [Solution(SuppressBuildProjectCheck = true)] + [Solution] Solution Solution => TryGetValue(() => Solution); diff --git a/build/Tasks/ITestJavaScript.cs b/build/Tasks/ITestJavaScript.cs index d0b4f3f..e4cf87c 100644 --- a/build/Tasks/ITestJavaScript.cs +++ b/build/Tasks/ITestJavaScript.cs @@ -9,10 +9,7 @@ public interface ITestJavaScript : INukeBuildSphere .Executes(() => { Information("Testing JavaScript with Jest..."); - - // Redirect NPM output to Serilog - NpmLogger = (outputType, text) => Log.Information(text); - + // Define the path to the Jest tests directory var jestTestProjects = RootDirectory .GlobDirectories("**/*.JsTests")