diff --git a/.github/workflows/ci_analyze.yml b/.github/workflows/ci_analyze.yml new file mode 100644 index 000000000..05b7bc26d --- /dev/null +++ b/.github/workflows/ci_analyze.yml @@ -0,0 +1,34 @@ +#### Build and tests all pushes, also code coverage +name: 🔍 CI Analyze sources +on: + push: + branches: + - main + - dev +jobs: + sonarscanner: + name: 🔍 SonarScanner + environment: CI - analyze environment + runs-on: ubuntu-latest + steps: + - name: 📤 Checkout the repository + uses: actions/checkout@main + with: + # Shallow clones should be disabled for a better relevancy of analysis + fetch-depth: 0 + + - name: 🔍 Analyze code + uses: highbyte/sonarscan-dotnet@v2.1-beta + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + sonarOrganization: net-daemon + sonarProjectKey: net-daemon_netdaemon + sonarProjectName: netdaemon + dotnetTestArguments: --logger trx /p:CollectCoverage=true /p:CoverletOutputFormat=opencover + sonarBeginArguments: >- + /d:sonar.inclusions="**/src/**" + /d:sonar.test.inclusions="**/tests/**" + /d:sonar.cs.xunit.reportsPaths="**/tests/**/TestResults/*.trx" + /d:sonar.cs.opencover.reportsPaths="**/tests/**/coverage.opencover.xml" diff --git a/.github/workflows/ci_build.yml b/.github/workflows/ci_build.yml index a7b301d39..1250f586f 100644 --- a/.github/workflows/ci_build.yml +++ b/.github/workflows/ci_build.yml @@ -26,7 +26,7 @@ jobs: run: echo "::add-matcher::.github/matchers/dotnet.json" - name: 🛠️ Build code - run: dotnet build + 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 @@ -36,31 +36,10 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} path-to-lcov: ${{github.workspace}}/codecover/lcov.info - - analyze: - name: 🔍 Analyze sources (CI) - environment: CI - analyze environment - runs-on: ubuntu-latest - steps: - - name: 📤 Checkout the repository - uses: actions/checkout@main - with: - # Shallow clones should be disabled for a better relevancy of analysis - fetch-depth: 0 - - - name: 🔍 Analyze code - uses: highbyte/sonarscan-dotnet@v2.1-beta - env: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: 📨 Publish coverage to codecov + uses: codecov/codecov-action@v1 with: - sonarOrganization: net-daemon - sonarProjectKey: net-daemon_netdaemon - sonarProjectName: netdaemon - - dotnetTestArguments: --logger trx /p:CollectCoverage=true /p:CoverletOutputFormat=opencover - sonarBeginArguments: >- - /d:sonar.inclusions="**/src/**" - /d:sonar.test.inclusions="**/tests/**" - /d:sonar.cs.xunit.reportsPaths="**/tests/**/TestResults/*.trx" - /d:sonar.cs.opencover.reportsPaths="**/tests/**/coverage.opencover.xml" + flags: unittests # optional + name: codecov-umbrella # optional + fail_ci_if_error: true # optional (default = false) diff --git a/src/Daemon/NetDaemon.Daemon/Daemon/EntityStateManagement.cs b/src/Daemon/NetDaemon.Daemon/Daemon/EntityStateManagement.cs index 03517f12f..b79e2a78e 100644 --- a/src/Daemon/NetDaemon.Daemon/Daemon/EntityStateManagement.cs +++ b/src/Daemon/NetDaemon.Daemon/Daemon/EntityStateManagement.cs @@ -43,7 +43,7 @@ public async Task RefreshAsync() public void Store(HassState newState) => InternalState[newState.EntityId] = newState; private readonly string[] _supportedDomains = {"binary_sensor", "sensor", "switch"}; - + public async Task SetStateAndWaitForResponseAsync(string entityId, string? state, object? attributes, bool waitForResponse) { diff --git a/tests/NetDaemon.Daemon.Tests/DaemonRunner/Config/ConfigTest.cs b/tests/NetDaemon.Daemon.Tests/DaemonRunner/Config/ConfigTest.cs index 444a7276a..3b8b5c003 100644 --- a/tests/NetDaemon.Daemon.Tests/DaemonRunner/Config/ConfigTest.cs +++ b/tests/NetDaemon.Daemon.Tests/DaemonRunner/Config/ConfigTest.cs @@ -228,7 +228,7 @@ public void YamlScalarNodeToObjectUsingDecimal() Assert.Equal((float) 1.5f, scalarValue.ToObject(typeof(float), null)); Assert.Equal((double) 1.5, scalarValue.ToObject(typeof(double), null)); } - + [Fact] public void YamlScalarNodeToObjectUsingEnum() { @@ -290,7 +290,7 @@ public void YamlAdvancedObjectsShouldReturnCorrectData() Assert.Equal("command2", instance?.Devices?.First()?.Commands?.ElementAt(1).Name); Assert.Equal("some code2", instance?.Devices?.First()?.Commands?.ElementAt(1).Data); } - + [Fact] public void YamlMultilevelObjectShouldReturnCorrectData() { diff --git a/tests/NetDaemon.Daemon.Tests/DaemonRunner/Config/MultilevelMappingConfig.cs b/tests/NetDaemon.Daemon.Tests/DaemonRunner/Config/MultilevelMappingConfig.cs index e9578ea1d..c1fd276c9 100644 --- a/tests/NetDaemon.Daemon.Tests/DaemonRunner/Config/MultilevelMappingConfig.cs +++ b/tests/NetDaemon.Daemon.Tests/DaemonRunner/Config/MultilevelMappingConfig.cs @@ -8,7 +8,7 @@ public class MultilevelMappingConfig : Common.Reactive.NetDaemonRxApp public class Node { public string? Data { get; set; } - + public Node? Child { get; set; } } } \ No newline at end of file