Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
86847d0
Merge branch 'develop'
EvilBeaver Jun 3, 2020
90e0352
Версия образа из переменной
EvilBeaver Jun 5, 2020
28d5d9d
Create dotnet-core.yml
EvilBeaver Oct 29, 2020
40bbafd
Merge branch 'develop' into GA-script
EvilBeaver Oct 29, 2020
a9a3512
Update dotnet-core.yml
EvilBeaver Oct 29, 2020
47a2a8f
попытка починить ресолв зависимостей
EvilBeaver Oct 29, 2020
eb981eb
Update dotnet-core.yml
EvilBeaver Oct 29, 2020
e0262a9
некорректный путь
EvilBeaver Oct 29, 2020
a0a1e9b
Update dotnet-core.yml
EvilBeaver Oct 29, 2020
160a68a
добавил переменных
EvilBeaver Oct 29, 2020
6ac60bd
Update dotnet-core.yml
EvilBeaver Oct 30, 2020
6a784da
обновлен подмодуль
EvilBeaver Oct 30, 2020
3916d07
Merge branch 'develop' into GA-script
EvilBeaver Oct 30, 2020
d353c25
Черновик сборки netcore
otymko Oct 30, 2020
ebcaf2c
Merge pull request #77 from otymko/patch-1
EvilBeaver Oct 30, 2020
f22fc28
+ workflow для стат анализа
otymko Oct 30, 2020
311f0e1
+ workflow для стат анализа #2
otymko Oct 30, 2020
280b819
+1
otymko Oct 30, 2020
f337092
java для dotnet
otymko Oct 30, 2020
28c1eae
Интеграция с sonarcloud.io
otymko Oct 30, 2020
4191c25
Интеграция с sonarcloud.io +1
otymko Oct 30, 2020
a954e99
Исправлена опечатка в параметре
otymko Oct 30, 2020
a5822b9
Please add the secret GITHUB_TOKEN as an environment variable to your…
otymko Oct 30, 2020
1846ae4
Сбор покрытия кода?
otymko Oct 30, 2020
c6c21c6
Актуализация доработок по GA
otymko Oct 30, 2020
d37922f
Смена названия воркфлоу + события на PR
otymko Oct 30, 2020
cc643c4
Исправлены ошибки запуска на 3.1
EvilBeaver Oct 31, 2020
04eda49
Merge branch 'GA-script' of https://github.com/EvilBeaver/OneScript.W…
EvilBeaver Oct 31, 2020
fea0be4
Update qa.yml
otymko Dec 14, 2020
35d7600
Merge pull request #78 from otymko/GA-script
EvilBeaver Dec 14, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/workflows/dotnet-core.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Build .NET Core

on:
push:
branches:
- master
- develop
- GA-*

env:
MAIN_PROJECT: OneScript/OneScriptWeb.csproj
TEST_PROJECT: OneScriptWeb.Tests/OneScriptWeb.Tests.csproj
SOLUTION: OneScript.sln

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest]
dotnet-version: [3.1.301]
include:
- os: windows-latest
RID: win-x64
target: netcoreapp3.1
- os: ubuntu-latest
RID: linux-x64
target: netcoreapp3.1
defaults:
run:
working-directory: src
steps:

# актуализация с сабмодулями
- uses: actions/checkout@v2
with:
submodules: true

# установка дотнет
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ matrix.dotnet-version }}

# Сборка
- name: Build
run: dotnet build ${{env.MAIN_PROJECT}} -c Release -r ${{matrix.RID}} -f ${{ matrix.target }} -o ../artifact/${{matrix.target}}/${{matrix.RID}}

# Тесты
- name: Test
run: dotnet test ${{env.TEST_PROJECT}} -c Release --runtime=${{matrix.RID}} -f ${{ matrix.target }} --logger="trx;LogFileName=${{matrix.RID}}.trx" --results-directory=testResults

