Refactored repo organization. Added Jenkinsfile.

This commit is contained in:
Harrison Deng 2022-04-24 00:01:55 -05:00
parent 44e072a723
commit 9cc55e516d
36 changed files with 169 additions and 81 deletions

50
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,50 @@
pipeline {
agent any
stages {
stage("Props.Shop") {
stages {
stage("Restore") {
steps {
dotnetRestore project: "Props.Shop/Props.Shop.sln"
dotnetRestore project: "Props.Shop/Props.Shop.Tests.sln"
}
}
stage("Test") {
steps {
dotnetTest project: "Props.Shop/Props.Shop.Tests.sln"
}
}
stage("Publish") {
steps {
dotnetPublish configuration: 'Release', project: 'Props.Shop/Props.Shop.sln', selfContained: false, unstableIfWarnings: true
}
}
stage("Load") {
steps {
sh "python3 scripts/load_shop_modules.py"
}
}
}
}
stage("Props") {
stages {
stage("Restore") {
steps {
dotnetRestore project: "Props"
dotnetRestore project: "Props.Tests"
}
}
stage("Test") {
steps {
dotnetTest project: "Props.Tests"
}
}
stage("Publish") {
steps {
dotnetPublish configuration: 'Release', project: 'Props', selfContained: false, unstableIfWarnings: true
}
}
}
}
}
}

View File

@ -1,27 +0,0 @@
{
"version": "0.2.0",
"configurations": [
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/test/Props.Shop/Adafruit.Tests/bin/Debug/net6.0/Props.Shop.Adafruit.Tests.dll",
"args": [],
"cwd": "${workspaceFolder}/test/Props.Shop/Adafruit.Tests",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}

View File

@ -1,42 +0,0 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/test/Props.Shop/Adafruit.Tests/Props.Shop.Adafruit.Tests.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/test/Props.Shop/Adafruit.Tests/Props.Shop.Adafruit.Tests.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"${workspaceFolder}/test/Props.Shop/Adafruit.Tests/Props.Shop.Adafruit.Tests.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}
]
}

View File

@ -23,7 +23,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\Props.Shop\Adafruit\Props.Shop.Adafruit.csproj" /> <ProjectReference Include="..\Adafruit\Props.Shop.Adafruit.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30114.105
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Props.Shop.Adafruit.Tests", "Adafruit.Tests\Props.Shop.Adafruit.Tests.csproj", "{DDE31868-2F4E-43D1-9955-E1B4C1BB13A0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DDE31868-2F4E-43D1-9955-E1B4C1BB13A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DDE31868-2F4E-43D1-9955-E1B4C1BB13A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DDE31868-2F4E-43D1-9955-E1B4C1BB13A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DDE31868-2F4E-43D1-9955-E1B4C1BB13A0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

28
Props.Shop/Props.Shop.sln Normal file
View File

@ -0,0 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30114.105
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Props.Shop.Adafruit", "Adafruit\Props.Shop.Adafruit.csproj", "{9C8E4646-C49E-422E-9884-A49D4A05998C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Props.Shop.Framework", "Framework\Props.Shop.Framework.csproj", "{2ED74B8A-F8A7-4DA0-B8E9-AE97207AB20A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9C8E4646-C49E-422E-9884-A49D4A05998C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9C8E4646-C49E-422E-9884-A49D4A05998C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9C8E4646-C49E-422E-9884-A49D4A05998C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9C8E4646-C49E-422E-9884-A49D4A05998C}.Release|Any CPU.Build.0 = Release|Any CPU
{2ED74B8A-F8A7-4DA0-B8E9-AE97207AB20A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2ED74B8A-F8A7-4DA0-B8E9-AE97207AB20A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2ED74B8A-F8A7-4DA0-B8E9-AE97207AB20A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2ED74B8A-F8A7-4DA0-B8E9-AE97207AB20A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>

12
Props.Tests/UnitTest1.cs Normal file
View File

@ -0,0 +1,12 @@
using Xunit;
namespace Props.Tests;
public class UnitTest1
{
[Fact]
public void Test1()
{
}
}

View File

@ -13,6 +13,7 @@
<script src="~/js/site.js" asp-append-version="true"></script> <script src="~/js/site.js" asp-append-version="true"></script>
@if (!string.IsNullOrEmpty((ViewData["Specific"] as string))) @if (!string.IsNullOrEmpty((ViewData["Specific"] as string)))
{ {
@* Adds page specific scripts semi-automatically. *@
<script defer src="@($"~/js/specific/{(ViewData["Specific"])}.js")" asp-append-version="true"></script> <script defer src="@($"~/js/specific/{(ViewData["Specific"])}.js")" asp-append-version="true"></script>
} }
</head> </head>

View File

@ -1,5 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<!-- https://docs.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props for more information. -->
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<UserSecretsId>aspnet-Props-20A2A991-EC61-4C06-91D2-953482026A7B</UserSecretsId> <UserSecretsId>aspnet-Props-20A2A991-EC61-4C06-91D2-953482026A7B</UserSecretsId>
@ -43,7 +43,7 @@
</Exec> </Exec>
<Error Condition="'$(ErrorCode)' != '0'" Text="Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE." /> <Error Condition="'$(ErrorCode)' != '0'" Text="Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE." />
<Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." /> <Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." />
<Exec WorkingDirectory="$(SpaRoot)" Command="npm install" /> <Exec WorkingDirectory="./" Command="npm install" />
</Target> </Target>
<!-- Build static resources --> <!-- Build static resources -->

View File

@ -1,11 +1,10 @@
{ {
"private": true, "private": true,
"main": "js/index.js",
"scripts": { "scripts": {
"build": "webpack --config webpack.prod.js", "build": "webpack --config webpack.prod.js",
"build:dev": "webpack --config webpack.dev.js", "build:dev": "webpack --config webpack.dev.js",
"build:prod": "webpack --config webpack.prod.js", "build:prod": "webpack --config webpack.prod.js",
"postinstall": "python ../scripts/npm_post_install.py" "postinstall": "python3 ../scripts/clear_webpack_cache.py"
}, },
"keywords": [], "keywords": [],
"author": "", "author": "",

View File

@ -10,5 +10,5 @@ def clear():
shutil.rmtree(CACHE_DIR, ignore_errors=True) shutil.rmtree(CACHE_DIR, ignore_errors=True)
if __name__ == "main": if __name__ == "__main__":
clear() clear()

View File

@ -0,0 +1,26 @@
from glob import glob
import os
import shutil
PROP_SHOP_MODULES_DIR = "Props.Shop"
PROPS_SHOP_MODULES_DST = "Props/shops"
NET_VER = "net6.0"
SHOP_MODULE_GLOB = "**/bin/Release/{net_ver}/publish/*.{ext}"
EXTS = ["deps.json", "dll"]
def load():
os.chdir(os.path.dirname(os.path.realpath(__file__)))
os.chdir("..")
os.chdir(PROP_SHOP_MODULES_DIR)
for ext in EXTS:
results = glob(SHOP_MODULE_GLOB.format(net_ver=NET_VER, ext=ext))
for result in results:
shutil.copy(result, PROPS_SHOP_MODULES_DST)
if __name__ == "__main__":
load()

View File

@ -1,3 +0,0 @@
import utils.clear_webpack_cache as clear_webpack_cache
clear_webpack_cache.clear() # Refer to https://webpack.js.org/guides/build-performance/#persistent-cache and https://webpack.js.org/blog/2020-10-10-webpack-5-release/#persistent-caching

View File

@ -1 +0,0 @@