Skip to content

Commit

Permalink
[1ES] Add 1ES pipeline files (#10096)
Browse files Browse the repository at this point in the history
  • Loading branch information
jviau authored and brettsam committed Jun 20, 2024
1 parent 83ab0f8 commit c6422f3
Show file tree
Hide file tree
Showing 21 changed files with 915 additions and 22 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -497,4 +497,8 @@ local.settings.json
/tools/ExtensionsMetadataGenerator/packages
/tools/ExtensionsMetadataGenerator/src/ExtensionsMetadataGenerator/runtimeassemblies.txt
/tools/ExtensionsMetadataGenerator/test/ExtensionsMetadataGeneratorTests/runtimeAssemblies.txt
BenchmarkDotNet.Artifacts/

local.settings.json
msbuild.binlog
pp.xml
BenchmarkDotNet.Artifacts/
1 change: 1 addition & 0 deletions .sscignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "cfs": [ "CFS0001", "CFS0013", "CFS0031" ] }
7 changes: 7 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
<Project>

<!-- artifacts -->
<PropertyGroup>
<ArtifactsPath>$(MSBuildThisFileDirectory)out</ArtifactsPath>
<ArtifactsPublishOutputName>pub</ArtifactsPublishOutputName>
<ArtifactsPackageOutputName>pkg</ArtifactsPackageOutputName>
</PropertyGroup>

<!-- paths -->
<PropertyGroup>
<RepoRoot>$(MSBuildThisFileDirectory)</RepoRoot>
<EngRoot>$(RepoRoot)eng/</EngRoot>
</PropertyGroup>

</Project>
5 changes: 5 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project>

<Import Project="$(EngRoot)build/Engineering.targets" />

</Project>
2 changes: 1 addition & 1 deletion build/Get-AzureFunctionsVersion.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ function Get-AzureFunctionsVersion {
$version = (& dotnet $cmd).Trim()

return $version
}
}
2 changes: 1 addition & 1 deletion build/check-vulnerabilities.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ if (!$result)
{
Write-Host "Vulnerabilities found"
Exit 1
}
}
4 changes: 0 additions & 4 deletions build/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@
<Message Importance="high" Text="$(Version)" />
</Target>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/>
</ItemGroup>

