Skip to content

Commit

Permalink
Merge 77ffdda into 4275efc
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankBakkerNl committed Oct 24, 2021
2 parents 4275efc + 77ffdda commit d308090
Show file tree
Hide file tree
Showing 144 changed files with 5,531 additions and 1,150 deletions.
60 changes: 32 additions & 28 deletions .github/workflows/ci_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,40 @@ on:
- main
- dev
jobs:
build:
name: 🔨 Build sources (CI)
runs-on: ubuntu-latest
steps:
- name: 📤 Checkout the repository
uses: actions/checkout@main
build:
name: 🔨 Build sources (CI)
runs-on: ubuntu-latest
steps:
- name: 📤 Checkout the repository
uses: actions/checkout@main

- name: 🥅 Install .Net 5
uses: actions/setup-dotnet@v1
with:
dotnet-version: '5.0.x' # SDK Version
- name: 🥅 Install .Net 5
uses: actions/setup-dotnet@v1
with:
dotnet-version: "5.0.x" # SDK Version

- name: 🔍 Enable problem matchers
run: echo "::add-matcher::.github/matchers/dotnet.json"
- name: 🔍 Enable problem matchers
run: echo "::add-matcher::.github/matchers/dotnet.json"

- name: 🛠️ Build code
run: dotnet build /warnaserror
- name: 🛠️ Build code
run: dotnet build /warnaserror

- name: 👀 Test code
run: dotnet test -v minimal /p:CollectCoverage=true /p:CoverletOutputFormat=lcov /p:CoverletOutput=${{github.workspace}}/codecover/lcov.info
- name: 👀 Test V2
run: dotnet test tests/NetDaemon.Daemon.Tests -v minimal /p:CollectCoverage=true /p:CoverletOutputFormat={json,lcov} /p:CoverletOutput=${{github.workspace}}/codecover

- name: 📨 Publish coverage report to coveralls.io
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ${{github.workspace}}/codecover/lcov.info

- name: 📨 Publish coverage to codecov
uses: codecov/codecov-action@v1
with:
flags: unittests # optional
name: codecov-umbrella # optional
fail_ci_if_error: true # optional (default = false)
- name: 👀 Test V3
run: dotnet test src/HassModel/NetDaemon.HassModel.Tests -v minimal /p:CollectCoverage=true /p:CoverletOutputFormat={json,lcov} /p:MergeWith=${{github.workspace}}/codecover.json /p:CoverletOutput=${{github.workspace}}/codecover_merged

- name: 📨 Publish coverage report to coveralls.io
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ${{github.workspace}}/codecover_merged.info

- name: 📨 Publish coverage to codecov
uses: codecov/codecov-action@v1
with:
flags: unittests # optional
name: codecov-umbrella # optional
files: ${{github.workspace}}/codecover_merged.info
fail_ci_if_error: true # optional (default = false)
47 changes: 47 additions & 0 deletions .github/workflows/ci_build_remodel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#### Build and tests all pushes, also code coverage
name: 🛠️ CI build check
on:
push:
branches:
- remodel
pull_request:
branches:
- remodel
jobs:
build:
name: 🔨 Build sources (CI) remodel branch
runs-on: ubuntu-latest
steps:
- name: 📤 Checkout the repository
uses: actions/checkout@main

- name: 🥅 Install .Net 5
uses: actions/setup-dotnet@v1
with:
dotnet-version: "5.0.x" # SDK Version

- name: 🔍 Enable problem matchers
run: echo "::add-matcher::.github/matchers/dotnet.json"

- name: 🛠️ Build code
run: dotnet build /warnaserror

- name: 👀 Test V2
run: dotnet test tests/NetDaemon.Daemon.Tests -v minimal /p:CollectCoverage=true /p:CoverletOutputFormat={json,lcov} /p:CoverletOutput=${{github.workspace}}/codecover

- name: 👀 Test V3
run: dotnet test src/HassModel/NetDaemon.HassModel.Tests -v minimal /p:CollectCoverage=true /p:CoverletOutputFormat={json,lcov} /p:MergeWith=${{github.workspace}}/codecover.json /p:CoverletOutput=${{github.workspace}}/codecover_merged

- name: 📨 Publish coverage report to coveralls.io
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ${{github.workspace}}/codecover_merged.info

- name: 📨 Publish coverage to codecov
uses: codecov/codecov-action@v1
with:
flags: unittests # optional
name: codecov-umbrella # optional
files: ${{github.workspace}}/codecover_merged.info
fail_ci_if_error: true # optional (default = false)
42 changes: 42 additions & 0 deletions .github/workflows/push_docker_remodel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#### Publish tags to docker hub
name: 📦 Deploy dev docker
on:
push:
branches:
- remodel

jobs:
deploy:
name: 📦 Deploy to Docker V3 branch
runs-on: ubuntu-latest
environment: CI - release environment
steps:
- name: 📤 Checkout the repository
uses: actions/checkout@main
- name: 📆 Set version number
run: |
sed -i '/ private const string Version = /c\ private const string Version = "v3 experimental build";' ${{github.workspace}}/src/DaemonRunner/DaemonRunner/Service/RunnerService.cs
sed -i '/ io.hass.version=/c\ io.hass.version="v3" \\' ${{github.workspace}}/Dockerfile
-
name: 📎 Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: 🔧 Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
-
name: 🧰 Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}

