From fbf4f78ccf4c7696e4d1111f1c2a80a5605d39d9 Mon Sep 17 00:00:00 2001 From: lucas-mrq Date: Sun, 5 May 2024 23:18:55 +0200 Subject: [PATCH] Merge with 5.3.1 --- .github/workflows/awesome-ideas.yml | 4 +- .github/workflows/aws-cfn-lint.yml | 2 +- .github/workflows/aws_deploy_staging.yml | 4 +- .github/workflows/bicep-lint.yml | 2 +- .../workflows/ci-open-api-documentation.yml | 4 +- .github/workflows/ci-tests.yml | 8 +- .github/workflows/codeql.yml | 2 +- .../delete-documentation-version.yml | 2 +- .github/workflows/deploy_staging.yml | 2 +- .github/workflows/issue.yml | 2 +- .github/workflows/lint-documentation.yml | 4 +- .../publish-documentation-new-version.yml | 2 +- .github/workflows/publish.yml | 87 ++- src/Dockerfile | 19 +- .../IoTHub.Portal.Application.csproj | 2 +- .../IoTHub.Portal.Client.csproj | 12 +- ...THub - Backup.Portal.Infrastructure.csproj | 2 +- .../IoTHub.Portal.Infrastructure.csproj | 6 +- .../PortalDbContext.cs | 14 +- ... cascade when deleting devices.Designer.cs | 606 +++++++++++++++++ ...values in cascade when deleting devices.cs | 67 ++ .../PortalDbContextModelSnapshot.cs | 8 +- ... cascade when deleting devices.Designer.cs | 611 ++++++++++++++++++ ...values in cascade when deleting devices.cs | 67 ++ ...d Layers, Planning & Schedule.Designer.cs} | 10 +- ...170814_Add Layers, Planning & Schedule.cs} | 0 .../PortalDbContextModelSnapshot.cs | 8 +- .../IoTHub.Portal.Server.csproj | 18 +- .../IoTHub.Portal.Shared.csproj | 6 +- .../IoTHub.Portal.Tests.E2E.csproj | 4 +- .../AwsGreengrassComponentDialogTests.cs | 6 +- ...wsGreengrassPublicComponentsDialogTests.cs | 8 +- .../EdgeModule/ModuleDialogTests.cs | 8 +- .../DeleteDeviceConfigurationTests.cs | 4 +- .../Devices/ConnectionStringDialogTests.cs | 4 +- .../Pages/Devices/DeleteDevicePageTests.cs | 4 +- .../Pages/Devices/ImportReportDialogTests.cs | 10 +- .../Devices/LoRaDeviceTelemetryDialogTests.cs | 4 +- .../ConnectionStringDialogTests.cs | 6 +- ...EdgeDeviceDeleteConfirmationDialogTests.cs | 6 +- .../EdgeDevices/ModuleLogsDialogTests.cs | 6 +- .../EdgeModels/DeleteEdgeModelDialogTest.cs | 6 +- .../EdgeModels/SystemModuleDialogTest.cs | 2 +- .../Pages/Ideas/SubmitIdeaDialogTests.cs | 14 +- .../DeleteConcentratorPageTests.cs | 6 +- .../Pages/Shared/ProblemDetailsDialogTests.cs | 2 +- .../Services/LoRaWanManagementServiceTests.cs | 41 ++ .../IoTHub.Portal.Tests.Unit.csproj | 6 +- 48 files changed, 1605 insertions(+), 123 deletions(-) create mode 100644 src/IoTHub.Portal.MySql/Migrations/20240503170430_Fix #2980 - delete tag values in cascade when deleting devices.Designer.cs create mode 100644 src/IoTHub.Portal.MySql/Migrations/20240503170430_Fix #2980 - delete tag values in cascade when deleting devices.cs create mode 100644 src/IoTHub.Portal.Postgres/Migrations/20240503170119_Fix #2980 - delete tag values in cascade when deleting devices.Designer.cs create mode 100644 src/IoTHub.Portal.Postgres/Migrations/20240503170119_Fix #2980 - delete tag values in cascade when deleting devices.cs rename src/IoTHub.Portal.Postgres/Migrations/{20240411150956_Add Layers, Planning & Schedule.Designer.cs => 20240505170814_Add Layers, Planning & Schedule.Designer.cs} (98%) rename src/IoTHub.Portal.Postgres/Migrations/{20240411150956_Add Layers, Planning & Schedule.cs => 20240505170814_Add Layers, Planning & Schedule.cs} (100%) diff --git a/.github/workflows/awesome-ideas.yml b/.github/workflows/awesome-ideas.yml index 5161fbca6..06cca16a9 100644 --- a/.github/workflows/awesome-ideas.yml +++ b/.github/workflows/awesome-ideas.yml @@ -11,7 +11,7 @@ jobs: steps: - uses: hmarr/debug-action@v3 - - uses: actions/checkout@v4.1.2 + - uses: actions/checkout@v4.1.4 - uses: JasonEtco/create-an-issue@v2 if: github.event.discussion.category.name == 'Ideas' @@ -20,7 +20,7 @@ jobs: with: filename: .github/issue_from_discussion.md - - uses: actions/add-to-project@v1.0.0 + - uses: actions/add-to-project@v1.0.1 with: project-url: https://github.com/orgs/CGI-FR/projects/1 github-token: ${{ steps.generate_app_token.outputs.token }} \ No newline at end of file diff --git a/.github/workflows/aws-cfn-lint.yml b/.github/workflows/aws-cfn-lint.yml index 00b8653f9..29436b197 100644 --- a/.github/workflows/aws-cfn-lint.yml +++ b/.github/workflows/aws-cfn-lint.yml @@ -28,7 +28,7 @@ jobs: repo: context.repo.repo, labels: ['cfn-templates'] }) - - uses: actions/checkout@v4.1.2 + - uses: actions/checkout@v4.1.4 - name: Check CloudFormation Syntax uses: scottbrenner/cfn-lint-action@v2 diff --git a/.github/workflows/aws_deploy_staging.yml b/.github/workflows/aws_deploy_staging.yml index 1e081181a..eddd2c6c5 100644 --- a/.github/workflows/aws_deploy_staging.yml +++ b/.github/workflows/aws_deploy_staging.yml @@ -14,7 +14,7 @@ jobs: outputs: aws_public_registry: ${{ steps.login-ecr-public.outputs.registry }} steps: - - uses: actions/checkout@v4.1.2 + - uses: actions/checkout@v4.1.4 - id: docker-tag uses: yuya-takeyama/docker-tag-from-github-ref-action@v1 @@ -82,7 +82,7 @@ jobs: environment: name: AWS Staging steps: - - uses: actions/checkout@v4.1.2 + - uses: actions/checkout@v4.1.4 - name: Configure AWS credentials id: aws-credentials diff --git a/.github/workflows/bicep-lint.yml b/.github/workflows/bicep-lint.yml index 31c2ff03a..53fdf93a5 100644 --- a/.github/workflows/bicep-lint.yml +++ b/.github/workflows/bicep-lint.yml @@ -31,7 +31,7 @@ jobs: labels: ['arm-templates'] }) - - uses: actions/checkout@v4.1.2 + - uses: actions/checkout@v4.1.4 with: submodules: recursive diff --git a/.github/workflows/ci-open-api-documentation.yml b/.github/workflows/ci-open-api-documentation.yml index cfa277ffe..4eb7c8162 100644 --- a/.github/workflows/ci-open-api-documentation.yml +++ b/.github/workflows/ci-open-api-documentation.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.2 + - uses: actions/checkout@v4.1.4 - name: Setup .NET uses: actions/setup-dotnet@v4 @@ -52,7 +52,7 @@ jobs: needs: [ build ] if: github.ref == 'refs/heads/main' steps: - - uses: actions/checkout@v4.1.2 + - uses: actions/checkout@v4.1.4 with: ref: 'docs/main' diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 2aceb56f2..3908bcd38 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.2 + - uses: actions/checkout@v4.1.4 - name: Setup .NET uses: actions/setup-dotnet@v4 @@ -62,7 +62,7 @@ jobs: needs: unit-test steps: - - uses: actions/checkout@v4.1.2 + - uses: actions/checkout@v4.1.4 - uses: actions/download-artifact@v4 with: @@ -71,7 +71,7 @@ jobs: src/IoTHub.Portal.Tests.Unit/TestResults - name: Upload to Codecov test reports - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} directory: src/IoTHub.Portal.Tests.Unit/TestResults @@ -85,7 +85,7 @@ jobs: # steps: - # - uses: actions/checkout@v4.1.2 + # - uses: actions/checkout@v4.1.4 # - name: Setup .NET # uses: actions/setup-dotnet@v4 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 0efed588b..ae9525e4d 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -30,7 +30,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v4.1.2 + uses: actions/checkout@v4.1.4 - name: Setup .NET uses: actions/setup-dotnet@v4 diff --git a/.github/workflows/delete-documentation-version.yml b/.github/workflows/delete-documentation-version.yml index 73aa99c52..2952587ec 100644 --- a/.github/workflows/delete-documentation-version.yml +++ b/.github/workflows/delete-documentation-version.yml @@ -10,7 +10,7 @@ jobs: name: Delete Documentation Version runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.2 + - uses: actions/checkout@v4.1.4 with: ref: docs/main fetch-depth: 0 diff --git a/.github/workflows/deploy_staging.yml b/.github/workflows/deploy_staging.yml index 3fa325dbe..febfaed86 100644 --- a/.github/workflows/deploy_staging.yml +++ b/.github/workflows/deploy_staging.yml @@ -26,7 +26,7 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v4.1.2 + - uses: actions/checkout@v4.1.4 - id: docker-tag uses: yuya-takeyama/docker-tag-from-github-ref-action@v1 diff --git a/.github/workflows/issue.yml b/.github/workflows/issue.yml index 51872720f..26c7da2ac 100644 --- a/.github/workflows/issue.yml +++ b/.github/workflows/issue.yml @@ -17,7 +17,7 @@ jobs: app_id: ${{ secrets.BOT_APP_ID }} private_key: ${{ secrets.BOT_PRIVATE_KEY }} - - uses: actions/add-to-project@v1.0.0 + - uses: actions/add-to-project@v1.0.1 with: project-url: https://github.com/orgs/CGI-FR/projects/1 github-token: ${{ steps.generate_app_token.outputs.token }} \ No newline at end of file diff --git a/.github/workflows/lint-documentation.yml b/.github/workflows/lint-documentation.yml index a96269c9f..bee625056 100644 --- a/.github/workflows/lint-documentation.yml +++ b/.github/workflows/lint-documentation.yml @@ -7,7 +7,7 @@ jobs: lint-documentation: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.2 - - uses: DavidAnson/markdownlint-cli2-action@v15 + - uses: actions/checkout@v4.1.4 + - uses: DavidAnson/markdownlint-cli2-action@v16 with: globs: 'docs/**/*.md' diff --git a/.github/workflows/publish-documentation-new-version.yml b/.github/workflows/publish-documentation-new-version.yml index d61ca5b88..b35a58aee 100644 --- a/.github/workflows/publish-documentation-new-version.yml +++ b/.github/workflows/publish-documentation-new-version.yml @@ -7,7 +7,7 @@ jobs: name: Publish Documentation with New Version runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.2 + - uses: actions/checkout@v4.1.4 with: ref: docs/main fetch-depth: 0 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1d79110f2..a36e9f5ac 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -23,7 +23,7 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v4.1.2 + - uses: actions/checkout@v4.1.4 - id: docker-tag uses: yuya-takeyama/docker-tag-from-github-ref-action@v1 @@ -67,3 +67,88 @@ jobs: GITHUB_RUN_NUMBER=${{ github.run_number }} tags: ${{ steps.meta.outputs.tags }} + + arm_templates: + name: Publish cloud infrastructure templates + # The type of runner that the job will run on + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4.1.4 + + - name: Get semver + id: version + uses: docker/metadata-action@v5 + with: + images: | + ${{ env.registry_name }}/${{ github.repository_owner }}/${{ env.image_name }} + tags: | + type=semver,pattern={{version}} + + - uses: actions/checkout@v4.1.4 + with: + path: IoT-Hub-Portal + submodules: recursive + + - uses: actions/checkout@v4.1.4 + with: + ref: arm/main + path: arm-templates + + - name: Generate app token + id: generate_app_token + uses: tibdex/github-app-token@v2 + with: + app_id: ${{ secrets.BOT_APP_ID }} + private_key: ${{ secrets.BOT_PRIVATE_KEY }} + + - name: Copy templates + working-directory: arm-templates + run: | + rm -rf ./templates/ + mkdir -p templates/azure/iotedge-lorawan-starterkit + touch ./templates/.gitkeep + cp -r ../IoT-Hub-Portal/templates/* ./templates/ + rm -rf ./templates/iotedge-lorawan-starterkit/ + cp -r ../IoT-Hub-Portal/templates/iotedge-lorawan-starterkit/TemplateBicep/* ./templates/azure/iotedge-lorawan-starterkit/ + sed -r -i 's/..\/iotedge-lorawan-starterkit\/TemplateBicep\/main.bicep/.\/iotedge-lorawan-starterkit\/main.bicep/g' ./templates/azure/portal_with_lorawan_and_starter_kit.bicep + + - name: Update IoTHub Portal docker image tag in app_service.bicep + working-directory: arm-templates/templates/azure + run: sed -i 's/ghcr.io\/cgi-fr\/iothub-portal:latest/ghcr.io\/cgi-fr\/iothub-portal:${{ fromJSON(steps.version.outputs.json).labels['org.opencontainers.image.version'] }}/g' app_service.bicep + + - name: Update IoTHub Portal docker image tag in awsdeploy.yml + working-directory: arm-templates/templates/aws + run: | + sed -i 's/public.ecr.aws\/cgi-fr\/iothub-portal:latest/public.ecr.aws\/cgi-fr\/iothub-portal:${{ fromJSON(steps.version.outputs.json).labels['org.opencontainers.image.version'] }}/g' awsdeploy.yml + + - name: Generate ARM file + working-directory: arm-templates/templates/azure + run: az bicep build --file azuredeploy.bicep --outfile azuredeploy.json + + - name: Upload azure templates to release assets + uses: AButler/upload-release-assets@v3.0 + with: + files: 'arm-templates/templates/azure/*.json' + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload aws templates to release assets + uses: AButler/upload-release-assets@v3.0 + with: + files: 'arm-templates/templates/aws/*.yml' + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Create PR for template updates + uses: peter-evans/create-pull-request@v6 + with: + base: 'arm/main' + branch: 'arm/feature/update-templates' + path: 'arm-templates' + commit-message: 'Update templates from release.' + token: ${{ steps.generate_app_token.outputs.token }} + title: '[ARM Templates] Update templates from release' + labels: | + arm-templates + automated pr + body: | + Automated changes to the Azure templates. diff --git a/src/Dockerfile b/src/Dockerfile index 2fe402fef..67807e0ba 100644 --- a/src/Dockerfile +++ b/src/Dockerfile @@ -4,32 +4,23 @@ WORKDIR /app EXPOSE 80 EXPOSE 443 -FROM node:14-bullseye AS build - -RUN wget https://packages.microsoft.com/config/debian/11/packages-microsoft-prod.deb -O packages-microsoft-prod.deb -RUN dpkg -i packages-microsoft-prod.deb -RUN rm packages-microsoft-prod.deb -RUN apt-get update; \ - apt-get install -y apt-transport-https && \ - apt-get update && \ - apt-get install -y dotnet-sdk-8.0 - -FROM build AS builder +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build ARG BUILD_VERSION=1.2.3 ARG GITHUB_RUN_NUMBER=4 WORKDIR /src +RUN ls COPY ["IoTHub.Portal.Server/IoTHub.Portal.Server.csproj", "IoTHub.Portal.Server/"] COPY ["IoTHub.Portal.Shared/IoTHub.Portal.Shared.csproj", "IoTHub.Portal.Shared/"] COPY ["IoTHub.Portal.Client/IoTHub.Portal.Client.csproj", "IoTHub.Portal.Client/"] RUN dotnet restore "IoTHub.Portal.Server/IoTHub.Portal.Server.csproj" COPY . . WORKDIR "/src/IoTHub.Portal.Server" -RUN dotnet build "IoTHub.Portal.Server.csproj" -c Release -o /app/build -p:Version="${BUILD_VERSION}.${GITHUB_RUN_NUMBER}" -p:ClientAssetsRestoreCommand="npm ci" +RUN dotnet build "IoTHub.Portal.Server.csproj" -c Release -o /app/build -p:Version="${BUILD_VERSION}.${GITHUB_RUN_NUMBER}" -FROM builder AS publish +FROM build AS publish ARG BUILD_VERSION=1.2.3 ARG GITHUB_RUN_NUMBER=4 -RUN dotnet publish "IoTHub.Portal.Server.csproj" -c Release -o /app/publish -p:Version="${BUILD_VERSION}.${GITHUB_RUN_NUMBER}" -p:ClientAssetsRestoreCommand="npm ci" +RUN dotnet publish "IoTHub.Portal.Server.csproj" -c Release -o /app/publish -p:Version="${BUILD_VERSION}.${GITHUB_RUN_NUMBER}" FROM base AS final WORKDIR /app diff --git a/src/IoTHub.Portal.Application/IoTHub.Portal.Application.csproj b/src/IoTHub.Portal.Application/IoTHub.Portal.Application.csproj index 33685d5cb..2b07f6565 100644 --- a/src/IoTHub.Portal.Application/IoTHub.Portal.Application.csproj +++ b/src/IoTHub.Portal.Application/IoTHub.Portal.Application.csproj @@ -9,7 +9,7 @@ - + diff --git a/src/IoTHub.Portal.Client/IoTHub.Portal.Client.csproj b/src/IoTHub.Portal.Client/IoTHub.Portal.Client.csproj index b7fc3ca03..c007ee7ba 100644 --- a/src/IoTHub.Portal.Client/IoTHub.Portal.Client.csproj +++ b/src/IoTHub.Portal.Client/IoTHub.Portal.Client.csproj @@ -16,8 +16,8 @@ - - + + all @@ -28,17 +28,17 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - - + + diff --git a/src/IoTHub.Portal.Infrastructure/IoTHub - Backup.Portal.Infrastructure.csproj b/src/IoTHub.Portal.Infrastructure/IoTHub - Backup.Portal.Infrastructure.csproj index ae4507708..021406f06 100644 --- a/src/IoTHub.Portal.Infrastructure/IoTHub - Backup.Portal.Infrastructure.csproj +++ b/src/IoTHub.Portal.Infrastructure/IoTHub - Backup.Portal.Infrastructure.csproj @@ -95,7 +95,7 @@ - + diff --git a/src/IoTHub.Portal.Infrastructure/IoTHub.Portal.Infrastructure.csproj b/src/IoTHub.Portal.Infrastructure/IoTHub.Portal.Infrastructure.csproj index 199861a69..b9e2d2781 100644 --- a/src/IoTHub.Portal.Infrastructure/IoTHub.Portal.Infrastructure.csproj +++ b/src/IoTHub.Portal.Infrastructure/IoTHub.Portal.Infrastructure.csproj @@ -105,8 +105,8 @@ - - + + @@ -141,7 +141,7 @@ - + diff --git a/src/IoTHub.Portal.Infrastructure/PortalDbContext.cs b/src/IoTHub.Portal.Infrastructure/PortalDbContext.cs index 7519ccd87..58e54d875 100644 --- a/src/IoTHub.Portal.Infrastructure/PortalDbContext.cs +++ b/src/IoTHub.Portal.Infrastructure/PortalDbContext.cs @@ -28,10 +28,8 @@ public class PortalDbContext : DbContext, IDataProtectionKeyContext public DbSet