diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..1d5e56c97 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,46 @@ +name: Build + +on: + push: + branches: [ main, master, dev/** ] + pull_request: + branches: [ main, master ] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/master' }} + +jobs: + build: + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + os: [windows-latest, macos-latest] + configuration: [Release] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '6.x' + + - name: Install Mono - macOS + if: matrix.os == 'macos-latest' + run: | + brew install --cask mono-mdk + + - name: Build and pack + run: make prepare build nuget CONFIGURATION=${{ matrix.configuration }} + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: build-artifacts-${{ matrix.os }}-${{ matrix.configuration }} + path: | + bin/Nuget/ + retention-days: 7 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..eaf22a220 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,44 @@ +name: Tests + +on: + push: + branches: [ main, master, dev/** ] + pull_request: + branches: [ main, master ] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/master' }} + +jobs: + test: + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + os: [macos-latest, windows-latest] + configuration: [Release] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '6.x' + + - name: Install Mono - macOS + if: matrix.os == 'macos-latest' + run: | + brew install --cask mono-mdk + + - name: Install Mono - Windows + if: matrix.os == 'windows-latest' + run: | + winget install Mono.Mono --accept-source-agreements --accept-package-agreements + echo "PATH=$env:PATH;C:\Program Files\Mono\bin" >> $env:GITHUB_ENV + + - name: Run tests + run: make prepare all check CONFIGURATION=${{ matrix.configuration }} diff --git a/Makefile b/Makefile index 59360081f..2a1b0ef38 100644 --- a/Makefile +++ b/Makefile @@ -22,13 +22,13 @@ clean: check: build check-monodoc check-mdoc check-mdoc: - cd mdoc; $(MAKE) check -B + $(MAKE) check -B -C mdoc nuget: nuget pack mdoc/mdoc.nuspec -outputdirectory bin/Nuget check-monodoc: - cd monodoc; $(MAKE) check -B + $(MAKE) check -B -C monodoc zip: rm -f $(BIN)/mdoc*.zip diff --git a/external/Test/AttachedEventsAndProperties.dll b/external/Test/AttachedEventsAndProperties.dll new file mode 100644 index 000000000..f0cf25192 Binary files /dev/null and b/external/Test/AttachedEventsAndProperties.dll differ diff --git a/external/Test/DocTest-VB-Eii.dll b/external/Test/DocTest-VB-Eii.dll new file mode 100644 index 000000000..6c307841e Binary files /dev/null and b/external/Test/DocTest-VB-Eii.dll differ diff --git a/external/Test/TestInterfaceImplementation.dll b/external/Test/TestInterfaceImplementation.dll new file mode 100644 index 000000000..58985d4cd Binary files /dev/null and b/external/Test/TestInterfaceImplementation.dll differ diff --git a/external/Test/mdoc.Test.Cplusplus.dll b/external/Test/mdoc.Test.Cplusplus.dll index 88506624a..92d02b2dd 100644 Binary files a/external/Test/mdoc.Test.Cplusplus.dll and b/external/Test/mdoc.Test.Cplusplus.dll differ diff --git a/external/Test/mdoc.Test.FSharp.dll b/external/Test/mdoc.Test.FSharp.dll index e7de8b4a4..df63bca2b 100644 Binary files a/external/Test/mdoc.Test.FSharp.dll and b/external/Test/mdoc.Test.FSharp.dll differ diff --git a/global.json b/global.json new file mode 100644 index 000000000..eaeb84d64 --- /dev/null +++ b/global.json @@ -0,0 +1,5 @@ +{ + "sdk": { + "version": "6.0.428" + } +} \ No newline at end of file diff --git a/mdoc/Makefile b/mdoc/Makefile index ee17bba11..3e1f996aa 100644 --- a/mdoc/Makefile +++ b/mdoc/Makefile @@ -1,6 +1,6 @@ CONFIGURATION = Release PROGRAM = ../bin/$(CONFIGURATION)/mdoc.exe -MONO = mono +MONO = $(if $(filter Windows_NT,$(OS)),,mono) CSCOMPILE = mcs VBCOMPILE = vbnc TEST_CSCFLAGS = -target:library @@ -47,8 +47,8 @@ EXTRA_DISTFILES = \ MULTI-CLASSIC = Test/DocTest-DropNS-classic.dll Test/DocTest-DropNS-classic-multitest.dll MULTI-UNIFIED = Test/DocTest-DropNS-unified.dll Test/DocTest-DropNS-unified-multitest.dll -DIFF = diff -rup -DIFF_QUIET = diff --brief +DIFF = diff -rup $(if $(filter Windows_NT,$(OS)),--strip-trailing-cr,) +DIFF_QUIET = diff --brief $(if $(filter Windows_NT,$(OS)),--strip-trailing-cr,) ifeq ($(ENVIRONMENT),wsl) DIFF = diff -rup -Z @@ -59,11 +59,40 @@ cleanup: -rm -Rf Test/en.actual Test/html.actual nunit: - mono ../packages/NUnit.ConsoleRunner.3.6.0/tools/nunit3-console.exe mdoc.Test/bin/$(CONFIGURATION)/mdoc.Test.dll + $(MONO) ../packages/NUnit.ConsoleRunner.3.6.0/tools/nunit3-console.exe mdoc.Test/bin/$(CONFIGURATION)/mdoc.Test.dll + +ifeq ($(filter Windows_NT,$(OS)),) Test/DocTest-VB-Eii.dll: $(VBCOMPILE) -out:Test/DocTest-VB-Eii.dll Test/ClassEnumerator.vb +../mdoc/mdoc.Test/mdoc.Test.FSharp/bin/Release/mdoc.Test.FSharp.dll: + msbuild ../mdoc/mdoc.Test/mdoc.Test.FSharp/mdoc.Test.FSharp.fsproj -property:Configuration=Release + +Test/TestInterfaceImplementation/bin/Release/TestInterfaceImplementation.dll: + msbuild ../mdoc/Test/TestInterfaceImplementation/TestInterfaceImplementation.csproj -property:Configuration=Release + +Test/AttachedEventsAndProperties/bin/Release/AttachedEventsAndProperties.dll: + msbuild ../mdoc/Test/AttachedEventsAndProperties/AttachedEventsAndProperties.csproj -property:Configuration=Release + +else # Full .NET Framework has extra attributes and slightly different generated types + +Test/DocTest-VB-Eii.dll: + cp ../external/Test/DocTest-VB-Eii.dll Test/DocTest-VB-Eii.dll + +../mdoc/mdoc.Test/mdoc.Test.FSharp/bin/Release/mdoc.Test.FSharp.dll: + cp ../external/Test/mdoc.Test.FSharp.dll ../mdoc/mdoc.Test/mdoc.Test.FSharp/bin/Release/mdoc.Test.FSharp.dll + +Test/TestInterfaceImplementation/bin/Release/TestInterfaceImplementation.dll: + mkdir -p Test/TestInterfaceImplementation/bin/Release/ + cp ../external/Test/TestInterfaceImplementation.dll Test/TestInterfaceImplementation/bin/Release/TestInterfaceImplementation.dll + +Test/AttachedEventsAndProperties/bin/Release/AttachedEventsAndProperties.dll: + mkdir -p Test/AttachedEventsAndProperties/bin/Release/ + cp ../external/Test/AttachedEventsAndProperties.dll Test/AttachedEventsAndProperties/bin/Release/AttachedEventsAndProperties.dll + +endif + Test/DocTest-addNonGeneric.dll: $(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:$@ Test/DocTest-addNonGeneric.cs @@ -174,7 +203,7 @@ Test/DocTest-typeForwards-Third.dll: $(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:Test/DocTest-typeForwards-Third-First.dll /reference:$@ Test/DocTest-typeForwards.cs /define:THIRD Test/DocTest-TypeProjection.dll: - rm -f DocTest-TypeProjection.dll + rm -f $@ $(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:$@ Test/DocTest-TypeProjection.cs # build test dll to test forwardings nested type @@ -183,7 +212,7 @@ Test/DocTest-nestedType-typeForwards-First.dll: $(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:$@ Test/DocTest-nestedType-typeForwards.cs /define:FIRST Test/DocTest-LongFileName.dll: - rm -f DocTest-LongFileName.dll + rm -f $@ $(CSCOMPILE) $(TEST_CSCFLAGS) -unsafe -debug -optimize -target:library -out:$@ Test/DocTest-LongFileName.cs .PHONY: Test/DocTest-nestedType-typeForwards-Second.dll @@ -670,7 +699,7 @@ check-monodocer-fx-statistics-remove: check-monodocer-fsharp: -rm -Rf Test/en.actual - msbuild ../mdoc/mdoc.Test/mdoc.Test.FSharp/mdoc.Test.FSharp.fsproj -property:Configuration=Release + $(MAKE) ../mdoc/mdoc.Test/mdoc.Test.FSharp/bin/Release/mdoc.Test.FSharp.dll $(MONO) $(PROGRAM) update -lang fsharp -o Test/en.actual ../mdoc/mdoc.Test/mdoc.Test.FSharp/bin/Release/mdoc.Test.FSharp.dll ifeq ($(ENVIRONMENT), wsl) @@ -682,7 +711,7 @@ endif check-monodocer-members-implementation: -rm -Rf Test/en.actual - msbuild ../mdoc/Test/TestInterfaceImplementation/TestInterfaceImplementation.csproj -property:Configuration=Release + $(MAKE) Test/TestInterfaceImplementation/bin/Release/TestInterfaceImplementation.dll $(MONO) $(PROGRAM) update -o Test/en.actual Test/TestInterfaceImplementation/bin/Release/TestInterfaceImplementation.dll $(DIFF) Test/en.expected.members-implementation Test/en.actual @@ -768,7 +797,7 @@ check-monodocer-import-fx-update: check-monodocer-import-fx-work check-monodocer-attached-entities: -rm -Rf Test/en.actual - msbuild ../mdoc/Test/AttachedEventsAndProperties/AttachedEventsAndProperties.csproj -property:Configuration=Release + $(MAKE) Test/AttachedEventsAndProperties/bin/Release/AttachedEventsAndProperties.dll $(MONO) $(PROGRAM) update --debug -o Test/en.actual Test/AttachedEventsAndProperties/bin/Release/AttachedEventsAndProperties.dll -lang docid -lang vb.net -lang fsharp -lang javascript -lang c++/cli -lang c++/cx -lang c++/winrt $(DIFF) Test/en.expected-attached-entities Test/en.actual diff --git a/mdoc/mdoc.Test/MDocFileSourceTests.cs b/mdoc/mdoc.Test/MDocFileSourceTests.cs index 31035d35e..414d96966 100644 --- a/mdoc/mdoc.Test/MDocFileSourceTests.cs +++ b/mdoc/mdoc.Test/MDocFileSourceTests.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Runtime.InteropServices; using System.Xml.Linq; using Mono.Documentation; using Mono.Documentation.Framework; @@ -406,7 +407,9 @@ public void GetTypeXmlPath_ShouldReturnCorrectPath_WhenTypeIsDropped() string result = fileSource.GetTypeXmlPath(basePath, nsName, typeName); // Assert - string expectedResult = "basePath/DroppedNamespace.Namespace/TypeName.xml"; + string expectedResult = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) + ? "basePath\\DroppedNamespace.Namespace\\TypeName.xml" + : "basePath/DroppedNamespace.Namespace/TypeName.xml"; Assert.AreEqual(expectedResult, result); } diff --git a/mdoc/mdoc.Test/mdoc.Test.csproj b/mdoc/mdoc.Test/mdoc.Test.csproj index e5ec15d4f..f90ce0a2e 100644 --- a/mdoc/mdoc.Test/mdoc.Test.csproj +++ b/mdoc/mdoc.Test/mdoc.Test.csproj @@ -19,7 +19,7 @@ true - + False ..\..\external\Test\mdoc.Test.Cplusplus.dll diff --git a/monodoc/Makefile b/monodoc/Makefile index 4aeb820d3..61d4fd82f 100644 --- a/monodoc/Makefile +++ b/monodoc/Makefile @@ -1,5 +1,6 @@ CONFIGURATION = Release +MONO = $(if $(filter Windows_NT,$(OS)),,mono) check: - mono ../packages/NUnit.ConsoleRunner.3.6.0/tools/nunit3-console.exe Test/bin/$(CONFIGURATION)/Monodoc.Test.dll + $(MONO) ../packages/NUnit.ConsoleRunner.3.6.0/tools/nunit3-console.exe Test/bin/$(CONFIGURATION)/Monodoc.Test.dll @echo "monodoc Tests Complete!"