- name: 🔓 Login to docker hub
run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_TOKEN }}

- name: 🛠️ Run Buildx
run: |
docker buildx build \
--platform linux/arm,linux/arm64,linux/amd64 \
--output "type=image,push=true" \
--no-cache \
--file ./Dockerfile . \
--compress \
--tag netdaemon/netdaemon:model3
1 change: 1 addition & 0 deletions .github/workflows/test_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- main
- dev
- remodel

jobs:
deploy:
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ scripts/version.txt

# Coverage files
lcov.info
codecover.json
code_cover.json
codecover
codecover.info
codecover_merged.json
codecover_merged.info

### VisualStudioCode ###
# Setting files
Expand Down
47 changes: 47 additions & 0 deletions NetDaemon.sln
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Integration", "Integration"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestClient", "tests\Integration\TestClient\TestClient.csproj", "{CEF690C5-DF76-465D-B571-FBBC85C7F7BB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetDaemon.HassModel", "src\HassModel\NetDeamon.HassModel\NetDaemon.HassModel.csproj", "{3C2E37A3-4669-4CF5-9D6C-D68FD2034642}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "HassModel", "HassModel", "{1D0125A6-DDC5-43C1-AAD7-7BFE14AD863F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetDaemon.HassModel.Tests", "src\HassModel\NetDaemon.HassModel.Tests\NetDaemon.HassModel.Tests.csproj", "{ED06E300-F256-4BD9-B2FF-BBA0FF8C2461}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetDaemon.HassModel.CodeGenerator", "src\HassModel\NetDaemon.HassModel.CodeGenerator\NetDaemon.HassModel.CodeGenerator.csproj", "{A2F2FDA3-A0E9-4D55-B31A-6C7BBD1800C3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -142,6 +150,42 @@ Global
{CEF690C5-DF76-465D-B571-FBBC85C7F7BB}.Release|x64.Build.0 = Release|Any CPU
{CEF690C5-DF76-465D-B571-FBBC85C7F7BB}.Release|x86.ActiveCfg = Release|Any CPU
{CEF690C5-DF76-465D-B571-FBBC85C7F7BB}.Release|x86.Build.0 = Release|Any CPU
{3C2E37A3-4669-4CF5-9D6C-D68FD2034642}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3C2E37A3-4669-4CF5-9D6C-D68FD2034642}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3C2E37A3-4669-4CF5-9D6C-D68FD2034642}.Debug|x64.ActiveCfg = Debug|Any CPU
{3C2E37A3-4669-4CF5-9D6C-D68FD2034642}.Debug|x64.Build.0 = Debug|Any CPU
{3C2E37A3-4669-4CF5-9D6C-D68FD2034642}.Debug|x86.ActiveCfg = Debug|Any CPU
{3C2E37A3-4669-4CF5-9D6C-D68FD2034642}.Debug|x86.Build.0 = Debug|Any CPU
{3C2E37A3-4669-4CF5-9D6C-D68FD2034642}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3C2E37A3-4669-4CF5-9D6C-D68FD2034642}.Release|Any CPU.Build.0 = Release|Any CPU
{3C2E37A3-4669-4CF5-9D6C-D68FD2034642}.Release|x64.ActiveCfg = Release|Any CPU
{3C2E37A3-4669-4CF5-9D6C-D68FD2034642}.Release|x64.Build.0 = Release|Any CPU
{3C2E37A3-4669-4CF5-9D6C-D68FD2034642}.Release|x86.ActiveCfg = Release|Any CPU
{3C2E37A3-4669-4CF5-9D6C-D68FD2034642}.Release|x86.Build.0 = Release|Any CPU
{ED06E300-F256-4BD9-B2FF-BBA0FF8C2461}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ED06E300-F256-4BD9-B2FF-BBA0FF8C2461}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ED06E300-F256-4BD9-B2FF-BBA0FF8C2461}.Debug|x64.ActiveCfg = Debug|Any CPU
{ED06E300-F256-4BD9-B2FF-BBA0FF8C2461}.Debug|x64.Build.0 = Debug|Any CPU
{ED06E300-F256-4BD9-B2FF-BBA0FF8C2461}.Debug|x86.ActiveCfg = Debug|Any CPU
{ED06E300-F256-4BD9-B2FF-BBA0FF8C2461}.Debug|x86.Build.0 = Debug|Any CPU
{ED06E300-F256-4BD9-B2FF-BBA0FF8C2461}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ED06E300-F256-4BD9-B2FF-BBA0FF8C2461}.Release|Any CPU.Build.0 = Release|Any CPU
{ED06E300-F256-4BD9-B2FF-BBA0FF8C2461}.Release|x64.ActiveCfg = Release|Any CPU
{ED06E300-F256-4BD9-B2FF-BBA0FF8C2461}.Release|x64.Build.0 = Release|Any CPU
{ED06E300-F256-4BD9-B2FF-BBA0FF8C2461}.Release|x86.ActiveCfg = Release|Any CPU
{ED06E300-F256-4BD9-B2FF-BBA0FF8C2461}.Release|x86.Build.0 = Release|Any CPU
{A2F2FDA3-A0E9-4D55-B31A-6C7BBD1800C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A2F2FDA3-A0E9-4D55-B31A-6C7BBD1800C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A2F2FDA3-A0E9-4D55-B31A-6C7BBD1800C3}.Debug|x64.ActiveCfg = Debug|Any CPU
{A2F2FDA3-A0E9-4D55-B31A-6C7BBD1800C3}.Debug|x64.Build.0 = Debug|Any CPU
{A2F2FDA3-A0E9-4D55-B31A-6C7BBD1800C3}.Debug|x86.ActiveCfg = Debug|Any CPU
{A2F2FDA3-A0E9-4D55-B31A-6C7BBD1800C3}.Debug|x86.Build.0 = Debug|Any CPU
{A2F2FDA3-A0E9-4D55-B31A-6C7BBD1800C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A2F2FDA3-A0E9-4D55-B31A-6C7BBD1800C3}.Release|Any CPU.Build.0 = Release|Any CPU
{A2F2FDA3-A0E9-4D55-B31A-6C7BBD1800C3}.Release|x64.ActiveCfg = Release|Any CPU
{A2F2FDA3-A0E9-4D55-B31A-6C7BBD1800C3}.Release|x64.Build.0 = Release|Any CPU
{A2F2FDA3-A0E9-4D55-B31A-6C7BBD1800C3}.Release|x86.ActiveCfg = Release|Any CPU
{A2F2FDA3-A0E9-4D55-B31A-6C7BBD1800C3}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -156,6 +200,9 @@ Global
{E33F4CFC-7D80-48C4-B5FE-107E36CD98E4} = {CD3259F6-4CD3-49AA-90D3-3CFEEE0BFF0E}
{374E37D9-68D9-4A65-ACBC-C6DC2A7C3076} = {32E20E48-2F62-447B-83A2-DB2EA7F61AB3}
{CEF690C5-DF76-465D-B571-FBBC85C7F7BB} = {374E37D9-68D9-4A65-ACBC-C6DC2A7C3076}
{3C2E37A3-4669-4CF5-9D6C-D68FD2034642} = {1D0125A6-DDC5-43C1-AAD7-7BFE14AD863F}
{ED06E300-F256-4BD9-B2FF-BBA0FF8C2461} = {1D0125A6-DDC5-43C1-AAD7-7BFE14AD863F}
{A2F2FDA3-A0E9-4D55-B31A-6C7BBD1800C3} = {1D0125A6-DDC5-43C1-AAD7-7BFE14AD863F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7C5FBB7F-654C-4CAC-964F-6D71AF3D62F8}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;

