Skip to content

Commit

Permalink
[v1.x] Add 1ES CI pipelines (#10211)
Browse files Browse the repository at this point in the history
* Add 1ES CI to v1.x

* Fix nuget.config

* Fix nuget.config

* update build_number

* Split v1 build into official/public/test

* Extra variables to template

* Add release/1.* to triggers

* Remove eng resource from public

* Fix public pool

* Replace secret with 'PLACEHOLDER'

* Add all env vars for tests

* Do not run tests on public ci

* Add eng resource to integration-tests.yml

* Fix missing job

* Fix filter

* Fix runtests.ps1

* Skip strong names for tests
  • Loading branch information
jviau authored Jun 27, 2024
1 parent a4d77d2 commit 465f692
Show file tree
Hide file tree
Showing 10 changed files with 289 additions and 5 deletions.
7 changes: 4 additions & 3 deletions .nuget/NuGet.Config
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
<add key="azure_app_service" value="https://www.myget.org/F/azure-appservice/api/v2" />
<add key="buildTools" value="https://www.myget.org/F/30de4ee06dd54956a82013fa17a3accb/" />
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="v1-tools" value="https://pkgs.dev.azure.com/azfunc/e6a70c92-4128-439f-8012-382fe78d6396/_packaging/v1-tools/nuget/v3/index.json" />
<add key="azure-app-service" value="https://pkgs.dev.azure.com/azfunc/e6a70c92-4128-439f-8012-382fe78d6396/_packaging/myget-backup-azure-app-service/nuget/v3/index.json" />
</packageSources>
</configuration>
24 changes: 24 additions & 0 deletions eng/ci/code-mirror.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
trigger:
branches:
include:
- dev
- in-proc
- v1.x
- v3.x
- release/1.*
- release/3.*
- release/4.*
- release/in-proc

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

variables:
- template: ci/variables/cfs.yml@eng

extends:
template: ci/code-mirror.yml@eng
45 changes: 45 additions & 0 deletions eng/ci/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
trigger: none

pr:
branches:
include:
- v1.x
- release/1.*

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/cfs.yml@eng
- template: /eng/ci/templates/variables/build.yml@self

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

stages:
- stage: Test
jobs:
- job: Test
steps:
- template: /eng/ci/templates/steps/build.yml@self
parameters:
configuration: $(configuration)
targets: EnableSkipStrongNames;TestBuild

- template: /eng/ci/templates/steps/test.yml@self
parameters:
configuration: $(configuration)
results_path: $(test_results_path)
53 changes: 53 additions & 0 deletions eng/ci/official-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
trigger:
branches:
include:
- v1.x
- release/1.*

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/cfs.yml@eng
- template: /eng/ci/templates/variables/build.yml@self

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

stages:
- stage: BuildAndTest

jobs:
- job: BuildAndTest
templateContext:
outputParentDirectory: $(publish_path)
outputs:
- output: pipelineArtifact
displayName: Publish drop
path: $(publish_path)/Packages
artifact: drop

steps:
- template: /eng/ci/templates/steps/build.yml@self
parameters:
configuration: $(configuration)
publish_path: $(publish_path)
build_number: $(build_number)

- template: /eng/ci/templates/steps/test.yml@self
parameters:
configuration: $(configuration)
results_path: $(test_results_path)
49 changes: 49 additions & 0 deletions eng/ci/public-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
trigger:
branches:
include:
- v1.x
- release/1.*

pr:
branches:
include:
- v1.x
- release/1.*

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

variables:
- template: /eng/ci/templates/variables/build.yml@self

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

stages:
- stage: Build

jobs:
- job: Build
templateContext:
outputParentDirectory: $(publish_path)
outputs:
- output: pipelineArtifact
displayName: Publish drop
path: $(publish_path)/Packages
artifact: drop

steps:
- template: /eng/ci/templates/steps/build.yml@self
parameters:
configuration: $(configuration)
publish_path: $(publish_path)
build_number: $(build_number)
20 changes: 20 additions & 0 deletions eng/ci/templates/steps/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
parameters:
- name: configuration
type: string
default: Release
- name: publish_path
type: string
default: bin
- name: build_number
type: string
default: '4242'
- name: targets
type: string
default: EnableSkipStrongNames;PackageScriptHost;PackageWebHost;TestBuild

steps:
- task: MSBuild@1
inputs:
solution: WebJobs.Script.proj
msbuildArguments: '/target:${{ parameters.targets }} /property:BuildNumber=${{ parameters.build_number }};Configuration=${{ parameters.configuration }};PublishPath=${{ parameters.publish_path }}'
logFileVerbosity: minimal
75 changes: 75 additions & 0 deletions eng/ci/templates/steps/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
parameters:
- name: configuration
type: string
default: Release
- name: results_path
type: string
default: $(System.DefaultWorkingDirectory)/test-results

steps:
- ${{ if ne(variables['System.TeamProject'], 'internal') }}:
- pwsh: |
Write-Host "##vso[task.LogIssue type=error;]Tests cannot be ran in this Azure Devops project."
exit 1
displayName: Fail invalid project
- ${{ else }}:
- task: AzureKeyVault@1
inputs:
# Note: This is actually a Service Connection in DevOps, not an Azure subscription name
azureSubscription: Azure-Functions-Host-CI-internal
keyVaultName: azurefunctionshostciv1
secretsFilter: '*'

- task: UseNode@1
displayName: Install Node 6.11.2
inputs:
version: '6.11.2'

- pwsh: .\runtests.ps1 -ResultsPath ${{ parameters.results_path }} -Configuration ${{ parameters.configuration }}
displayName: Run tests
env:
# many of these will be empty if running unit tests, which is fine.
AzureWebJobsStorage: $(Storage)
AzureWebJobsDashboard: $(Storage)
AzureWebJobsServiceBus: $(ServiceBus)
AzureWebJobsDocumentDBConnectionString: $(CosmosDB)
AzureWebJobsMobileAppUri: $(MobileUri)
AzureWebJobs_TestMobileUri: $(MobileUri)
AzureWebJobsDropBox: UseLocalFileSystem=true;Path=%TEMP%\DropBox
AzureWebJobsEventHubSender: $(EventHub)
AzureWebJobsEventHubReceiver: $(EventHub)
AzureWebJobsEventHubPath: testhub
AzureWebJobsNotificationHubsConnectionString: $(NotificationHub)
AzureWebJobsNotificationHubName: testhub
AzureWebJobsEnv: Development
AzureWebJobsScriptRoot: $(System.DefaultWorkingDirectory)\test\WebJobs.Script.Tests.Integration\TestScripts\Empty
AzureWebJobsCosmosDBConnectionString: $(CosmosDB)
AzureWebJobsSecretStorageKeyVaultName: $(KeyVaultName)
AzureWebJobsSecretStorageKeyVaultConnectionString: $(KeyVaultConnectionString)
ConnectionStrings__CosmosDB: $(CosmosDB2)
FILES_ACCOUNT_NAME: $(FilesAccountName)
FILES_ACCOUNT_KEY: $(FilesAccountKey)
MOCHA_FILE: ${{ parameters.results_path }}/junit-test-results.xml
TMP: $(Agent.TempDirectory)

- task: PublishTestResults@2
displayName: Publish XUnit test results
inputs:
testResultsFormat: XUnit
testResultsFiles: ${{ parameters.results_path }}/xunit-*.xml
mergeTestResults: true
buildConfiguration: $(configuration)
testRunTitle: XUnit Tests
condition: always()


- task: PublishTestResults@2
displayName: Publish JUnit test results
inputs:
testResultsFormat: JUnit
testResultsFiles: ${{ parameters.results_path }}/junit-*.xml
mergeTestResults: true
buildConfiguration: $(configuration)
testRunTitle: JUnit Tests
condition: always()
17 changes: 17 additions & 0 deletions eng/ci/templates/variables/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
variables:
- name: DOTNET_NOLOGO
value: 1
- name: DOTNET_SKIP_FIRST_TIME_EXPERIENCE
value: 1
- name: DOTNET_CLI_TELEMETRY_OPTOUT
value: 1
- name: build_number
value: $[ counter('constant-v1x', 23000) ]
- name: includeBuildNumberInVersion
value: 1
- name: configuration
value: Release
- name: publish_path
value: bin
- name: test_results_path
value: $(System.DefaultWorkingDirectory)\test-results
2 changes: 1 addition & 1 deletion src/Common/CommonAssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System;
Expand Down
2 changes: 1 addition & 1 deletion test/WebJobs.Script.Tests/Security/SecretManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ public async Task AddOrUpdateFunctionSecrets_WithScope_UsesSecretandPersistsHost
[Fact]
public async Task SetMasterKey_WithProvidedKey_UsesProvidedKeyAndPersistsFile()
{
string testSecret = "abcde0123456789abcde0123456789abcde0123456789";
string testSecret = "PLACEHOLDER";
using (var directory = new TempDirectory())
{
string expectedTraceMessage = "Master key Updated";
Expand Down

0 comments on commit 465f692

Please sign in to comment.