-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
144 changed files
with
5,531 additions
and
1,150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ on: | |
branches: | ||
- main | ||
- dev | ||
- remodel | ||
|
||
jobs: | ||
deploy: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/App/NetDaemon.App/Common/ApplicationContexts/AppBaseApplicationContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.