namespace NetDaemon.Common
{
/// <summary>
/// Application Context implementation for apps derived from INetDaemonAppBase
/// </summary>
class AppBaseApplicationContext : ApplicationContext
{
private readonly INetDaemonAppBase _appInstance;

public AppBaseApplicationContext(Type applicationType, string id, IServiceProvider serviceProvider)
: base(applicationType, id, serviceProvider)
{
_appInstance = (INetDaemonAppBase)ActivatorUtilities.GetServiceOrCreateInstance(ServiceProvider, applicationType);

if (_appInstance is NetDaemonAppBase appBase)
{
appBase.ServiceProvider = ServiceProvider;
}
ApplicationInstance = _appInstance;
Id = id;
}

/// <summary>
/// Constructor from an already instantiated app (used for unit testing)
/// </summary>
/// <param name="appInstance"></param>
/// <param name="serviceProvider"></param>
public AppBaseApplicationContext(INetDaemonAppBase appInstance, IServiceProvider serviceProvider)
: base(appInstance.GetType(), appInstance.Id!, serviceProvider)
{
_appInstance = appInstance;

if (appInstance is NetDaemonAppBase appBase)
{
appBase.ServiceProvider = ServiceProvider;
}
ApplicationInstance = appInstance;
}

public override void SetConfigProvider(Action configProvider)
{
configProvider();
}

public override async Task RestoreStateAsync()
{
await _appInstance.StartUpAsync(ServiceProvider.GetRequiredService<INetDaemon>()).ConfigureAwait(false);
await _appInstance.RestoreAppStateAsync().ConfigureAwait(false);
if (!_appInstance.IsEnabled)
{
await _appInstance.DisposeAsync().ConfigureAwait(false);
}
}

public override void Start()
{
// Do nothing, already instantiated
}

public override string? Description => _appInstance.Description;

public override bool IsEnabled
{
get => _appInstance.IsEnabled;
set => _appInstance.IsEnabled = value;
}

public override AppRuntimeInfo RuntimeInfo => _appInstance.RuntimeInfo;
}
}
Loading

0 comments on commit d308090

Please sign in to comment.