# Заливка в артефакты
- name: Artifact
uses: actions/upload-artifact@v2
with:
name: oscript.web-${{matrix.RID}}.zip
path: ./artifact/${{matrix.target}}/${{matrix.RID}}
70 changes: 70 additions & 0 deletions .github/workflows/qa.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Continuous Code Quality

on:
push:
branches:
- master
- develop
# для отладки, нужно после убрать
- GA-*
pull_request:
types: [opened, synchronize, reopened]

env:
MAIN_PROJECT: OneScript/OneScriptWeb.csproj
TEST_PROJECT: OneScriptWeb.Tests/OneScriptWeb.Tests.csproj
SOLUTION: OneScript.sln

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest]
dotnet-version: [3.1.301]
include:
- os: windows-latest
RID: win-x64
target: netcoreapp3.1
defaults:
run:
working-directory: src
steps:

# актуализация с сабмодулями
- uses: actions/checkout@v2
with:
submodules: true

# установка дотнет
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ matrix.dotnet-version }}

# Установка SonarScanner
- run: dotnet tool install --global dotnet-sonarscanner --version 4.10.0

# Java для dotnet
- name: Setup java
uses: actions/setup-java@v1
with:
java-version: 11

# Старт SonarScanner
- run: dotnet sonarscanner begin /k:"1script-web" /d:sonar.login=${{ env.SONAR_TOKEN }} /d:sonar.host.url=${{ env.SONAR_HOST }}
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST: ${{ secrets.SONAR_HOST }}

# Сборка
- name: Build
run: |
dotnet build ${{env.MAIN_PROJECT}} -c Release -r ${{matrix.RID}} -f ${{ matrix.target }}

