From 0e2655e303865587fa1ed525b6951e26ce77ad97 Mon Sep 17 00:00:00 2001 From: helto4real Date: Mon, 5 Jul 2021 21:58:42 +0200 Subject: [PATCH 1/4] anaysis on push to dev and main and codecov --- .github/workflows/ci_analyze.yml | 34 ++++++++++++++++++++++++++++++++ .github/workflows/ci_build.yml | 33 ++++++------------------------- 2 files changed, 40 insertions(+), 27 deletions(-) create mode 100644 .github/workflows/ci_analyze.yml diff --git a/.github/workflows/ci_analyze.yml b/.github/workflows/ci_analyze.yml new file mode 100644 index 000000000..bb0d7aae0 --- /dev/null +++ b/.github/workflows/ci_analyze.yml @@ -0,0 +1,34 @@ +#### Build and tests all pushes, also code coverage +name: 🛠️ CI build check +on: + push: + branches: + - main + - dev +jobs: + 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 }} + 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..c1d4594eb 100644 --- a/.github/workflows/ci_build.yml +++ b/.github/workflows/ci_build.yml @@ -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) From a41b2222ac2eea64ff980580a518422d853adcd5 Mon Sep 17 00:00:00 2001 From: helto4real Date: Mon, 5 Jul 2021 21:58:59 +0200 Subject: [PATCH 2/4] cleanup --- src/Daemon/NetDaemon.Daemon/Daemon/EntityStateManagement.cs | 2 +- .../NetDaemon.Daemon.Tests/DaemonRunner/Config/ConfigTest.cs | 4 ++-- .../DaemonRunner/Config/MultilevelMappingConfig.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) 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 From 2d36a13167cc995f7c5f91c1fd09cb4323e5bf61 Mon Sep 17 00:00:00 2001 From: helto4real Date: Mon, 5 Jul 2021 21:59:55 +0200 Subject: [PATCH 3/4] add warn as error in build --- .github/workflows/ci_build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_build.yml b/.github/workflows/ci_build.yml index c1d4594eb..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 From e4bfa4b1f4650d03f5eadff3b3b2d689eda4c186 Mon Sep 17 00:00:00 2001 From: helto4real Date: Mon, 5 Jul 2021 22:28:01 +0200 Subject: [PATCH 4/4] cleanup after review --- .github/workflows/ci_analyze.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci_analyze.yml b/.github/workflows/ci_analyze.yml index bb0d7aae0..05b7bc26d 100644 --- a/.github/workflows/ci_analyze.yml +++ b/.github/workflows/ci_analyze.yml @@ -1,13 +1,13 @@ #### Build and tests all pushes, also code coverage -name: 🛠️ CI build check +name: 🔍 CI Analyze sources on: push: branches: - main - dev jobs: - analyze: - name: 🔍 Analyze sources (CI) + sonarscanner: + name: 🔍 SonarScanner environment: CI - analyze environment runs-on: ubuntu-latest steps: @@ -16,6 +16,7 @@ jobs: 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: @@ -25,9 +26,8 @@ jobs: sonarOrganization: net-daemon sonarProjectKey: net-daemon_netdaemon sonarProjectName: netdaemon - dotnetTestArguments: --logger trx /p:CollectCoverage=true /p:CoverletOutputFormat=opencover - sonarBeginArguments: >- + sonarBeginArguments: >- /d:sonar.inclusions="**/src/**" /d:sonar.test.inclusions="**/tests/**" /d:sonar.cs.xunit.reportsPaths="**/tests/**/TestResults/*.trx"