From a0ba1bc28684b6410a468f8b38d004c293193eac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rasmus=20B=C3=A6kgaard?= Date: Sun, 29 Dec 2024 14:17:12 +0100 Subject: [PATCH 1/2] Update a few GitHub actions' versions, and add dependabot to check for latest version of GitHub actions --- .github/dependabot.yml | 32 ++++++++++++------- .github/workflows/ci_build.yml | 5 +-- .../workflows/push_docker_addon_manual.yml | 10 ++++-- .github/workflows/push_docker_manual.yml | 21 +++++++++--- .github/workflows/push_docker_prerelease.yml | 20 +++++++++--- .github/workflows/push_nuget_prerelease.yml | 6 +++- .github/workflows/release_drafter.yml | 2 +- .github/workflows/tags_docker.yml | 18 ++++++++--- .github/workflows/tags_nuget.yml | 4 ++- .github/workflows/test_docker.yml | 3 ++ 10 files changed, 90 insertions(+), 31 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 24ad7c3ac..4f619ad67 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,14 +1,22 @@ version: 2 updates: -- package-ecosystem: nuget - directory: "/" - schedule: - interval: daily - open-pull-requests-limit: 10 - labels: - - dependencies - - "pr: dependency-update" - ignore: - - dependency-name: YamlDotNet - versions: - - 11.1.0 + - package-ecosystem: nuget + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 + labels: + - dependencies + - "pr: dependency-update" + ignore: + - dependency-name: YamlDotNet + versions: + - 11.1.0 + + - package-ecosystem: github-actions + directory: "/" + schedule: + interval: daily + labels: + - dependencies + - "pr: dependency-update" diff --git a/.github/workflows/ci_build.yml b/.github/workflows/ci_build.yml index 05feded77..7cc2a0a58 100644 --- a/.github/workflows/ci_build.yml +++ b/.github/workflows/ci_build.yml @@ -19,9 +19,10 @@ jobs: uses: actions/checkout@main - name: 🥅 Install .Net 9 - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: dotnet-version: '9.0.x' + - name: 🔍 Enable problem matchers run: echo "::add-matcher::.github/matchers/dotnet.json" @@ -59,7 +60,7 @@ jobs: path-to-lcov: ${{github.workspace}}/codecover.info - name: 📨 Publish coverage to codecov - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@v5 with: flags: unittests # optional name: codecov-umbrella # optional diff --git a/.github/workflows/push_docker_addon_manual.yml b/.github/workflows/push_docker_addon_manual.yml index 32c61ad69..dc1350f74 100644 --- a/.github/workflows/push_docker_addon_manual.yml +++ b/.github/workflows/push_docker_addon_manual.yml @@ -16,29 +16,35 @@ jobs: 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 = "feature build";' ${{github.workspace}}/src/Runtime/NetDaemon.Runtime/Internal/NetDaemonRuntime.cs sed -i '/ io.hass.version=/c\ io.hass.version="feature" \\' ${{github.workspace}}/Dockerfile.AddOn + - name: 📎 Set up QEMU uses: docker/setup-qemu-action@v3 + - name: 🔧 Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v3 + - name: 🧰 Available platforms run: echo ${{ steps.buildx.outputs.platforms }} - name: 🔓 Login to Docker hub - uses: docker/login-action@v1.10.0 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_TOKEN }} + - name: 🔓 Login to GitHub Container Registry - uses: docker/login-action@v1.10.0 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} + - name: 🛠️ Run Buildx run: | docker buildx build \ diff --git a/.github/workflows/push_docker_manual.yml b/.github/workflows/push_docker_manual.yml index 44d7f5c38..d136c60f0 100644 --- a/.github/workflows/push_docker_manual.yml +++ b/.github/workflows/push_docker_manual.yml @@ -16,30 +16,36 @@ jobs: steps: - name: 📤 Checkout the repository uses: actions/checkout@main + - name: 📆 Set version number run: | echo setting source version: feature-${{ github.event.inputs.tag }} sed -i '/ private const string Version = /c\ private const string Version = "feature-${{ github.event.inputs.tag }}";' ${{github.workspace}}/src/Runtime/NetDaemon.Runtime/Internal/NetDaemonRuntime.cs sed -i '/ io.hass.version=/c\ io.hass.version="feature-${{ github.event.inputs.tag }}"' ${{github.workspace}}/Dockerfile.AddOn + - name: 📎 Set up QEMU uses: docker/setup-qemu-action@v3 + - name: 🔧 Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v3 + - name: 🧰 Available platforms run: echo ${{ steps.buildx.outputs.platforms }} - name: 🔓 Login to Docker hub - uses: docker/login-action@v1.10.0 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_TOKEN }} + - name: 🔓 Login to GitHub Container Registry - uses: docker/login-action@v1.10.0 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} + - name: 🛠️ Run Buildx run: | docker buildx build \ @@ -50,6 +56,7 @@ jobs: --compress \ --tag "netdaemon/netdaemon4:feature-${{ github.event.inputs.tag }}" \ --tag "ghcr.io/net-daemon/netdaemon4:feature-${{ github.event.inputs.tag }}" + deploy_docker_addon: name: 📦 Deploy to Docker add-on with tag runs-on: ubuntu-latest @@ -57,30 +64,36 @@ jobs: steps: - name: 📤 Checkout the repository uses: actions/checkout@main + - name: 📆 Set version number run: | echo setting source version: feature-${{ github.event.inputs.tag }} sed -i '/ private const string Version = /c\ private const string Version = "feature-${{ github.event.inputs.tag }}";' ${{github.workspace}}/src/Runtime/NetDaemon.Runtime/Internal/NetDaemonRuntime.cs sed -i '/ io.hass.version=/c\ io.hass.version="feature-${{ github.event.inputs.tag }}"' ${{github.workspace}}/Dockerfile.AddOn + - name: 📎 Set up QEMU uses: docker/setup-qemu-action@v3 + - name: 🔧 Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v3 + - name: 🧰 Available platforms run: echo ${{ steps.buildx.outputs.platforms }} - name: 🔓 Login to Docker hub - uses: docker/login-action@v1.10.0 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_TOKEN }} + - name: 🔓 Login to GitHub Container Registry - uses: docker/login-action@v1.10.0 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} + - name: 🛠️ Run Buildx run: | docker buildx build \ diff --git a/.github/workflows/push_docker_prerelease.yml b/.github/workflows/push_docker_prerelease.yml index 53df866bf..632bad525 100644 --- a/.github/workflows/push_docker_prerelease.yml +++ b/.github/workflows/push_docker_prerelease.yml @@ -21,30 +21,36 @@ jobs: steps: - name: 📤 Checkout the repository uses: actions/checkout@main + - name: 📆 Set version number run: | echo setting source version: ${{ github.event.inputs.pre }} sed -i '/ private const string Version = /c\ private const string Version = "${{ github.event.inputs.pre }}";' ${{github.workspace}}/src/Runtime/NetDaemon.Runtime/Internal/NetDaemonRuntime.cs sed -i '/ io.hass.version=/c\ io.hass.version="${{ github.event.inputs.pre }}"' ${{github.workspace}}/Dockerfile.AddOn + - name: 📎 Set up QEMU uses: docker/setup-qemu-action@v3 + - name: 🔧 Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v3 + - name: 🧰 Available platforms run: echo ${{ steps.buildx.outputs.platforms }} - name: 🔓 Login to Docker hub - uses: docker/login-action@v1.10.0 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_TOKEN }} + - name: 🔓 Login to GitHub Container Registry - uses: docker/login-action@v1.10.0 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} + - name: 🛠️ Run Buildx run: | docker buildx build \ @@ -55,6 +61,7 @@ jobs: --compress \ --tag "netdaemon/netdaemon5:${{ github.event.inputs.pre }}" \ --tag "ghcr.io/net-daemon/netdaemon5:${{ github.event.inputs.pre }}" + deploy_docker_addon: name: 📦 Deploy to Docker add-on with tag runs-on: ubuntu-latest @@ -67,25 +74,30 @@ jobs: echo setting source version: {{ github.event.inputs.pre }} sed -i '/ private const string Version = /c\ private const string Version = "feature-${{ github.event.inputs.pre }}";' ${{github.workspace}}/src/Runtime/NetDaemon.Runtime/Internal/NetDaemonRuntime.cs sed -i '/ io.hass.version=/c\ io.hass.version="feature-${{ github.event.inputs.pre }}"' ${{github.workspace}}/Dockerfile.AddOn + - name: 📎 Set up QEMU uses: docker/setup-qemu-action@v3 + - name: 🔧 Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v3 + - name: 🧰 Available platforms run: echo ${{ steps.buildx.outputs.platforms }} - name: 🔓 Login to Docker hub - uses: docker/login-action@v1.10.0 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_TOKEN }} + - name: 🔓 Login to GitHub Container Registry - uses: docker/login-action@v1.10.0 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} + - name: 🛠️ Run Buildx run: | docker buildx build \ diff --git a/.github/workflows/push_nuget_prerelease.yml b/.github/workflows/push_nuget_prerelease.yml index b902ec1ff..be29fe58e 100644 --- a/.github/workflows/push_nuget_prerelease.yml +++ b/.github/workflows/push_nuget_prerelease.yml @@ -42,15 +42,19 @@ jobs: echo "version=$datepre.$newpost" >> $GITHUB_OUTPUT # Get the build number echo "build=$(git rev-list $(git rev-list --tags --no-walk --max-count=1)..HEAD --count)" >> $GITHUB_OUTPUT + - name: 🥅 Install .Net 9 - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: dotnet-version: '9.0.x' # dotnet-quality: 'preview' + - name: 🔖 Set version number run: | sed -i "/ private const string Version = /c\ private const string Version = \"${{ steps.version.outputs.version }}-${{ github.event.inputs.pre }}-${{ steps.version.outputs.build }}\";" ${{github.workspace}}/src/Runtime/NetDaemon.Runtime/Internal/NetDaemonRuntime.cs + - name: 🎁 Pack run: dotnet pack NetDaemon.sln --configuration Release -p:PackageVersion=${{ steps.version.outputs.version }}-${{ github.event.inputs.pre }}-${{ steps.version.outputs.build }} -p:Version=${{ steps.version.outputs.version }}-${{ github.event.inputs.pre }}-${{ steps.version.outputs.build }} + - name: 📨 Push to nuget run: dotnet nuget push **/*.nupkg --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json diff --git a/.github/workflows/release_drafter.yml b/.github/workflows/release_drafter.yml index 3a028f1a6..d0770605d 100644 --- a/.github/workflows/release_drafter.yml +++ b/.github/workflows/release_drafter.yml @@ -32,7 +32,7 @@ jobs: echo "version=$datepre.$newpost" >> $GITHUB_OUTPUT - name: 🏃 Run Release Drafter - uses: release-drafter/release-drafter@v5 + uses: release-drafter/release-drafter@v6 with: tag: ${{ steps.version.outputs.version }} name: ${{ steps.version.outputs.version }} diff --git a/.github/workflows/tags_docker.yml b/.github/workflows/tags_docker.yml index 24a58ecb9..f4778ac7f 100644 --- a/.github/workflows/tags_docker.yml +++ b/.github/workflows/tags_docker.yml @@ -14,33 +14,38 @@ jobs: steps: - name: 📤 Checkout the repository uses: actions/checkout@main + - name: ⏭️ Get next version id: version run: | latest=$(git describe --tags $(git rev-list --tags --max-count=1)) echo Current version: $latest echo "::set-output name=version::$latest" + - name: 📆 Set version number run: | echo setting source version: ${{ steps.version.outputs.version }} sed -i '/ private const string Version = /c\ private const string Version = "${{ steps.version.outputs.version }}";' ${{github.workspace}}/src/Runtime/NetDaemon.Runtime/Internal/NetDaemonRuntime.cs sed -i '/ io.hass.version=/c\ io.hass.version="${{ steps.version.outputs.version }}"' ${{github.workspace}}/Dockerfile.AddOn + - name: 📎 Set up QEMU uses: docker/setup-qemu-action@v3 + - name: 🔧 Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v3 + - name: 🧰 Available platforms run: echo ${{ steps.buildx.outputs.platforms }} - name: 🔓 Login to Docker hub - uses: docker/login-action@v1.10.0 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_TOKEN }} - name: 🔓 Login to GitHub Container Registry - uses: docker/login-action@v1.10.0 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} @@ -84,22 +89,27 @@ jobs: - name: 📎 Set up QEMU uses: docker/setup-qemu-action@v3 + - name: 🔧 Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v3 + - name: 🧰 Available platforms run: echo ${{ steps.buildx.outputs.platforms }} + - name: 🔓 Login to Docker hub - uses: docker/login-action@v1.10.0 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_TOKEN }} + - name: 🔓 Login to GitHub Container Registry - uses: docker/login-action@v1.10.0 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} + - name: 🛠️ Run Buildx run: | docker buildx build \ diff --git a/.github/workflows/tags_nuget.yml b/.github/workflows/tags_nuget.yml index a69b2c7b3..939c418a1 100644 --- a/.github/workflows/tags_nuget.yml +++ b/.github/workflows/tags_nuget.yml @@ -24,14 +24,16 @@ jobs: echo "::set-output name=version::$latest" - name: 🥅 Install .Net 9 - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: dotnet-version: "9.0.x" # SDK Version - name: 🔖 Set version number run: | sed -i '/ private const string Version = /c\ private const string Version = "${{ steps.version.outputs.version }}";' ${{github.workspace}}/src/Runtime/NetDaemon.Runtime/Internal/NetDaemonRuntime.cs + - name: 🎁 Pack run: dotnet pack NetDaemon.sln --configuration Release -p:PackageVersion=${{ steps.version.outputs.version }} -p:Version=${{ steps.version.outputs.version }} + - name: 📨 Push to nuget run: dotnet nuget push **/*.nupkg --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json diff --git a/.github/workflows/test_docker.yml b/.github/workflows/test_docker.yml index 5d09c2c27..2e3b25f81 100644 --- a/.github/workflows/test_docker.yml +++ b/.github/workflows/test_docker.yml @@ -18,11 +18,14 @@ jobs: steps: - name: 📤 Checkout the repository uses: actions/checkout@main + - name: 📎 Set up QEMU uses: docker/setup-qemu-action@v3 + - name: 🔧 Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v3 + - name: 🧰 Available platforms run: echo ${{ steps.buildx.outputs.platforms }} From bf499ed47d0898273961e3060a27a5e3149c3263 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rasmus=20B=C3=A6kgaard?= Date: Sun, 29 Dec 2024 21:57:38 +0100 Subject: [PATCH 2/2] Update SonarScan for .NET --- .github/workflows/ci_analyze.yml | 67 ++++++++++++++++---------------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/.github/workflows/ci_analyze.yml b/.github/workflows/ci_analyze.yml index 471e77d93..323d6c856 100644 --- a/.github/workflows/ci_analyze.yml +++ b/.github/workflows/ci_analyze.yml @@ -1,35 +1,34 @@ -# Reenable when it supports .net 8 +### Build and tests all pushes, also code coverage +name: 🔍 CI Analyze sources +on: + push: + branches: + - main + +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 -#### Build and tests all pushes, also code coverage -# name: 🔍 CI Analyze sources -# on: -# push: -# branches: -# - main -# 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.2 -# 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" + - name: 🔍 Analyze code + uses: highbyte/sonarscan-dotnet@v2.4.1 + 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"