* move to gha, package and x-plat updates
This commit is contained in:
Tim Hess 2024-02-07 14:05:29 -06:00 коммит произвёл GitHub
Родитель 9643ce7953
Коммит 15ab821988
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
19 изменённых файлов: 167 добавлений и 273 удалений

94
.github/workflows/build-and-stage.yml поставляемый Normal file
Просмотреть файл

@ -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'

Просмотреть файл

@ -1,13 +1,13 @@
<Project>
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning" Condition="!Exists('packages.config')">
<Version>3.4.*</Version>
<Version>3.6.*</Version>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

Просмотреть файл

@ -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

Просмотреть файл

@ -5,20 +5,19 @@
</PropertyGroup>
<PropertyGroup>
<MicrosoftExtensionsVersion>5.0.*</MicrosoftExtensionsVersion>
<SteeltoeVersion>3.2.*</SteeltoeVersion>
<SwashbuckleVersion>6.1.*</SwashbuckleVersion>
<SwashbuckleVersion>6.5.0</SwashbuckleVersion>
</PropertyGroup>
<PropertyGroup>
<CoverletCollectorVersion>1.3.*</CoverletCollectorVersion>
<CoverletMsBuildVersion>2.9.*</CoverletMsBuildVersion>
<FluentAssertionsVersion>5.10.*</FluentAssertionsVersion>
<FluentAssertionsJsonVersion>5.5.*</FluentAssertionsJsonVersion>
<MicrosoftAspNetCoreMvcTestingVersion>3.1.*</MicrosoftAspNetCoreMvcTestingVersion>
<MicrosoftNetTestSdkVersion>16.7.*</MicrosoftNetTestSdkVersion>
<MoqVersion>4.14.*</MoqVersion>
<XunitVersion>2.4.*</XunitVersion>
<FluentAssertionsVersion>6.12.0</FluentAssertionsVersion>
<FluentAssertionsJsonVersion>6.1.0</FluentAssertionsJsonVersion>
<MicrosoftAspNetCoreMvcTestingVersion>8.0.1</MicrosoftAspNetCoreMvcTestingVersion>
<MicrosoftNetTestSdkVersion>17.9.0</MicrosoftNetTestSdkVersion>
<MoqVersion>4.18.4</MoqVersion>
<XunitVersion>2.6.6</XunitVersion>
</PropertyGroup>
</Project>

Просмотреть файл

@ -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

Просмотреть файл

@ -1,6 +0,0 @@
{
"sdk": {
"version": "6.0.0",
"rollForward": "latestFeature"
}
}

Просмотреть файл

@ -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: ""

Просмотреть файл

@ -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

Просмотреть файл

@ -1,39 +0,0 @@
<Project>
<Import Project="..\Directory.Build.props" />
<PropertyGroup>
<Authors>Steeltoe,VMware</Authors>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IncludeSymbols>true</IncludeSymbols>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup>
<!-- SA1101: Prefix local calls with this -->
<!-- SA1309: Field '...' should not begin with an underscore -->
<!-- SA1402: File may only contain a single type -->
<!-- SA1649: File name should match first type name -->
<NoWarn>SA1101;SA1309;SA1402;SA1649</NoWarn>
</PropertyGroup>
<PropertyGroup>
<Version Condition=" '$(BUILD_BUILDNUMBER)' == '' ">$(SteeltoeNetCoreToolServiceVersion)</Version>
<Version Condition=" '$(BUILD_BUILDNUMBER)' != '' ">$(BUILD_BUILDNUMBER)</Version>
</PropertyGroup>
<PropertyGroup Condition="'$(TF_BUILD)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<AdditionalFiles Include="$(MSBuildThisFileDirectory)\..\stylecop.json" />
</ItemGroup>
</Project>

Просмотреть файл

@ -208,7 +208,7 @@ namespace Steeltoe.NetCoreToolService.Controllers
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 @@ namespace Steeltoe.NetCoreToolService.Controllers
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 @@ namespace Steeltoe.NetCoreToolService.Controllers
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.");
}

