diff --git a/.github/workflows/build-and-stage.yml b/.github/workflows/build-and-stage.yml new file mode 100644 index 0000000..6a14bd0 --- /dev/null +++ b/.github/workflows/build-and-stage.yml @@ -0,0 +1,94 @@ +name: Build and stage +on: + push: + branches: + - main + pull_request: + branches: + - main +env: + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_VERSION: '8.0' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + checks: write + contents: read + statuses: write + +jobs: + build: + name: Build and publish app + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # avoid shallow clone so nbgv can do its work. + + - name: Set up .NET Core + uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + + - name: Set up dependency caching for faster builds + uses: actions/cache@v4 + with: + path: ~/.nuget/packages + key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} + restore-keys: | + ${{ runner.os }}-nuget- + + - name: dotnet restore + run: dotnet restore + + - name: dotnet build + run: dotnet build --no-restore /p:TreatWarningsAsErrors=True + + - name: dotnet test + run: dotnet test --logger trx --results-directory "${{ runner.temp }}" --no-build + + - name: dotnet test + uses: NasAmin/trx-parser@v0.5.0 + with: + TRX_PATH: "${{ runner.temp }}" + REPO_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + + - name: dotnet publish + run: dotnet publish src/NetCoreToolService/Steeltoe.NetCoreToolService.csproj -o publish + + - name: Upload artifact for deployment job + if: ${{ github.event_name != 'pull_request' }} + uses: actions/upload-artifact@v4 + with: + name: published-app + path: publish + + deploy: + name: Deploy + environment: production + needs: + - build + runs-on: ubuntu-latest + if: ${{ github.event_name != 'pull_request' }} + steps: + - name: Download artifact from build job + uses: actions/download-artifact@v4 + with: + name: published-app + + - name: Log into Azure CLI with service principal + uses: azure/login@v1 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + + - name: Deploy to Azure Web App + id: deploy-to-webapp + uses: azure/webapps-deploy@v3 + with: + app-name: ${{ vars.AZURE_WEBAPP_NAME }} + package: '.' + slot-name: 'production' diff --git a/Directory.Build.props b/Directory.Build.props index 13afc32..4b20913 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,13 +1,13 @@ - net6.0 + net8.0 false - 3.4.* + 3.6.* all diff --git a/Steeltoe.NetCoreToolService.sln b/Steeltoe.NetCoreToolService.sln index 73ee6cc..3515b13 100644 --- a/Steeltoe.NetCoreToolService.sln +++ b/Steeltoe.NetCoreToolService.sln @@ -1,7 +1,6 @@ - Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.6.30114.105 +# Visual Studio Version 17 +VisualStudioVersion = 17.9.34414.90 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{C742A7B8-80CA-4365-85CA-C29AA744CE54}" EndProject @@ -20,11 +19,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Directory.Build.props = Directory.Build.props docker-compose.yaml = docker-compose.yaml Dockerfile = Dockerfile - kubernetes.yaml = kubernetes.yaml stylecop.json = stylecop.json Version.props = Version.props - azure-pipelines.yaml = azure-pipelines.yaml - setversion.sh = setversion.sh EndProjectSection EndProject Global diff --git a/Version.props b/Version.props index 34e519c..0e92de6 100644 --- a/Version.props +++ b/Version.props @@ -5,20 +5,19 @@ - 5.0.* 3.2.* - 6.1.* + 6.5.0 1.3.* 2.9.* - 5.10.* - 5.5.* - 3.1.* - 16.7.* - 4.14.* - 2.4.* + 6.12.0 + 6.1.0 + 8.0.1 + 17.9.0 + 4.18.4 + 2.6.6 diff --git a/azure-pipelines.yaml b/azure-pipelines.yaml deleted file mode 100644 index 1de7312..0000000 --- a/azure-pipelines.yaml +++ /dev/null @@ -1,81 +0,0 @@ -trigger: -- main - -variables: -- name: DOTNET_SKIP_FIRST_TIME_EXPERIENCE - value: true -- name: DOTNET_CLI_TELEMETRY_OPTOUT - value: 1 - -stages: -- stage: assemble - displayName: Assemble - jobs: - - job: build - displayName: Build - pool: - vmImage: ubuntu-latest - steps: - - task: UseDotNet@2 - displayName: 'Use .NET Core SDK 6.0' - inputs: - packageType: sdk - version: 6.0.x - - task: DotNetCoreCLI@2 - displayName: dotnet restore - inputs: - command: restore - - task: DotNetCoreCLI@2 - displayName: dotnet build - inputs: - command: build - arguments: --no-restore /p:TreatWarningsAsErrors=True - - task: DotNetCoreCLI@2 - displayName: dotnet test - inputs: - command: test - arguments: --no-build -- stage: Deploy - displayName: Deploy - dependsOn: assemble - condition: - not(eq(variables['build.reason'], 'PullRequest')) - jobs: - - job: deploy - displayName: Deploy Docker Image - pool: - vmImage: ubuntu-latest - steps: - - task: Docker@2 - displayName: Build and Push Docker Image - inputs: - command: buildAndPush - containerRegistry: SteeltoeContainerRegistry - repository: net-core-tool-service - tags: | - $(Build.BuildId) - latest - - task: ShellScript@2 - displayName: Generate Staging Manifest - inputs: - scriptPath: ./yttw.sh - args: > - -f kubernetes - -v image_tag=$(Build.BuildId) - -v dotnet_environment=Staging - --output-files manifests/staging - - task: ShellScript@2 - displayName: Generate Production Manifest - inputs: - scriptPath: ./yttw.sh - args: > - -f kubernetes - -v image_tag=$(Build.BuildId) - -v replica_count=2 - -v dotnet_environment=Production - --output-files manifests/production - - task: PublishPipelineArtifact@1 - displayName: Publish Manifests - inputs: - targetPath: manifests - artifactName: manifests diff --git a/global.json b/global.json deleted file mode 100644 index 5a0ab4a..0000000 --- a/global.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "sdk": { - "version": "6.0.0", - "rollForward": "latestFeature" - } -} diff --git a/kubernetes/defaults.yaml b/kubernetes/defaults.yaml deleted file mode 100644 index 6a1c43c..0000000 --- a/kubernetes/defaults.yaml +++ /dev/null @@ -1,12 +0,0 @@ -#@data/values-schema -#@schema/type any=True ---- -name: net-core-tool-service -namespace: initializr -image_name: steeltoe.azurecr.io/net-core-tool-service -image_tag: latest -container_port: 80 -service_port: 80 -replica_count: 1 -dotnet_environment: Development -args: "" diff --git a/kubernetes/net-core-tool-service.yaml b/kubernetes/net-core-tool-service.yaml deleted file mode 100644 index afe6e5e..0000000 --- a/kubernetes/net-core-tool-service.yaml +++ /dev/null @@ -1,42 +0,0 @@ -#@ load("@ytt:data", "data") - ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: #@ data.values.name - namespace: #@ data.values.namespace -spec: - selector: - matchLabels: - app: #@ data.values.name - template: - metadata: - labels: - app: #@ data.values.name - spec: - nodeSelector: - "kubernetes.io/os": linux - containers: - - name: #@ data.values.name - image: #@ "{}:{}".format(data.values.image_name, data.values.image_tag) - ports: - - containerPort: #@ int(data.values.container_port) - #@ if/end data.values.args: - args: #@ data.values.args.split() - env: - - name: DOTNET_ENVIRONMENT - value: #@ data.values.dotnet_environment - replicas: #@ int(data.values.replica_count) ---- -apiVersion: v1 -kind: Service -metadata: - name: #@ data.values.name - namespace: #@ data.values.namespace -spec: - ports: - - port: #@ int(data.values.service_port) - targetPort: #@ int(data.values.container_port) - selector: - app: #@ data.values.name diff --git a/src/Directory.Build.props b/src/Directory.Build.props deleted file mode 100644 index 7becd19..0000000 --- a/src/Directory.Build.props +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - Steeltoe,VMware - true - true - true - $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb - true - - - - - - - - SA1101;SA1309;SA1402;SA1649 - - - - $(SteeltoeNetCoreToolServiceVersion) - $(BUILD_BUILDNUMBER) - - - - true - - - - - - All - - - - - diff --git a/src/NetCoreToolService/Controllers/NewController.cs b/src/NetCoreToolService/Controllers/NewController.cs index 15e7942..b0025dd 100644 --- a/src/NetCoreToolService/Controllers/NewController.cs +++ b/src/NetCoreToolService/Controllers/NewController.cs @@ -208,7 +208,7 @@ public async Task GetTemplateProject( var start = newCommand.Error.IndexOf(invalidOptionError, StringComparison.Ordinal) + invalidOptionError.Length; start = newCommand.Error.IndexOf("--", start, StringComparison.Ordinal) + "--".Length; - var end = newCommand.Error.IndexOf('\n', start); + var end = newCommand.Error.IndexOf(Environment.NewLine, start, StringComparison.Ordinal); return NotFound($"Switch '{newCommand.Error[start..end]}' not found."); } @@ -218,7 +218,7 @@ public async Task GetTemplateProject( var start = newCommand.Error.IndexOf(invalidSwitchError, StringComparison.Ordinal) + invalidSwitchError.Length; start = newCommand.Error.IndexOf("--", start, StringComparison.Ordinal) + "--".Length; - var end = newCommand.Error.IndexOf('\n', start); + var end = newCommand.Error.IndexOf(Environment.NewLine, start, StringComparison.Ordinal); return NotFound($"Switch '{newCommand.Error[start..end]}' not found."); } @@ -228,7 +228,7 @@ public async Task GetTemplateProject( var start = newCommand.Error.IndexOf(invalidParameterError, StringComparison.Ordinal) + invalidParameterError.Length; start = newCommand.Error.IndexOf("--", start, StringComparison.Ordinal) + "--".Length; - var end = newCommand.Error.IndexOf('\n', start); + var end = newCommand.Error.IndexOf(Environment.NewLine, start, StringComparison.Ordinal); var nvp = newCommand.Error[start..end].Split(' ', 2); return NotFound($"Option '{nvp[0]}' parameter '{nvp[1]}' not found."); } diff --git a/src/NetCoreToolService/Packagers/ZipPackager.cs b/src/NetCoreToolService/Packagers/ZipPackager.cs index ca2ac6e..3f07d2c 100644 --- a/src/NetCoreToolService/Packagers/ZipPackager.cs +++ b/src/NetCoreToolService/Packagers/ZipPackager.cs @@ -84,7 +84,7 @@ private void AddPathToArchive(ZipArchive archive, string rootPath, string path = var directory = new DirectoryInfo(path); if (path != rootPath) { - var entry = archive.CreateEntry($"{Path.GetRelativePath(rootPath, path)}/"); + var entry = archive.CreateEntry($"{Path.GetRelativePath(rootPath, path)}{Path.DirectorySeparatorChar}"); if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { entry.ExternalAttributes = UnixDirectoryPermissions; diff --git a/src/NetCoreToolService/Steeltoe.NetCoreToolService.csproj b/src/NetCoreToolService/Steeltoe.NetCoreToolService.csproj index ccdecde..15bc5f0 100644 --- a/src/NetCoreToolService/Steeltoe.NetCoreToolService.csproj +++ b/src/NetCoreToolService/Steeltoe.NetCoreToolService.csproj @@ -1,9 +1,36 @@ + + Steeltoe,VMware + true + true + true + $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb + true + + + + + + + + SA1101;SA1309;SA1402;SA1649 + $(SteeltoeNetCoreToolServiceVersion) + $(BUILD_BUILDNUMBER) + + + + true + + + + All + + diff --git a/src/NetCoreToolService/appsettings.Development.json b/src/NetCoreToolService/appsettings.Development.json index ce7c54c..792b794 100644 --- a/src/NetCoreToolService/appsettings.Development.json +++ b/src/NetCoreToolService/appsettings.Development.json @@ -4,5 +4,14 @@ "Steeltoe.Common.Utils": "Debug", "Steeltoe.NetCoreToolService": "Debug" } + }, + "Management": { + "Endpoints": { + "Actuator":{ + "Exposure": { + "Include": [ "*" ] + } + } + } } } diff --git a/src/NetCoreToolService/appsettings.json b/src/NetCoreToolService/appsettings.json index 19f1f19..4705473 100644 --- a/src/NetCoreToolService/appsettings.json +++ b/src/NetCoreToolService/appsettings.json @@ -6,14 +6,5 @@ "Microsoft.Hosting.Lifetime": "Information", "Steeltoe.NetCoreToolService": "Information" } - }, - "Management": { - "Endpoints": { - "Actuator":{ - "Exposure": { - "Include": [ "*" ] - } - } - } } } diff --git a/test/Directory.Build.props b/test/Directory.Build.props deleted file mode 100644 index 25a479b..0000000 --- a/test/Directory.Build.props +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - diff --git a/test/NetCoreToolService.Test/Packagers/ZipPackagerTests.cs b/test/NetCoreToolService.Test/Packagers/ZipPackagerTests.cs index 1587fd9..7ec63a1 100644 --- a/test/NetCoreToolService.Test/Packagers/ZipPackagerTests.cs +++ b/test/NetCoreToolService.Test/Packagers/ZipPackagerTests.cs @@ -50,11 +50,11 @@ public void ToStream_Should_Archive_File_Contents() using var entries = zip.Entries.GetEnumerator(); entries.MoveNext().Should().BeTrue(); Assert.NotNull(entries.Current); - entries.Current.FullName.Should().Be("d1/"); + entries.Current.FullName.Should().Be($"d1{Path.DirectorySeparatorChar}"); entries.MoveNext().Should().BeTrue(); Assert.NotNull(entries.Current); entries.Current.Name.Should().Be("f1"); - entries.Current.FullName.Should().Be("d1/f1"); + entries.Current.FullName.Should().Be($"d1{Path.DirectorySeparatorChar}f1"); using var reader = new StreamReader(entries.Current.Open()); reader.ReadToEnd().Should().Be("f1 stuff"); entries.MoveNext().Should().BeFalse(); @@ -79,12 +79,12 @@ public void ToStream_Should_Archive_Directories() using var entries = zip.Entries.GetEnumerator(); entries.MoveNext().Should().BeTrue(); Assert.NotNull(entries.Current); - entries.Current.FullName.Should().Be("d1/"); + entries.Current.FullName.Should().Be($"d1{Path.DirectorySeparatorChar}"); using var reader = new StreamReader(entries.Current.Open()); reader.ReadToEnd().Should().BeEmpty(); entries.MoveNext().Should().BeTrue(); Assert.NotNull(entries.Current); - entries.Current.FullName.Should().Be("d1/d2/"); + entries.Current.FullName.Should().Be($"d1{Path.DirectorySeparatorChar}d2{Path.DirectorySeparatorChar}"); entries.MoveNext().Should().BeFalse(); } diff --git a/test/NetCoreToolService.Test/Steeltoe.NetCoreToolService.Test.csproj b/test/NetCoreToolService.Test/Steeltoe.NetCoreToolService.Test.csproj index feb704f..d3596a4 100644 --- a/test/NetCoreToolService.Test/Steeltoe.NetCoreToolService.Test.csproj +++ b/test/NetCoreToolService.Test/Steeltoe.NetCoreToolService.Test.csproj @@ -1,13 +1,25 @@ - - Directory.Build.props - + - + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + diff --git a/tool.properties b/tool.properties deleted file mode 100644 index 19e80de..0000000 --- a/tool.properties +++ /dev/null @@ -1,2 +0,0 @@ -ytt_version=v0.36.0 -ytt_mirror=https://github.com/vmware-tanzu/carvel-ytt/releases/download diff --git a/yttw.sh b/yttw.sh deleted file mode 100755 index 669ec30..0000000 --- a/yttw.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash - -set -e - -# =========================================================================== # -# wrapper for ytt # -# =========================================================================== # - -base_dir=$(dirname $0) -ytt=$base_dir/tools/ytt - -if [ ! -x $ytt ]; then - ytt_version=$(grep '^ytt_version=' $base_dir/tool.properties | cut -d= -f2) - ytt_mirror=$(grep '^ytt_mirror=' $base_dir/tool.properties | cut -d= -f2) - case $(uname -s) in - Darwin) platform=darwin ;; - Linux) platform=linux ;; - *) - echo "unsupported platform: $(uname -s)" - exit 1 - ;; - esac - ytt_url=$ytt_mirror/$ytt_version/ytt-$platform-amd64 - mkdir -p $(dirname $ytt) - wget $ytt_url -O $ytt - chmod +x $ytt -fi - -exec $ytt $*