# Завершение SonarScanner
- run: dotnet sonarscanner end /d:sonar.login=${{ env.SONAR_TOKEN }}
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}
6 changes: 3 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
pipeline {

agent none

environment {
ReleaseNumber = '0.7.0'
}

stages {

stage('Build and test'){
Expand Down Expand Up @@ -100,8 +100,8 @@ pipeline {
unstash 'buildResults'

withCredentials([usernamePassword(credentialsId: 'docker-hub', passwordVariable: 'dockerpassword', usernameVariable: 'dockeruser')]) {
sh 'docker build -t evilbeaver/oscript-web:0.7.0 --file Dockerfile src'
sh 'docker login -p $dockerpassword -u $dockeruser && docker push evilbeaver/oscript-web:0.7.0'
sh "docker build -t evilbeaver/oscript-web:${ReleaseNumber} --file Dockerfile src"
sh "docker login -p $dockerpassword -u $dockeruser && docker push evilbeaver/oscript-web:${ReleaseNumber}"
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/OneScript.sln
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,23 @@ Global
{59C56111-1C71-475C-8BE9-1173C9E7B7E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{59C56111-1C71-475C-8BE9-1173C9E7B7E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{59C56111-1C71-475C-8BE9-1173C9E7B7E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{59C56111-1C71-475C-8BE9-1173C9E7B7E0}.Release|Any CPU.Build.0 = Release|Any CPU
{E0753066-45FE-4A74-9E25-D1D0A6EE1162}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E0753066-45FE-4A74-9E25-D1D0A6EE1162}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E0753066-45FE-4A74-9E25-D1D0A6EE1162}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E0753066-45FE-4A74-9E25-D1D0A6EE1162}.Release|Any CPU.Build.0 = Release|Any CPU
{778596E5-05C4-4775-A88B-34B3B48B56BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{778596E5-05C4-4775-A88B-34B3B48B56BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{778596E5-05C4-4775-A88B-34B3B48B56BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{778596E5-05C4-4775-A88B-34B3B48B56BA}.Release|Any CPU.Build.0 = Release|Any CPU
{272DC28D-54B6-4D4D-9970-D3BA324DBECF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{272DC28D-54B6-4D4D-9970-D3BA324DBECF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{272DC28D-54B6-4D4D-9970-D3BA324DBECF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{272DC28D-54B6-4D4D-9970-D3BA324DBECF}.Release|Any CPU.Build.0 = Release|Any CPU
{E8530889-A741-4A5E-B606-6C25FE4B8EA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E8530889-A741-4A5E-B606-6C25FE4B8EA4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E8530889-A741-4A5E-B606-6C25FE4B8EA4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E8530889-A741-4A5E-B606-6C25FE4B8EA4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
16 changes: 10 additions & 6 deletions src/OneScript/Application/ApplicationInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,15 @@ public void UseStaticFiles()
[ContextMethod("ИспользоватьМаршруты")]
public void UseMvcRoutes(string handler = null)
{
if (handler == null)
_startupBuilder.UseMvcWithDefaultRoute();
_startupBuilder.UseRouting();
if (handler == default)
{
_startupBuilder.UseEndpoints(x => x.MapDefaultControllerRoute());
}
else
{
CallRoutesRegistrationHandler(handler);
}
}

/// <summary>
Expand Down Expand Up @@ -221,14 +226,13 @@ private void CallRoutesRegistrationHandler(string handler)
var handlerIndex = GetScriptMethod(handler);

var routesCol = new RoutesCollectionContext();

CallScriptMethod(handlerIndex, new IValue[]{routesCol});

_startupBuilder.UseMvc(routes =>
_startupBuilder.UseEndpoints(routes =>
{
foreach (var route in routesCol)
{
routes.MapRoute(route.Name, route.Template, route.Defaults?.Select(x=>
routes.MapControllerRoute(route.Name, route.Template, route.Defaults?.Select(x=>
{
var kv = new KeyValuePair<string,object>(x.Key.AsString(),ContextValuesMarshaller.ConvertToCLRObject(x.Value));
return kv;
Expand Down Expand Up @@ -260,7 +264,7 @@ public static ApplicationInstance Create(ICodeSource src, IApplicationRuntime we
var bc = compiler.Compile(src);
var app = new ApplicationInstance(new LoadedModule(bc));
var machine = MachineInstance.Current;
webApp.Environment.LoadMemory(machine);
machine.PrepareThread(webApp.Environment);
webApp.Engine.InitializeSDO(app);

return app;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private void AppendScriptedHandlers(IApplicationRuntime runtime, IFileProvider f
if(!authFile.Exists || authFile.IsDirectory)
return;

runtime.Environment.LoadMemory(MachineInstance.Current);
MachineInstance.Current.PrepareThread(runtime.Environment);
var codeSource = new FileInfoCodeSource(authFile);

runtime.DebugCurrentThread();
Expand Down
4 changes: 2 additions & 2 deletions src/OneScript/BackgroundJobs/BackgroundJobsManagerContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This Source Code Form is subject to the terms of the
----------------------------------------------------------*/
using System;
using Hangfire;
using OneScript.WebHost.Infrastructure;
using ScriptEngine;
using ScriptEngine.Machine;
using ScriptEngine.Machine.Contexts;
Expand Down Expand Up @@ -51,8 +52,7 @@ public void WaitForCompletion()
// должен быть public, т.к. hangfire не умеет вызывать private
public static void PerformAction(string module, string method)
{
var machine = MachineInstance.Current;
_globalEnv.LoadMemory(machine);
MachineInstance.Current.PrepareThread(_globalEnv);

var scriptObject = (IRuntimeContextInstance)_globalEnv.GetGlobalProperty(module);
var methodId = scriptObject.FindMethod(method);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void RunContinuationsTask(string TaskIDFrom, string module, string method

public static void PerformAction(string module, string method)
{
_globalEnv.LoadMemory(MachineInstance.Current);
MachineInstance.Current.PrepareThread(_globalEnv);

ApplicationDbContext dbContext = null;
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void OnProvidersExecuting(ApplicationModelProviderContext context)
private void FillContext(IEnumerable<IFileInfo> sources, ApplicationModelProviderContext context)
{
var reflector = new TypeReflectionEngine();
_fw.Environment.LoadMemory(MachineInstance.Current);
MachineInstance.Current.PrepareThread(_fw.Environment);
foreach (var virtualPath in sources)
{
LoadedModule module;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public object Create(ControllerContext context)
var module = info.Module;
var instance = new ScriptedController(context, module);
var machine = MachineInstance.Current;
engine.Environment.LoadMemory(machine);
machine.PrepareThread(engine.Environment);

_runtime.DebugCurrentThread();
engine.InitializeSDO(instance);
return instance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public async Task InvokeAsync(HttpContext context)
var engine = _runtime.Engine;
var instance = new ScriptedMiddleware(_next, _module);
var machine = MachineInstance.Current;
engine.Environment.LoadMemory(machine);
machine.PrepareThread(engine.Environment);
try
{
_runtime.DebugCurrentThread();
Expand Down
21 changes: 21 additions & 0 deletions src/OneScript/Infrastructure/RuntimeExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*----------------------------------------------------------
This Source Code Form is subject to the terms of the
Mozilla Public License, v.2.0. If a copy of the MPL
was not distributed with this file, You can obtain one
at http://mozilla.org/MPL/2.0/.
----------------------------------------------------------*/

using ScriptEngine;
using ScriptEngine.Machine;

namespace OneScript.WebHost.Infrastructure
{
public static class RuntimeExtensions
{
public static void PrepareThread(this MachineInstance machine, RuntimeEnvironment env)
{
if (!machine.IsRunning)
env.LoadMemory(machine);
}
}
}
10 changes: 9 additions & 1 deletion src/OneScript/OneScriptWeb.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
<Copyright>Copyright (c) 2018 EvilBeaver</Copyright>
<Configurations>Debug;Release</Configurations>
<Platforms>AnyCPU</Platforms>


<!-- SonarQube needs this -->
<ProjectGuid>{E2CEBBAF-6DF7-41E9-815D-9AD4CF90C844}</ProjectGuid>

</PropertyGroup>

Expand All @@ -29,6 +33,8 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
<DocumentationFile>bin\Release\$(TargetFramework)\OneScript.WebHost.xml</DocumentationFile>
<DebugSymbols>false</DebugSymbols>
<WarningLevel>2</WarningLevel>
</PropertyGroup>
<ItemGroup>
<None Remove="oscript_modules\package-loader.os" />
Expand All @@ -48,14 +54,16 @@
<PackageReference Include="Microsoft.AspNetCore.Hosting.WindowsServices" Version="3.1.9" />

<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.9" />

<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="3.1.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="3.1.6" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.9" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.4" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.2.3" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.4" ExcludeAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.4" ExcludeAssets="All" />

</ItemGroup>
<ItemGroup>
Expand Down
8 changes: 5 additions & 3 deletions src/OneScript/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ public void ConfigureServices(IServiceCollection services)
//TODO подумать как вывести данную конструкцию в конфигурацю доступную для разработчика 1С
services.AddAntiforgery(options => options.Cookie.Name = "OScriptWeb.Antiforgery");

services.AddMvc()
services.AddControllersWithViews(mvcopts => mvcopts.EnableEndpointRouting = false)
.AddRazorRuntimeCompilation()
.ConfigureApplicationPartManager(pm=>pm.FeatureProviders.Add(new ScriptedViewComponentFeatureProvider()));

services.AddOneScript();
services.AddOneScriptDebug(Configuration);
}
Expand Down Expand Up @@ -106,8 +106,10 @@ private static void StartOneScriptApp(IApplicationBuilder app, IServiceProvider
try
{
var oscriptApp = services.GetService<ApplicationInstance>();

MachineInstance.Current.PrepareThread(appRuntime.Environment);

appRuntime.Engine.DebugController = services.GetService<IDebugController>();

if (appRuntime.DebugEnabled())
{
var logger = services.GetService<ILogger<Startup>>();
Expand Down