diff --git a/.github/workflows/Build-Test-And-Deploy.yaml b/.github/workflows/Build-Test-And-Deploy.yaml new file mode 100644 index 000000000..143e805c8 --- /dev/null +++ b/.github/workflows/Build-Test-And-Deploy.yaml @@ -0,0 +1,150 @@ +name: Build, Test, and Deploy Try .NET API + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + workflow_dispatch: + +permissions: + id-token: write + contents: read + +jobs: + build-and-test: + runs-on: ubuntu-latest + environment: "BuildAndUploadImage" + + steps: + - uses: actions/checkout@v6 + + - name: Set up .NET + uses: actions/setup-dotnet@v5 + with: + global-json-file: global.json + + - name: Set up dependency caching for faster builds + uses: actions/cache@v5 + id: nuget-cache + with: + path: | + ~/.nuget/packages + ${{ github.workspace }}/**/obj/project.assets.json + key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} + restore-keys: | + ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} + ${{ runner.os }}-nuget- + + - name: Restore with dotnet + run: dotnet restore + + - name: Build with dotnet + run: dotnet build -p:ContinuousIntegrationBuild=True -p:ReleaseDateAttribute=True --configuration Release --no-restore + + - name: Run .NET Tests + run: dotnet test --no-build --configuration Release + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + # Build but no push with a PR + - name: Docker build (no push) + if: github.event_name == 'pull_request' || github.event_name == 'merge_group' + uses: docker/build-push-action@v6 + with: + push: false + tags: temp-pr-validation + file: ./Dockerfile + + - name: Build Container Image + if: github.event_name != 'pull_request_target' && github.event_name != 'pull_request' + uses: docker/build-push-action@v6 + with: + tags: ${{ vars.DEVCONTAINER_REGISTRY }}/try:${{ github.sha }},${{ vars.DEVCONTAINER_REGISTRY }}/try:latest + file: ./Dockerfile + context: . + outputs: type=docker,dest=${{ github.workspace }}/tryimage.tar + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Upload artifact + if: github.event_name != 'pull_request_target' && github.event_name != 'pull_request' + uses: actions/upload-artifact@v6 + with: + name: tryimage + path: ${{ github.workspace }}/tryimage.tar + + deploy-development: + if: github.event_name != 'pull_request_target' && github.event_name != 'pull_request' + runs-on: ubuntu-latest + needs: build-and-test + environment: + name: "Development" + + steps: + - name: Azure Login + uses: azure/login@v2 + with: + client-id: ${{ secrets.ESSENTIALCSHARPDEV_CLIENT_ID }} + tenant-id: ${{ secrets.ESSENTIALCSHARP_TENANT_ID }} + subscription-id: ${{ secrets.ESSENTIALCSHARP_SUBSCRIPTION_ID }} + + - name: Download artifact + uses: actions/download-artifact@v7 + with: + name: tryimage + path: ${{ github.workspace }} + + - name: Load image + run: | + docker load --input ${{ github.workspace }}/tryimage.tar + docker image ls -a + + - name: Log in to container registry + uses: azure/CLI@v2 + env: + REGISTRY_URL: ${{ vars.DEVCONTAINER_REGISTRY }} + with: + inlineScript: | + REGISTRY_NAME=${REGISTRY_URL%.azurecr.io} + az acr login --name $REGISTRY_NAME + + - name: Push Image to Container Registry + env: + REGISTRY_URL: ${{ vars.DEVCONTAINER_REGISTRY }} + run: docker push --all-tags $REGISTRY_URL/try + + - name: Create and Deploy to Container App + uses: azure/CLI@v2 + env: + CONTAINER_APP_NAME: ${{ vars.CONTAINER_APP_NAME }} + RESOURCEGROUP: ${{ vars.RESOURCEGROUP }} + CONTAINER_APP_ENVIRONMENT: ${{ vars.CONTAINER_APP_ENVIRONMENT }} + REGISTRY_URL: ${{ vars.DEVCONTAINER_REGISTRY }} + SUBSCRIPTION_ID: ${{ secrets.ESSENTIALCSHARP_SUBSCRIPTION_ID }} + MANAGED_IDENTITY_ID: ${{ secrets.MANAGED_IDENTITY_ID }} + with: + inlineScript: | + az config set extension.use_dynamic_install=yes_without_prompt + az extension add --name containerapp --upgrade + az containerapp up \ + -n $CONTAINER_APP_NAME \ + -g $RESOURCEGROUP \ + --image $REGISTRY_URL/try:${{ github.sha }} \ + --environment $CONTAINER_APP_ENVIRONMENT \ + --registry-server $REGISTRY_URL \ + --ingress external \ + --target-port 8080 \ + --user-assigned /subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RESOURCEGROUP/providers/Microsoft.ManagedIdentity/userAssignedIdentities/$MANAGED_IDENTITY_ID \ + --registry-identity /subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RESOURCEGROUP/providers/Microsoft.ManagedIdentity/userAssignedIdentities/$MANAGED_IDENTITY_ID + + + - name: Logout of Azure CLI + if: always() + uses: azure/CLI@v2 + with: + inlineScript: | + az logout + az cache purge + az account clear \ No newline at end of file diff --git a/Directory.Packages.props b/Directory.Packages.props index a795acae9..e6ff8b6bd 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -7,10 +7,10 @@ - - - - + + + + @@ -24,7 +24,7 @@ - + diff --git a/Dockerfile b/Dockerfile index 88adbf475..a4721c59b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/sdk:9.0-azurelinux3.0 AS build-env +FROM mcr.microsoft.com/dotnet/sdk:10.0-azurelinux3.0 AS build-env WORKDIR /App # Copy everything @@ -24,7 +24,7 @@ RUN dotnet restore --configfile /App/NuGet.config /App/TryDotNet.sln RUN dotnet publish -c Release -o out /App/src/Microsoft.TryDotNet # Build runtime image -FROM mcr.microsoft.com/dotnet/sdk:9.0-azurelinux3.0 +FROM mcr.microsoft.com/dotnet/sdk:10.0-azurelinux3.0 ARG TRY_DOT_NET_BUILD_ID WORKDIR /App diff --git a/azure-pipelines-CI.yml b/azure-pipelines-CI.yml deleted file mode 100644 index f7c94e2a2..000000000 --- a/azure-pipelines-CI.yml +++ /dev/null @@ -1,191 +0,0 @@ -# azure-pipelines-CI.yml -parameters: -- name: SkipTests - displayName: Skip Tests - type: boolean - default: false - -# CI and PR triggers -trigger: -- main -- feature/* -- release/* -pr: -- main -- feature/* -- release/* - -resources: - repositories: - - repository: 1esPipelines - type: git - name: 1ESPipelineTemplates/1ESPipelineTemplates - ref: refs/tags/release - -variables: -- template: /eng/common/templates/variables/pool-providers.yml@self -- template: /eng/templates/variables-template.yml@self -- name: additionalWindowsArgs - value: '' -- name: additionalLinuxArgs - value: '' - -extends: - # The pipeline extends the 1ES PT which will inject different SDL and compliance tasks. - # For non-production pipelines, use "Unofficial" as defined below. - # For productions pipelines, use "Official". - template: v1/1ES.Official.PipelineTemplate.yml@1esPipelines - parameters: - # Update the pool with your team's 1ES hosted pool. - pool: - name: $(DncEngInternalBuildPool) # Name of your hosted pool - image: 1es-windows-2022 # Name of the image in your pool. If not specified, first image of the pool is used - os: windows # OS of the image. This value cannot be a variable. Allowed values: windows, linux, macOS - - # Build Tags - customBuildTags: - - TryDotNet - - $(Build.BuildNumber) - - sdl: - git: - longpaths: true - tsa: - enabled: true - config: - repositoryName: 'dotnet-try' - codebaseName: 'dotnet-try' - instanceUrl: 'https://devdiv.visualstudio.com/' - projectName: 'DEVDIV' - iterationPath: 'DevDiv\\Future Backlog' - areaPath: 'DevDiv\\NET Developer Experience\\VS Testing\\Interactive' - notificationAliases: ['dotnetInteractive@microsoft.com'] - serviceTreeID: 'ab4d58de-beb3-4714-866c-1b46a48ea002' - allTools: true - policheck: - enabled: true - credscan: - enabled: true - suppressionsFile: $(Build.SourcesDirectory)/.config/credscan/Suppressions.json - - stages: - - stage: build - displayName: Build and Test - jobs: - - template: /eng/common/templates-official/jobs/jobs.yml@self - parameters: - enableMicrobuild: true - enablePublishBuildArtifacts: true - enablePublishTestResults: true - enablePublishBuildAssets: true - enablePublishUsingPipelines: $(_PublishUsingPipelines) - jobs: - - job: Windows_NT - pool: - # TODO: Can we use latest or equivalent? - name: $(DncEngInternalBuildPool) - demands: ImageOverride -equals 1es-windows-2022 - os: windows - templateContext: - # This enables SDL scanning to be run once across all artifacts - outputParentDirectory: $(Build.SourcesDirectory)/artifacts - outputs: - - output: pipelineArtifact - targetPath: $(Build.SourcesDirectory)/artifacts - artifactName: Windows_artifacts - displayName: Publish Windows artifacts - condition: always() - - variables: - - name: TRYDOTNET_PREBUILDS_PATH - value: $(Build.SourcesDirectory)\artifacts\trydotnet-prebuilds - - name: POCKETLOGGER_LOG_PATH - value: $(Build.SourcesDirectory)\artifacts\logs\pocketlogger.log - - name: RunIntegrationTests - value: true - # Enable signing for internal, non-PR builds - - ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}: - - group: DotNet-Symbol-Server-Pats - - name: _SignType - value: Real - - name: _DotNetPublishToBlobFeed - value: false - - name: _BuildArgs - value: /p:SignType=$(_SignType) - /p:DotNetSignType=$(_SignType) - /p:MicroBuild_SigningEnabled=true - /p:OverridePackageSource=https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json - /p:TeamName=$(_TeamName) - /p:DotNetPublishToBlobFeed=false - /p:DotNetPublishUsingPipelines=$(_PublishUsingPipelines) - /p:DotNetArtifactsCategory=$(_DotNetArtifactsCategory) - /p:DotNetSymbolServerTokenMsdl=$(microsoft-symbol-server-pat) - /p:DotNetSymbolServerTokenSymWeb=$(symweb-symbol-server-pat) - /p:OfficialBuildId=$(BUILD.BUILDNUMBER) - # else - - ${{ if or(eq(variables['System.TeamProject'], 'public'), in(variables['Build.Reason'], 'PullRequest')) }}: - - name: _SignType - value: Test - - name: _BuildArgs - value: /p:SignType=$(_SignType) - steps: - - task: UseDotNet@2 - displayName: Install SDK 9.0.111 - inputs: - packageType: sdk - version: 9.0.111 - - template: /eng/templates/build-and-test-job-windows-templates.yml@self - parameters: - buildConfig: $(_BuildConfig) - skipTests: $(SkipTests) - buildArgs: $(_BuildArgs) - additionalArgs: $(additionalWindowsArgs) - - template: /eng/common/templates-official/jobs/jobs.yml@self - parameters: - enableMicrobuild: true - enablePublishBuildArtifacts: true - enablePublishTestResults: true - enablePublishBuildAssets: false - enablePublishUsingPipelines: false - jobs: - - job: Linux - pool: - name: $(DncEngInternalBuildPool) - os: linux - demands: ImageOverride -equals 1es-mariner-2 - templateContext: - # This enables SDL scanning to be run once across all artifacts - outputParentDirectory: $(Build.SourcesDirectory)/artifacts - outputs: - - output: pipelineArtifact - targetPath: $(Build.SourcesDirectory)/artifacts - artifactName: Linux_artifacts - displayName: Publish Linux artifacts - condition: always() - variables: - - name: TRYDOTNET_PREBUILDS_PATH - value: $(Build.SourcesDirectory)/artifacts/trydotnet-prebuilds - - name: POCKETLOGGER_LOG_PATH - value: $(Build.SourcesDirectory)/artifacts/logs/pocketlogger.log - # Enable signing for internal, non-PR builds - - ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}: - - name: _SignType - value: Test - - name: _BuildArgs - value: /p:SignType=$(_SignType) - /p:DotNetSignType=$(_SignType) - /p:OverridePackageSource=https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json - /p:TeamName=$(_TeamName) - /p:OfficialBuildId=$(BUILD.BUILDNUMBER) - # else - - ${{ if or(eq(variables['System.TeamProject'], 'public'), in(variables['Build.Reason'], 'PullRequest')) }}: - - name: _SignType - value: Test - - name: _BuildArgs - value: /p:SignType=$(_SignType) - steps: - - template: /eng/templates/build-and-test-job-linux-templates.yml@self - parameters: - buildConfig: $(_BuildConfig) - skipTests: $(SkipTests) - additionalArgs: $(additionalLinuxArgs) diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index a7bb119b3..000000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,156 +0,0 @@ -# azure-pipelines.yml -parameters: -- name: SkipTests - displayName: Skip Tests - type: boolean - default: false - -# CI and PR triggers -trigger: -- main -- feature/* -- release/* -pr: -- main -- feature/* -- release/* - -variables: - - template: /eng/templates/variables-template.yml@self - - name: system.debug - value: true - - name: additionalWindowsArgs - value: '--diag $(Build.SourcesDirectory)/artifacts/TestResults/$(_BuildConfig)/diag.txt -p:m=1' - - name: additionalLinuxArgs - value: '--diag $(Build.SourcesDirectory)/artifacts/TestResults/$(_BuildConfig)/diag.txt' - -stages: -- stage: build - displayName: Build and Test - jobs: - - template: /eng/common/templates/jobs/jobs.yml - parameters: - enableMicrobuild: true - enablePublishBuildArtifacts: true - enablePublishTestResults: true - enablePublishBuildAssets: true - enablePublishUsingPipelines: $(_PublishUsingPipelines) - jobs: - - job: Windows_NT - pool: - ${{ if or(eq(variables['System.TeamProject'], 'public'), in(variables['Build.Reason'], 'PullRequest')) }}: - name: NetCore-Public - demands: ImageOverride -equals windows.vs2022.amd64.open - ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}: - name: NetCore1ESPool-Internal - demands: ImageOverride -equals windows.vs2022.amd64 - variables: - - name: RunIntegrationTests - value: true - - name: TRYDOTNET_PREBUILDS_PATH - value: $(Build.SourcesDirectory)\artifacts\trydotnet-prebuilds - - name: POCKETLOGGER_LOG_PATH - value: $(Build.SourcesDirectory)\artifacts\logs\pocketlogger.log - # Enable signing for internal, non-PR builds - - ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}: - - group: DotNet-Symbol-Server-Pats - - name: _SignType - value: Real - - name: _DotNetPublishToBlobFeed - value: false - - name: _BuildArgs - value: /p:SignType=$(_SignType) - /p:DotNetSignType=$(_SignType) - /p:MicroBuild_SigningEnabled=true - /p:OverridePackageSource=https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json - /p:TeamName=$(_TeamName) - /p:DotNetPublishToBlobFeed=false - /p:DotNetPublishUsingPipelines=$(_PublishUsingPipelines) - /p:DotNetArtifactsCategory=$(_DotNetArtifactsCategory) - /p:DotNetSymbolServerTokenMsdl=$(microsoft-symbol-server-pat) - /p:DotNetSymbolServerTokenSymWeb=$(symweb-symbol-server-pat) - /p:OfficialBuildId=$(BUILD.BUILDNUMBER) - # else - - ${{ if or(eq(variables['System.TeamProject'], 'public'), in(variables['Build.Reason'], 'PullRequest')) }}: - - name: _SignType - value: Test - - name: _BuildArgs - value: /p:SignType=$(_SignType) - steps: - - task: UseDotNet@2 - displayName: Install SDK 9.0.111 - inputs: - packageType: sdk - version: 9.0.111 - - template: /eng/templates/build-and-test-job-windows-templates.yml@self - parameters: - buildConfig: $(_BuildConfig) - skipTests: $(SkipTests) - buildArgs: $(_BuildArgs) - additionalArgs: $(additionalWindowsArgs) - - task: PublishBuildArtifacts@1 - displayName: Publish Windows artifacts - inputs: - pathToPublish: $(Build.SourcesDirectory)/artifacts/ - artifactName: Windows_artifacts - artifactType: container - condition: always() - - - template: /eng/common/templates/jobs/jobs.yml - parameters: - enableMicrobuild: true - enablePublishBuildArtifacts: true - enablePublishTestResults: true - enablePublishBuildAssets: false - enablePublishUsingPipelines: false - jobs: - - job: Linux - pool: - vmImage: ubuntu-22.04 - variables: - - name: TRYDOTNET_PREBUILDS_PATH - value: $(Build.SourcesDirectory)/artifacts/trydotnet-prebuilds - - name: POCKETLOGGER_LOG_PATH - value: $(Build.SourcesDirectory)/artifacts/logs/pocketlogger.log - # Enable signing for internal, non-PR builds - - ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}: - - name: _SignType - value: Test - - name: _BuildArgs - value: /p:SignType=$(_SignType) - /p:DotNetSignType=$(_SignType) - /p:OverridePackageSource=https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json - /p:TeamName=$(_TeamName) - /p:OfficialBuildId=$(BUILD.BUILDNUMBER) - # else - - ${{ if or(eq(variables['System.TeamProject'], 'public'), in(variables['Build.Reason'], 'PullRequest')) }}: - - name: _SignType - value: Test - - name: _BuildArgs - value: /p:SignType=$(_SignType) - steps: - - template: /eng/templates/build-and-test-job-linux-templates.yml@self - parameters: - buildConfig: $(_BuildConfig) - skipTests: $(SkipTests) - additionalArgs: $(additionalLinuxArgs) - - - task: PublishBuildArtifacts@1 - displayName: Publish Linux artifacts - inputs: - pathToPublish: $(Build.SourcesDirectory)/artifacts/ - artifactName: Linux_artifacts - artifactType: container - condition: always() - -#---------------------------------------------------------------------------------------------------------------------# -# Post Build # -#---------------------------------------------------------------------------------------------------------------------# -- ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}: - - template: eng/common/templates/post-build/post-build.yml - parameters: - publishingInfraVersion: 3 - # Symbol validation is not entirely reliable as of yet, so should be turned off until https://github.com/dotnet/arcade/issues/2871 is resolved. - enableSymbolValidation: false - # SourceLink improperly looks for generated files. See https://github.com/dotnet/arcade/issues/3069 - enableSourceLinkValidation: false diff --git a/eng/build.ps1 b/eng/build.ps1 index fbfe4e521..1111d775f 100644 --- a/eng/build.ps1 +++ b/eng/build.ps1 @@ -48,7 +48,7 @@ try { # playwright if ($test) { - & $repoRoot\artifacts\bin\Microsoft.TryDotNet.IntegrationTests\$configuration\net9.0\playwright.ps1 install chromium + & $repoRoot\artifacts\bin\Microsoft.TryDotNet.IntegrationTests\$configuration\net10.0\playwright.ps1 install chromium } } } diff --git a/global.json b/global.json index 02e68dde0..68f9c1d13 100644 --- a/global.json +++ b/global.json @@ -1,11 +1,11 @@ { "sdk": { - "version": "9.0.111", - "allowPrerelease": true, + "version": "10.0.100", + "allowPrerelease": false, "rollForward": "latestMinor" }, "tools": { - "dotnet": "9.0.111", + "dotnet": "10.0.100", "rollForward": "latestMinor" }, "msbuild-sdks": { diff --git a/src/Microsoft.TryDotNet.IntegrationTests/Microsoft.TryDotNet.IntegrationTests.csproj b/src/Microsoft.TryDotNet.IntegrationTests/Microsoft.TryDotNet.IntegrationTests.csproj index dd09f85f8..196d51215 100644 --- a/src/Microsoft.TryDotNet.IntegrationTests/Microsoft.TryDotNet.IntegrationTests.csproj +++ b/src/Microsoft.TryDotNet.IntegrationTests/Microsoft.TryDotNet.IntegrationTests.csproj @@ -1,7 +1,7 @@  - net9.0 + net10.0 enable false GeneratedLocation.cs @@ -29,8 +29,6 @@ all runtime; build; native; contentfiles; analyzers - - all diff --git a/src/Microsoft.TryDotNet.SimulatorGenerator/Microsoft.TryDotNet.SimulatorGenerator.csproj b/src/Microsoft.TryDotNet.SimulatorGenerator/Microsoft.TryDotNet.SimulatorGenerator.csproj index 9a1817f23..f79f6e889 100644 --- a/src/Microsoft.TryDotNet.SimulatorGenerator/Microsoft.TryDotNet.SimulatorGenerator.csproj +++ b/src/Microsoft.TryDotNet.SimulatorGenerator/Microsoft.TryDotNet.SimulatorGenerator.csproj @@ -2,7 +2,7 @@ Exe - net9.0 + net10.0 enable enable embedded @@ -15,7 +15,6 @@ - diff --git a/src/Microsoft.TryDotNet.Tests/Microsoft.TryDotNet.Tests.csproj b/src/Microsoft.TryDotNet.Tests/Microsoft.TryDotNet.Tests.csproj index 9fcf05f74..917c99fc4 100644 --- a/src/Microsoft.TryDotNet.Tests/Microsoft.TryDotNet.Tests.csproj +++ b/src/Microsoft.TryDotNet.Tests/Microsoft.TryDotNet.Tests.csproj @@ -1,7 +1,7 @@  - net9.0 + net10.0 enable enable all @@ -29,8 +29,6 @@ all runtime; build; native; contentfiles; analyzers - - all diff --git a/src/Microsoft.TryDotNet.WasmRunner/Microsoft.TryDotNet.WasmRunner.csproj b/src/Microsoft.TryDotNet.WasmRunner/Microsoft.TryDotNet.WasmRunner.csproj index d675be24e..71697049c 100644 --- a/src/Microsoft.TryDotNet.WasmRunner/Microsoft.TryDotNet.WasmRunner.csproj +++ b/src/Microsoft.TryDotNet.WasmRunner/Microsoft.TryDotNet.WasmRunner.csproj @@ -1,7 +1,7 @@  - net9.0 + net10.0 enable enable wasmrunner diff --git a/src/Microsoft.TryDotNet/Microsoft.TryDotNet.csproj b/src/Microsoft.TryDotNet/Microsoft.TryDotNet.csproj index a22b26a51..83b972b7e 100644 --- a/src/Microsoft.TryDotNet/Microsoft.TryDotNet.csproj +++ b/src/Microsoft.TryDotNet/Microsoft.TryDotNet.csproj @@ -1,7 +1,7 @@  - net9.0 + net10.0 enable enable true @@ -23,8 +23,6 @@ - -