<ItemGroup>
<AdditionalFiles Include="$(MSBuildThisFileDirectory)..\stylecop.json" Link="stylecop.json" />
</ItemGroup>
Expand Down
22 changes: 13 additions & 9 deletions build/initialize-pipeline.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ param (

$buildReason = $env:BUILD_REASON
$sourceBranch = $env:BUILD_SOURCEBRANCH
$provider = $env:BUILD_REPOSITORY_PROVIDER

Write-Host "BUILD_REASON: '$buildReason'"
Write-Host "BUILD_SOURCEBRANCH: '$sourceBranch'"
Expand All @@ -15,15 +16,18 @@ if ($buildReason -eq "PullRequest") {
# This often gets rate limited, so it isn't reliable.

$pack = $false
try {
$response = Invoke-RestMethod api.github.com/repos/$env:BUILD_REPOSITORY_ID/pulls/$env:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER
$title = $response.title.ToLowerInvariant()
Write-Host "Pull request '$title'"
$pack = $title.Contains("[pack]")
}
catch {
Write-Warning "Failed to get pull request title."
Write-Warning $_

if ($provider -eq "GitHub") {
try {
$response = Invoke-RestMethod api.github.com/repos/$env:BUILD_REPOSITORY_ID/pulls/$env:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER
$title = $response.title.ToLowerInvariant()
Write-Host "Pull request '$title'"
$pack = $title.Contains("[pack]")
}
catch {
Write-Warning "Failed to get pull request title."
Write-Warning $_
}
}

# Next we check if the commit message contains '--pack'
Expand Down
5 changes: 5 additions & 0 deletions eng/build/Engineering.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project>

<Import Project="$(MSBuildThisFileDirectory)RepositoryInfo.targets" />

</Project>
35 changes: 35 additions & 0 deletions eng/build/RepositoryInfo.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<Project>

<!--
The convention for names of Azure DevOps repositories mirrored from GitHub is "{GitHub org name}.{GitHub repository name}".
-->
<PropertyGroup>
<!-- There are quite a few git repo forms:
https://azfunc@dev.azure.com/azfunc/internal/_git/azure.azure-functions-host
https://dev.azure.com/azfunc/internal/_git/azure.azure-functions-host
https://azfunc.visualstudio.com/internal/_git/azure.azure-functions-host
azfunc@vs-ssh.visualstudio.com:v3/azfunc/internal/azure.azure-functions-host
git@ssh.dev.azure.com:v3/azfunc/internal/azure.azure-functions-host
-->
<!-- Set DisableSourceLinkUrlTranslation to true when building a tool for internal use where sources only come from internal URIs -->
<DisableSourceLinkUrlTranslation Condition="'$(DisableSourceLinkUrlTranslation)' == ''">false</DisableSourceLinkUrlTranslation>
<_TranslateUrlPattern>(https://azfunc%40dev\.azure\.com/azfunc/internal/_git|https://dev\.azure\.com/azfunc/internal/_git|https://azfunc\.visualstudio\.com/internal/_git|azfunc%40vs-ssh\.visualstudio\.com:v3/azfunc/internal|git%40ssh\.dev\.azure\.com:v3/azfunc/internal)/([^/\.]+)\.(.+)</_TranslateUrlPattern>
<_TranslateUrlReplacement>https://github.com/$2/$3</_TranslateUrlReplacement>
</PropertyGroup>

<!-- When building from Azure Devops we update SourceLink to point back to the GitHub repo. -->
<Target Name="_TranslateAzureDevOpsUrlToGitHubUrl"
Condition="'$(DisableSourceLinkUrlTranslation)' == 'false'"
DependsOnTargets="$(SourceControlManagerUrlTranslationTargets)"
BeforeTargets="SourceControlManagerPublishTranslatedUrls">
<PropertyGroup>
<ScmRepositoryUrl>$([System.Text.RegularExpressions.Regex]::Replace($(ScmRepositoryUrl), $(_TranslateUrlPattern), $(_TranslateUrlReplacement)))</ScmRepositoryUrl>
</PropertyGroup>
<ItemGroup>
<SourceRoot Update="@(SourceRoot)">
<ScmRepositoryUrl>$([System.Text.RegularExpressions.Regex]::Replace(%(SourceRoot.ScmRepositoryUrl), $(_TranslateUrlPattern), $(_TranslateUrlReplacement)))</ScmRepositoryUrl>
</SourceRoot>
</ItemGroup>
</Target>

</Project>
36 changes: 36 additions & 0 deletions eng/ci/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
variables:
DOTNET_NOLOGO: 1
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_CLI_TELEMETRY_OPTOUT: 1

pr:
branches:
include:
- dev
- in-proc
- release/4.*
- release/inproc6/4.*
- release/inproc8/4.*

resources:
repositories:
- repository: 1es
type: git
name: 1ESPipelineTemplates/1ESPipelineTemplates
ref: refs/tags/release

extends:
template: v1/1ES.Unofficial.PipelineTemplate.yml@1es
parameters:
pool:
name: 1es-pool-azfunc
image: 1es-windows-2022
os: windows

stages:
- stage: Test
jobs:

- template: /eng/ci/templates/jobs/initialize-pipeline.yml@self
- template: /eng/ci/templates/official/jobs/run-non-e2e-tests.yml@self
- template: /eng/ci/templates/official/jobs/run-integration-tests.yml@self
67 changes: 67 additions & 0 deletions eng/ci/official-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@


trigger:
batch: true
branches:
include:
- dev
- in-proc
- release/4.*
- release/inproc6/4.*
- release/inproc8/4.*

# CI only, does not trigger on PRs.
pr: none

resources:
repositories:
- repository: 1es
type: git
name: 1ESPipelineTemplates/1ESPipelineTemplates
ref: refs/tags/release
- repository: eng
type: git
name: engineering
ref: refs/tags/release

variables:
- template: ci/variables/build.yml@eng
- template: ci/variables/cfs.yml@eng
- name: buildNumber
value: $[ counter('build', 23000) ] # 23000 selected to be ahead of current host build
- name: minorVersionPrefix
${{ if contains(variables['Build.SourceBranch'], 'release/inproc6/') }}:
value: "6"
${{ elseif contains(variables['Build.SourceBranch'], 'release/inproc8/') }}:
value: "8"
${{ else }}:
value: ""

extends:
template: v1/1ES.Official.PipelineTemplate.yml@1es
parameters:
pool:
name: 1es-pool-azfunc
image: 1es-windows-2022
os: windows

stages:
- stage: Initialize

jobs:
- template: /eng/ci/templates/jobs/initialize-pipeline.yml@self

- stage: Build
dependsOn: Initialize

jobs:
- template: /eng/ci/templates/official/jobs/build-artifacts-windows.yml@self
- template: /eng/ci/templates/official/jobs/build-artifacts-linux.yml@self

- stage: Test
dependsOn: Initialize

jobs:
- template: /eng/ci/templates/jobs/run-unit-tests.yml@self
- template: /eng/ci/templates/official/jobs/run-non-e2e-tests.yml@self
- template: /eng/ci/templates/official/jobs/run-integration-tests.yml@self
59 changes: 59 additions & 0 deletions eng/ci/public-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# This build is used for public PR and CI builds.

variables:
buildNumber: $[ counter('build', 23000) ] # 23000 selected to be ahead of current host build
${{ if contains(variables['Build.SourceBranch'], 'release/inproc6/') }}:
minorVersionPrefix: "6"
${{ elseif contains(variables['Build.SourceBranch'], 'release/inproc8/') }}:
minorVersionPrefix: "8"
${{ else }}:
minorVersionPrefix: ""
DOTNET_NOLOGO: 1
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_CLI_TELEMETRY_OPTOUT: 1

trigger:
batch: true
branches:
include:
- dev
- in-proc
- release/4.*
- release/inproc6/4.*
- release/inproc8/4.*

pr:
branches:
include:
- dev
- in-proc
- release/4.*
- release/inproc6/4.*
- release/inproc8/4.*

resources:
repositories:
- repository: 1es
type: git
name: 1ESPipelineTemplates/1ESPipelineTemplates
ref: refs/tags/release

extends:
template: v1/1ES.Unofficial.PipelineTemplate.yml@1es
parameters:
pool:
name: 1es-pool-azfunc-public
image: 1es-windows-2022
os: windows

stages:
- stage: Initialize

jobs:
- template: /eng/ci/templates/jobs/initialize-pipeline.yml@self

- stage: Test
dependsOn: Initialize

jobs:
- template: /eng/ci/templates/jobs/run-unit-tests.yml@self
19 changes: 19 additions & 0 deletions eng/ci/templates/install-dotnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
steps:

- task: UseDotNet@2 # Needed by some of our test resources
displayName: Install .NET 3.1
inputs:
packageType: sdk
version: 3.1.x

- task: UseDotNet@2 # Needed by our projects and CI steps
displayName: Install .NET 6
inputs:
packageType: sdk
version: 6.x

- task: UseDotNet@2 # The pinned SDK we use to build
displayName: Install .NET SDK from global.json
inputs:
packageType: sdk
useGlobalJson: true
19 changes: 19 additions & 0 deletions eng/ci/templates/jobs/initialize-pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
jobs:
- job: InitializePipeline
displayName: Initialize Pipeline

steps:
- task: UseDotNet@2 # The pinned SDK we use to build
displayName: 'Install .NET SDK from global.json'
inputs:
packageType: sdk
useGlobalJson: true

- task: PowerShell@2
displayName: 'Initialize'
name: Initialize
inputs:
filePath: build/initialize-pipeline.ps1
arguments: -minorVersionPrefix "$(minorVersionPrefix)"
showWarnings: true
pwsh: true
24 changes: 24 additions & 0 deletions eng/ci/templates/jobs/run-unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
jobs:
- job: RunUnitTests
displayName: Run Unit Tests

pool:
name: 1es-pool-azfunc
image: 1es-windows-2022
os: windows

steps:
- task: NuGetAuthenticate@1
displayName: NuGet Authenticate

- template: /eng/ci/templates/install-dotnet.yml@self

- task: DotNetCoreCLI@2
displayName: Unit Tests
inputs:
command: test
testRunTitle: Unit Tests
arguments: -v n
projects: |
**\ExtensionsMetadataGeneratorTests.csproj
**\WebJobs.Script.Tests.csproj
Loading

0 comments on commit c6422f3

Please sign in to comment.