Skip to content

Commit

Permalink
50 reduce binaries size (#51)
Browse files Browse the repository at this point in the history
* Added <PublishTrimmed>true</PublishTrimmed>

* Removed jet test

* Splitted Jet Buil

* trued tó stop the MDAC Depended Assembly from trimming

* more update

* use publish trimmed only for linux target

* JetDatabase: throw NotSupportedException for Linux and Windows 32bit

* Fixed build

* Added tests for LemonTree.Pipeline.Tools.RemovePrerenderedDiagrams

* Added <PublishTrimmed>true</PublishTrimmed>

* Removed jet test

* Splitted Jet Buil

* trued tó stop the MDAC Depended Assembly from trimming

* more update

* use publish trimmed only for linux target

* JetDatabase: throw NotSupportedException for Linux and Windows 32bit

* Fixed build

* Added tests for LemonTree.Pipeline.Tools.RemovePrerenderedDiagrams

* changed publish:
win-x86: - single exe, not self contained
linux-x64 - single-exe, self-contained and trimmed

---------

Co-authored-by: joHerbst72 <144138691+joHerbst72@users.noreply.github.com>
Co-authored-by: Johannes Herbst <johannes.herbst@lieberlieber.com>
  • Loading branch information
3 people authored Sep 11, 2023
1 parent 7755964 commit 7de2859
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 42 deletions.
18 changes: 3 additions & 15 deletions .github/workflows/Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ jobs:
run: msbuild src/LemonTree.Pipeline.Tools.sln /p:Configuration=Release

- name: Publish Solution for Windows
run: dotnet publish -c Release -r win-x86 src/LemonTree.Pipeline.Tools.sln
run: dotnet publish -c Release -r win-x86 --self-contained false src/LemonTree.Pipeline.Tools.sln

- name: Publish Solution for Linux
run: dotnet publish -c Release -r linux-x64 src/LemonTree.Pipeline.Tools.sln
run: dotnet publish -c Release -r linux-x64 --self-contained true -p:PublishTrimmed=true src/LemonTree.Pipeline.Tools.sln

- name: Archive LemonTree.Pipeline.Tools.ModelCheck.Models
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -85,16 +85,4 @@ jobs:
with:
name: LemonTree.Pipeline.Tools.RemovePrerenderedDiagrams.Windows
path: "bin/LemonTree.Pipeline.Tools.RemovePrerenderedDiagrams.exe"
retention-days: 2












retention-days: 2
2 changes: 1 addition & 1 deletion .github/workflows/TestModelCheck.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: test
name: test LemonTree.Pipeline.Tools.ModelCheck

on:
workflow_call:
Expand Down
69 changes: 69 additions & 0 deletions .github/workflows/TestRemovePrerenderedDiagrams.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: test LemonTree.Pipeline.Tools.RemovePrerenderedDiagrams

on:
workflow_call:
inputs:
runs-on:
required: true
type: string
model-path:
required: true
type: string
expected-exitcode:
type: number
default: 0

jobs:
TestRemovePrerenderedDiagramsOnCleanRunner:
runs-on: ${{inputs.runs-on}}
timeout-minutes: 15
steps:

- name: Download LemonTree.Pipeline.Tools.ModelCheck.Models
uses: actions/download-artifact@v3
with:
name: LemonTree.Pipeline.Tools.ModelCheck.Models

- name: Download LemonTree.Pipeline.Tools.RemovePrerenderedDiagrams.Linux
if: runner.os == 'Linux'
uses: actions/download-artifact@v3
with:
name: LemonTree.Pipeline.Tools.RemovePrerenderedDiagrams.Linux

- name: Download LemonTree.Pipeline.Tools.RemovePrerenderedDiagrams.Windows
if: runner.os == 'Windows'
uses: actions/download-artifact@v3
with:
name: LemonTree.Pipeline.Tools.RemovePrerenderedDiagrams.Windows

- name: Run LemonTree.Pipeline.Tools.RemovePrerenderedDiagrams
shell: pwsh
run: |
Write-Output "# Modelcheck of ${{inputs.model-path}} on ${{runner.os}}" >> $env:GITHUB_STEP_SUMMARY
Write-Output "Starting validation"
if ('${{runner.os}}' -eq 'Linux') {
#workaround because github artifacts logic doesn't maintain properties
chmod +x ./LemonTree.Pipeline.Tools.RemovePrerenderedDiagrams
./LemonTree.Pipeline.Tools.RemovePrerenderedDiagrams --model "${{inputs.model-path}}"
}
elseif ('${{runner.os}}' -eq 'Windows') {
./LemonTree.Pipeline.Tools.RemovePrerenderedDiagrams.exe --model "${{inputs.model-path}}"
}
else {
Write-Output "${{runner.os}} is not supported"
Exit -1
}
if (${{inputs.expected-exitcode}} -eq $LASTEXITCODE) {
Write-Output "Finished removing with expected Exitcode: $LASTEXITCODE"
Write-Output "# Finished removing with esxpected Exitcode: $LASTEXITCODE" >> $env:GITHUB_STEP_SUMMARY
exit 0
}
else {
Write-Output "Finished removing with unexpected Exitcode: $LASTEXITCODE"
Write-Output "# Finished removing with unexpected Exitcode: $LASTEXITCODE" >> $env:GITHUB_STEP_SUMMARY
exit -1
}
27 changes: 26 additions & 1 deletion .github/workflows/executetests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,29 @@ jobs:
with:
runs-on: ubuntu-latest
model-path: ./Model.qeax
secrets: inherit
secrets: inherit

call-test-remove-windows-qeax:
# needs: prepare-test
uses: ./.github/workflows/TestRemovePrerenderedDiagrams.yml
with:
runs-on: windows-latest
model-path: ./Model.qeax
secrets: inherit

call-test-remove-windows-eapx:
# needs: prepare-test
uses: ./.github/workflows/TestRemovePrerenderedDiagrams.yml
with:
runs-on: windows-latest
model-path: ./PWC.eapx
secrets: inherit

call-test-workflow-remove-filenotfound:
# needs: prepare-test
uses: ./.github/workflows/TestRemovePrerenderedDiagrams.yml
with:
runs-on: windows-latest
model-path: ./filenotfound.qeax
expected-exitcode: -2
secrets: inherit
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@
<Target Name="PostPublishLinux" AfterTargets="Publish" Condition="'$(RuntimeIdentifier)' == 'linux-x64'">
<Copy SourceFiles="$(PublishDir)LemonTree.Pipeline.Tools.ModelCheck" DestinationFolder="$(SolutionDir)..\bin\" />
</Target>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
<OutputType>Exe</OutputType>
<RestorePackages>true</RestorePackages>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<PublishSingleFile>true</PublishSingleFile>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<OutputPath>bin\x86\Debug\</OutputPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
<OutputType>Exe</OutputType>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<PublishSingleFile>true</PublishSingleFile>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<OutputPath>bin\x86\Debug\</OutputPath>
Expand Down
41 changes: 25 additions & 16 deletions src/LemonTree.Pipeline.Tools/LemonTree.Pipeline.Tools.csproj
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<OutputType>Library</OutputType>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<OutputPath>bin\x86\Debug\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
</PropertyGroup>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<OutputType>Library</OutputType>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<OutputPath>bin\x86\Debug\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<PublishTrimmed>false</PublishTrimmed>
</PropertyGroup>
<PropertyGroup>
<IsTrimmable>false</IsTrimmable>
</PropertyGroup>
<PropertyGroup>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Data.OleDb" Version="7.0.0" />
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.117" />
</ItemGroup>
</ItemGroup>
</Project>
11 changes: 9 additions & 2 deletions src/LemonTree.Pipeline.Tools/ModelAccess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
using System.Data;
using System.IO;
using System.Reflection;

using System.Runtime.InteropServices;

namespace LemonTree.Pipeline.Tools
{
public static class ModelAccess
Expand Down Expand Up @@ -66,7 +67,13 @@ public static DataTable RunSql(string sql)
public static void ConfigureAccess(string model)
{
if (model.EndsWith(".eap") || model.EndsWith(".eapx"))
{
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && RuntimeInformation.ProcessArchitecture == Architecture.X64))
{
// Do something
throw new NotSupportedException($"Model '{Path.GetFileName(model)}' only supported on Windows 32bit.");
}

eaDatabase = new JetDatabase();
eaDatabase.SetModel(model);
}
Expand Down

0 comments on commit 7de2859

Please sign in to comment.