Просмотреть файл

@ -84,7 +84,7 @@ namespace Steeltoe.NetCoreToolService.Packagers
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;

Просмотреть файл

@ -1,9 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<Authors>Steeltoe,VMware</Authors>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IncludeSymbols>true</IncludeSymbols>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup>
<!-- SA1101: Prefix local calls with this -->
<!-- SA1309: Field '...' should not begin with an underscore -->
<!-- SA1402: File may only contain a single type -->
<!-- SA1649: File name should match first type name -->
<NoWarn>SA1101;SA1309;SA1402;SA1649</NoWarn>
<Version Condition=" '$(BUILD_BUILDNUMBER)' == '' ">$(SteeltoeNetCoreToolServiceVersion)</Version>
<Version Condition=" '$(BUILD_BUILDNUMBER)' != '' ">$(BUILD_BUILDNUMBER)</Version>
</PropertyGroup>
<PropertyGroup Condition="'$(CI)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Steeltoe.Management.EndpointCore" Version="$(SteeltoeVersion)" />
<PackageReference Include="Steeltoe.Common.Utils" Version="$(SteeltoeVersion)" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="$(SwashbuckleVersion)" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<AdditionalFiles Include="$(MSBuildThisFileDirectory)\..\..\stylecop.json" />
</ItemGroup>
</Project>

Просмотреть файл

@ -4,5 +4,14 @@
"Steeltoe.Common.Utils": "Debug",
"Steeltoe.NetCoreToolService": "Debug"
}
},
"Management": {
"Endpoints": {
"Actuator":{
"Exposure": {
"Include": [ "*" ]
}
}
}
}
}

Просмотреть файл

@ -6,14 +6,5 @@
"Microsoft.Hosting.Lifetime": "Information",
"Steeltoe.NetCoreToolService": "Information"
}
},
"Management": {
"Endpoints": {
"Actuator":{
"Exposure": {
"Include": [ "*" ]
}
}
}
}
}

Просмотреть файл

@ -1,23 +0,0 @@
<Project>
<Import Project="..\Directory.Build.props" />
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="$(CoverletCollectorVersion)">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.msbuild" Version="$(CoverletMsBuildVersion)" />
<PackageReference Include="FluentAssertions" Version="$(FluentAssertionsVersion)" />
<PackageReference Include="FluentAssertions.Json" Version="$(FluentAssertionsJsonVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="$(MicrosoftAspNetCoreMvcTestingVersion)" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNetTestSdkVersion)" />
<PackageReference Include="Moq" Version="$(MoqVersion)" />
<PackageReference Include="xunit" Version="$(XunitVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitVersion)">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>

Просмотреть файл

@ -50,11 +50,11 @@ namespace Steeltoe.NetCoreToolService.Test.Packagers
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 @@ namespace Steeltoe.NetCoreToolService.Test.Packagers
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();
}

Просмотреть файл

@ -1,13 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<Content Include="..\Directory.Build.props">
<Link>Directory.Build.props</Link>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\NetCoreToolService\Steeltoe.NetCoreToolService.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="$(CoverletCollectorVersion)">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.msbuild" Version="$(CoverletMsBuildVersion)" />
<PackageReference Include="FluentAssertions" Version="$(FluentAssertionsVersion)" />
<PackageReference Include="FluentAssertions.Json" Version="$(FluentAssertionsJsonVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="$(MicrosoftAspNetCoreMvcTestingVersion)" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNetTestSdkVersion)" />
<PackageReference Include="Moq" Version="$(MoqVersion)" />
<PackageReference Include="xunit" Version="$(XunitVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>

Просмотреть файл

@ -1,2 +0,0 @@
ytt_version=v0.36.0
ytt_mirror=https://github.com/vmware-tanzu/carvel-ytt/releases/download

29
yttw.sh
Просмотреть файл

@ -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 $*