From 0d93cb1d8d819e46bc5cfc7d55d1797086d965d2 Mon Sep 17 00:00:00 2001 From: Benedek Farkas Date: Fri, 6 Dec 2024 09:59:15 +0100 Subject: [PATCH] #8816: Compilation workflow should test the setup and code generation (#8817) * Updating Compile workflow with setup and code generation steps * Updating NHibernate reference and OrchardBasicCorrectness.ruleset path in ModuleTestsCsProj code generation template * Ignoring CS2008 warning when recompiling with generated modules, because the theme and test projects don't have .cs files * Generating a test project should also include packages.config * Fixing the relative path of Orchard.Core and Orchard.Framework in the generated test project * A bit of code styling in the Compile workflow * Updating Readme * Revert "A bit of code styling in the Compile workflow" This reverts commit 7b01ebbad0422d402362b1d08a74b1240a19daa4. --- .github/workflows/compile.yml | 24 ++++++++++++++++- README.md | 26 +++++++------------ .../ModuleTestsCsProj.txt | 10 +++---- .../ModuleTestsPackagesConfig.txt | 7 +++++ .../Commands/CodeGenerationCommands.cs | 16 +++++++----- .../Orchard.CodeGeneration.csproj | 3 ++- 6 files changed, 57 insertions(+), 29 deletions(-) create mode 100644 src/Orchard.Web/Modules/Orchard.CodeGeneration/CodeGenerationTemplates/ModuleTestsPackagesConfig.txt diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index 602548d78..eb46871be 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -26,11 +26,33 @@ jobs: uses: microsoft/setup-msbuild@v2 - name: Compile - run: msbuild Orchard.proj /m /v:minimal /t:Compile /p:MvcBuildViews=true /p:TreatWarningsAsErrors=true -WarnAsError + run: msbuild Orchard.proj /m /v:minimal /t:Compile /p:TreatWarningsAsErrors=true -WarnAsError /p:MvcBuildViews=true - name: Test run: msbuild Orchard.proj /m /v:minimal /t:Test + - name: Run Orchard setup + run: | + $commandFile = 'src/Orchard.Web/bin/setup-commands.txt' + New-Item -Path $commandFile -ItemType File -Force + Set-Content -Path $commandFile -Value 'setup /SiteName:Orchard /AdminUsername:admin /AdminPassword:Password1! /DatabaseProvider:SqlCe /Recipe:Default' + & 'src/Orchard.Web/bin/Orchard.exe' @$commandFile + + - name: Run code generation + run: | + $commandFile = 'src/Orchard.Web/bin/codegen-commands.txt' + New-Item -Path $commandFile -ItemType File -Force + Set-Content -Path $commandFile -Value @' + feature enable Orchard.CodeGeneration + codegen module Orchard.CodeGeneration.TestModule + codegen theme Orchard.CodeGeneration.TestTheme /CreateProject:true + codegen moduletests Orchard.CodeGeneration.TestModule + '@ + & 'src/Orchard.Web/bin/Orchard.exe' @$commandFile + + - name: Compile with generated projects + run: msbuild Orchard.proj /m /v:minimal /t:Compile /p:TreatWarningsAsErrors=true -WarnAsError /NoWarn:CS2008 + compile-node: name: Compile client-side assets defaults: diff --git a/README.md b/README.md index 5a7073d25..19d04cb9e 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,14 @@ # Orchard -Orchard is a free, open source, community-focused Content Management System built on the ASP.NET MVC platform. +Orchard is a free, open source, community-focused Content Management System built on the ASP.NET MVC platform. You are looking at Orchard 1, the older, .NET Framework-based version that has been in development since 2009. -[![Join the chat at https://gitter.im/OrchardCMS/Orchard](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/OrchardCMS/Orchard?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +If you're starting a new project (or maintaining a project built on Orchard 1), you should check out [Orchard Core](https://github.com/OrchardCMS/OrchardCore), the new generation of Orchard built on ASP.NET Core. You can also try it for free on [DotNest.com](https://dotnest.com)! -You can try it for free on [DotNest.com](https://dotnest.com) or on Microsoft Azure by clicking on this button. - -[![Deploy to Azure](https://azuredeploy.net/deploybutton.png)](https://portal.azure.com/#create/OutercurveFoundation.OrchardCMS) +Join the community discussion on [Discord](https://orchardcore.net/discord), where we also have a [channel dedicated to Orchard 1](https://discord.com/channels/551136772243980291/551137194689953848). ## About The Orchard Project -#### Please visit our website at https://orchardproject.net for the most current information about this project. +#### Please visit our website at https://orchardcore.net for the most current information about this project. Orchard is a free, open source, community-focused **Content Management System** built on the ASP.NET MVC platform. @@ -24,12 +22,12 @@ Our mission is to empower our users and foster a dedicated and diverse community Orchard is currently in version **[1.10.3](https://github.com/OrchardCMS/Orchard/releases/tag/1.10.3)**: It contains bugfixes and the more impactful changes and new features added in the latest major version (*1.10*). -We invite participation by the developer community in shaping the project’s direction, so that we can publicly validate our designs and development approach. +We invite participation by the developer community in shaping the project's direction, so that we can publicly validate our designs and development approach. All our releases are available on our [Releases](https://github.com/OrchardCMS/Orchard/releases) page, and we encourage interested developers to check out the source code on the Orchard GitHub site and get involved with the project. * [Download the latest release](https://github.com/OrchardCMS/Orchard/releases) -* [Feature roadmap](https://docs.orchardproject.net/en/latest/Documentation/Feature-roadmap/) -* [Docs and designs/specs](https://docs.orchardproject.net) +* [Feature roadmap](https://docs.orchardcore.net/projects/O1/en/latest/Documentation/Feature-roadmap/) +* [Docs and designs/specs](https://docs.orchardcore.net/projects/O1/en/latest/) ## How To Get Involved @@ -42,11 +40,7 @@ There are many ways you can contribute to Orchard: * [Find and file a bug](https://github.com/OrchardCMS/Orchard/issues) * [Propose a feature idea](https://github.com/OrchardCMS/Orchard/issues/new) * [Ask and answer questions on Stack Overflow](https://stackoverflow.com/questions/tagged/orchardcms) -* [Participate in our gitter.im chatroom](https://gitter.im/OrchardCMS/Orchard) -* [Submit a pull request](https://docs.orchardproject.net/en/latest/Documentation/Contributing-patches/) +* [Join us on Discord](https://orchardcore.net/discord) +* [Submit a pull request](https://docs.orchardcore.net/projects/O1/en/latest/Documentation/Contributing-patches/) * [Translate Orchard](https://crowdin.com/project/orchard-cms) -* [Contribute modules and themes to our gallery](https://gallery.orchardproject.net/) - -## The Future Of Orchard CMS: Orchard Core - -As the underlying frameworks (.NET, ASP.NET and ASP.NET MVC) are constantly evolving, Orchard of course keeps track of the changes and improvements of these: Orchard Core is the next generation of Orchard releases that is based on [ASP.NET Core](https://www.asp.net/core). Just like the current Orchard project, it's fully [open-source and is publicly available on GitHub](https://github.com/OrchardCMS/OrchardCore). Orchard Core (as a framework) is being built from scratch: it's still in development and does not share any of its code base (at least directly) with the current versions (1.x) of Orchard. +* [Contribute modules and themes to our gallery](https://gallery.orchardproject.net) diff --git a/src/Orchard.Web/Modules/Orchard.CodeGeneration/CodeGenerationTemplates/ModuleTestsCsProj.txt b/src/Orchard.Web/Modules/Orchard.CodeGeneration/CodeGenerationTemplates/ModuleTestsCsProj.txt index 8bd755adb..889b3c7fa 100644 --- a/src/Orchard.Web/Modules/Orchard.CodeGeneration/CodeGenerationTemplates/ModuleTestsCsProj.txt +++ b/src/Orchard.Web/Modules/Orchard.CodeGeneration/CodeGenerationTemplates/ModuleTestsCsProj.txt @@ -21,7 +21,7 @@ DEBUG;TRACE prompt 4 - ..\..\..\OrchardBasicCorrectness.ruleset + ..\..\..\..\OrchardBasicCorrectness.ruleset false @@ -35,16 +35,16 @@ false - + ..\..\..\..\packages\Autofac.3.5.2\lib\net40\Autofac.dll ..\..\..\..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll - - ..\..\..\..\packages\NHibernate.4.0.1.4000\lib\net40\NHibernate.dll + + ..\..\..\..\packages\NHibernate.4.1.2.4000\lib\net40\NHibernate.dll - + ..\..\..\..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll diff --git a/src/Orchard.Web/Modules/Orchard.CodeGeneration/CodeGenerationTemplates/ModuleTestsPackagesConfig.txt b/src/Orchard.Web/Modules/Orchard.CodeGeneration/CodeGenerationTemplates/ModuleTestsPackagesConfig.txt new file mode 100644 index 000000000..6b79f20b1 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.CodeGeneration/CodeGenerationTemplates/ModuleTestsPackagesConfig.txt @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.CodeGeneration/Commands/CodeGenerationCommands.cs b/src/Orchard.Web/Modules/Orchard.CodeGeneration/Commands/CodeGenerationCommands.cs index 7f3523094..398617a25 100644 --- a/src/Orchard.Web/Modules/Orchard.CodeGeneration/Commands/CodeGenerationCommands.cs +++ b/src/Orchard.Web/Modules/Orchard.CodeGeneration/Commands/CodeGenerationCommands.cs @@ -161,6 +161,8 @@ namespace Orchard.CodeGeneration.Commands { templateText = templateText.Replace("$$ModuleTypeLibGuid$$", Guid.NewGuid().ToString()); File.WriteAllText(propertiesPath + "\\AssemblyInfo.cs", templateText); content.Add(propertiesPath + "\\AssemblyInfo.cs"); + File.WriteAllText(testsPath + "packages.config", File.ReadAllText(_codeGenTemplatePath + "ModuleTestsPackagesConfig.txt")); + content.Add(testsPath + "packages.config"); var itemGroup = CreateProjectItemGroup(testsPath, content, folders); @@ -168,7 +170,7 @@ namespace Orchard.CodeGeneration.Commands { csprojText = csprojText.Replace("$$ProjectName$$", projectName); csprojText = csprojText.Replace("$$TestsProjectGuid$$", projectGuid); csprojText = csprojText.Replace("$$FileIncludes$$", itemGroup ?? ""); - csprojText = csprojText.Replace("$$OrchardReferences$$", GetOrchardReferences()); + csprojText = csprojText.Replace("$$OrchardReferences$$", GetOrchardReferences(modulesFolderRelativeDepth: 3)); File.WriteAllText(testsPath + projectName + ".csproj", csprojText); @@ -327,15 +329,17 @@ namespace Orchard.CodeGeneration.Commands { return text; } - private static string GetOrchardReferences() { + private static string GetOrchardReferences(int modulesFolderRelativeDepth = 2) { + var frameworkRelativeDepth = string.Join("\\", Enumerable.Repeat("..", modulesFolderRelativeDepth + 1)); + var coreRelativeDepth = string.Join("\\", Enumerable.Repeat("..", modulesFolderRelativeDepth)); return IsSourceEnlistment() ? -@" - {2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6} +$@" + {{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}} Orchard.Framework $(MvcBuildViews) - - {9916839C-39FC-4CEB-A5AF-89CA7E87119F} + + {{9916839C-39FC-4CEB-A5AF-89CA7E87119F}} Orchard.Core $(MvcBuildViews) " : diff --git a/src/Orchard.Web/Modules/Orchard.CodeGeneration/Orchard.CodeGeneration.csproj b/src/Orchard.Web/Modules/Orchard.CodeGeneration/Orchard.CodeGeneration.csproj index 05eb8c41b..6565c15f6 100644 --- a/src/Orchard.Web/Modules/Orchard.CodeGeneration/Orchard.CodeGeneration.csproj +++ b/src/Orchard.Web/Modules/Orchard.CodeGeneration/Orchard.CodeGeneration.csproj @@ -88,6 +88,7 @@ + @@ -158,4 +159,4 @@ - + \ No newline at end of file