From ac5474b5c318b7f33a05bb379feda88f9ecce3be Mon Sep 17 00:00:00 2001 From: AMER JUSUPOVIC Date: Thu, 25 Jul 2024 10:20:24 -0700 Subject: [PATCH 1/3] add github workflow ci.yml, remove old pipelines --- .github/workflows/ci.yml | 53 +++++++++ .pipelines/OneBranch.Official.yml | 175 ------------------------------ .pipelines/windows-buddy.yml | 125 --------------------- 3 files changed, 53 insertions(+), 300 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .pipelines/OneBranch.Official.yml delete mode 100644 .pipelines/windows-buddy.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..3701da6c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,53 @@ +name: FeatureManagement-Dotnet CI + +on: + push: + branches: + - main + - preview + - release/* + pull_request: + branches: + - main + - preview + - release/* + +permissions: + security-events: write + +jobs: + build: + runs-on: windows-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install .NET + run: pwsh build/install-dotnet.ps1 -RestoreOnly + + - name: Restore + run: pwsh build.ps1 -RestoreOnly + + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: 'csharp' + + - name: Dotnet Build + run: pwsh build.ps1 + + - name: Dotnet Pack + run: pwsh pack.ps1 + + - name: Dotnet Test + run: pwsh test.ps1 + + - name: Publish Test Results + uses: actions/upload-artifact@v4 + with: + name: Unit Test Results + path: ${{ github.workspace }}/tests/**/*.trx + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 diff --git a/.pipelines/OneBranch.Official.yml b/.pipelines/OneBranch.Official.yml deleted file mode 100644 index 15c44d0e..00000000 --- a/.pipelines/OneBranch.Official.yml +++ /dev/null @@ -1,175 +0,0 @@ -trigger: none - -parameters: # parameters are shown up in ADO UI in a build queue time -- name: 'debug' - displayName: 'Enable debug output' - type: boolean - default: false - -variables: - CDP_DEFINITION_BUILD_COUNT: $[counter('', 0)] # needed for onebranch.pipeline.version task - system.debug: ${{ parameters.debug }} - ENABLE_PRS_DELAYSIGN: 1 - ROOT: $(Build.SourcesDirectory) - REPOROOT: $(Build.SourcesDirectory) - OUTPUTROOT: $(REPOROOT)\out - CDP_USER_SOURCE_FOLDER_CONTAINER_PATH: $(Build.SourcesDirectory) - CDP_DEFINITION_BUILD_COUNT_DAY: $[counter(format('{0:yyyyMMdd}', pipeline.startTime), 1)] - CDP_DEFINITION_BUILD_COUNT_MONTH: $[counter(format('{0:yyyyMM}', pipeline.startTime), 1)] - CDP_DEFINITION_BUILD_COUNT_YEAR: $[counter(format('{0:yyyy}', pipeline.startTime), 1)] - NUGET_XMLDOC_MODE: none - - # Docker image which is used to build the project - WindowsContainerImage: 'onebranch.azurecr.io/windows/ltsc2019/vse2022:latest' - -resources: - repositories: - - repository: templates - type: git - name: OneBranch.Pipelines/GovernedTemplates - ref: refs/heads/main - -extends: - template: v2/OneBranch.Official.CrossPlat.yml@templates - parameters: - cloudvault: - enabled: false - globalSdl: - tsa: - enabled: false # onebranch publish all sdl results to TSA. If TSA is disabled all SDL tools will forced into 'break' build mode. - # credscan: - # suppressionsFile: $(Build.SourcesDirectory)\.config\CredScanSuppressions.json - binskim: - break: true # always break the build on binskim issues in addition to TSA upload - policheck: - break: true # always break the build on policheck issues. You can disable it by setting to 'false' - # baseline: - # baselineFile: $(Build.SourcesDirectory)\.gdn\global.gdnbaselines - cg: - failOnAlert: false - - stages: - - stage: build - jobs: - - job: main - pool: - type: windows - - variables: - ob_outputDirectory: '$(REPOROOT)\out' # this directory is uploaded to pipeline artifacts, reddog and cloudvault - ob_sdl_binskim_break: true - ${{ if eq(variables['Build.SourceBranch'], 'refs/heads/master') }}: # conditionally enable symbolsPublishing for master branch only - ob_symbolsPublishing_enabled: true - # ob_sdl_baseline_baselineFile: $(Build.SourcesDirectory)\.gdn\build.official.gdnbaselines - # ob_sdl_codeSignValidation_excludes: -|**\*.js # Example -|**\*.js;-|**\Test*\** - ob_artifactBaseName: 'drop' - ob_sdl_cg_failOnAlert: false - - steps: - - task: CmdLine@2 - displayName: 'Install .NET' - inputs: - script: $(Build.SourcesDirectory)\build\CallPowerShell.cmd build/install-dotnet.ps1 -RestoreOnly - workingDirectory: '$(Build.SourcesDirectory)' - - - task: CmdLine@2 - displayName: 'Restore' - inputs: - script: $(Build.SourcesDirectory)\build\CallPowerShell.cmd build.ps1 -RestoreOnly - workingDirectory: '$(Build.SourcesDirectory)' - - - task: onebranch.pipeline.version@1 # generates automatic version - displayName: 'Setup BuildNumber' - inputs: - system: 'BuildRevision' - major: '1' - minor: '0' - name: 'FeatureManagement-Dotnet' - # exclude_commit: true - - - - - task: CmdLine@2 - displayName: 'Dotnet Build' - inputs: - script: $(Build.SourcesDirectory)\build\CallPowerShell.cmd build.ps1 - workingDirectory: '$(Build.SourcesDirectory)' - - - task: CopyFiles@2 - inputs: - SourceFolder: '$(Build.SourcesDirectory)\buildlogs' - Contents: | - **/* - TargetFolder: '$(Build.SourcesDirectory)\out\outputs\build\Build Logs' - - - - - task: onebranch.pipeline.signing@1 - displayName: 'Signing' - inputs: - command: 'sign' - signing_environment: 'azure-ado' - signing_profile: 'external_distribution ' - files_to_sign: '*/bin/Release/**/*' - search_root: '$(Build.SourcesDirectory)\src' - - - - task: CopyFiles@2 - inputs: - SourceFolder: '$(Build.SourcesDirectory)\src' - Contents: | - */bin/Release/**/* - TargetFolder: '$(Build.SourcesDirectory)\out\outputs\build\Binaries' - - - task: CmdLine@2 - displayName: 'Dotnet Pack' - inputs: - script: $(Build.SourcesDirectory)\build\CallPowerShell.cmd pack.ps1 - workingDirectory: '$(Build.SourcesDirectory)' - - - task: CopyFiles@2 - inputs: - SourceFolder: '$(Build.SourcesDirectory)\buildlogs' - Contents: | - **/* - TargetFolder: '$(Build.SourcesDirectory)\out\outputs\package\Build Logs' - - - - - task: onebranch.pipeline.signing@1 - displayName: 'Signing' - inputs: - command: 'sign' - signing_environment: 'azure-ado' - signing_profile: 'external_distribution ' - files_to_sign: '*/bin/PackageOutput/**/*.nupkg' - search_root: '$(Build.SourcesDirectory)\src' - - - - task: CopyFiles@2 - inputs: - SourceFolder: '$(Build.SourcesDirectory)\src' - Contents: | - */bin/PackageOutput/**/*.nupkg - TargetFolder: '$(Build.SourcesDirectory)\out\outputs\package\Packages' - - - task: CmdLine@2 - displayName: 'Dotnet Test' - inputs: - script: '$(Build.SourcesDirectory)\build/CallPowerShell.cmd test.ps1|| exit /b 0' - workingDirectory: '$(Build.SourcesDirectory)' - - - task: CopyFiles@2 - inputs: - SourceFolder: '$(Build.SourcesDirectory)\tests' - Contents: '**/*.trx' - TargetFolder: '$(Build.SourcesDirectory)\out\outputs\test\_post_command__run_log_alerts_schedular_tests\_testresults' - - - task: PublishTestResults@2 - displayName: 'Unit Tests' - inputs: - testResultsFormat: 'vstest' - testResultsFiles: '**/*.trx' - searchFolder: '' - failTaskOnFailedTests: False - testRunTitle: Unit Tests \ No newline at end of file diff --git a/.pipelines/windows-buddy.yml b/.pipelines/windows-buddy.yml deleted file mode 100644 index 48e9a699..00000000 --- a/.pipelines/windows-buddy.yml +++ /dev/null @@ -1,125 +0,0 @@ - -pr: -- main -- release/* - -trigger: -- none - -parameters: # parameters are shown up in ADO UI in a build queue time -- name: 'debug' - displayName: 'Enable debug output' - type: boolean - default: false - -jobs: -- job: main - pool: - type: windows - isCustom: true - name: Azure Pipelines - vmImage: 'windows-latest' - - variables: - Codeql.Enabled: true - - steps: - - task: AntiMalware@4 - inputs: - InputType: 'Basic' - ScanType: 'CustomScan' - FileDirPath: '$(Build.StagingDirectory)' - TreatSignatureUpdateFailureAs: 'Warning' - SignatureFreshness: 'UpToDate' - TreatStaleSignatureAs: 'Error' - - - task: CredScan@3 - - - task: nuget-security-analysis@0 - - - task: CmdLine@2 - displayName: 'Install .NET' - inputs: - script: build\CallPowerShell.cmd build/install-dotnet.ps1 -RestoreOnly - workingDirectory: '$(Build.SourcesDirectory)' - - - task: CmdLine@2 - displayName: 'Restore' - inputs: - script: $(Build.SourcesDirectory)\build\CallPowerShell.cmd build.ps1 -RestoreOnly - workingDirectory: '$(Build.SourcesDirectory)' - - - task: CodeQL3000Init@0 - displayName: 'Initialize CodeQL' - - - task: CmdLine@2 - displayName: 'Dotnet Build' - inputs: - script: $(Build.SourcesDirectory)\build\CallPowerShell.cmd build.ps1 - workingDirectory: '$(Build.SourcesDirectory)' - - - task: CopyFiles@2 - inputs: - SourceFolder: '$(Build.SourcesDirectory)\buildlogs' - Contents: | - **/* - TargetFolder: '$(Build.SourcesDirectory)\out\outputs\build\Build Logs' - - - task: CmdLine@2 - displayName: 'Dotnet Pack' - inputs: - script: $(Build.SourcesDirectory)\build\CallPowerShell.cmd pack.ps1 - workingDirectory: '$(Build.SourcesDirectory)' - - - task: CopyFiles@2 - inputs: - SourceFolder: '$(Build.SourcesDirectory)\buildlogs' - Contents: | - **/* - TargetFolder: '$(Build.SourcesDirectory)\out\outputs\package\Build Logs' - - - task: CmdLine@2 - displayName: 'Dotnet Test' - inputs: - script: '$(Build.SourcesDirectory)\build/CallPowerShell.cmd test.ps1|| exit /b 0' - workingDirectory: '$(Build.SourcesDirectory)' - - - - task: CopyFiles@2 - inputs: - SourceFolder: '$(Build.SourcesDirectory)\tests' - Contents: '**/*.trx' - TargetFolder: '$(Build.SourcesDirectory)\out\outputs\test\_post_command__run_log_alerts_schedular_tests\_testresults' - - - task: PublishTestResults@2 - displayName: 'Unit Tests' - inputs: - testResultsFormat: 'vstest' - testResultsFiles: '**/*.trx' - searchFolder: '' - failTaskOnFailedTests: True - testRunTitle: Unit Tests - - - task: ComponentGovernanceComponentDetection@0 - displayName: "Component Detection" - inputs: - scanType: 'Register' - verbosity: 'Verbose' - alertWarningLevel: 'High' - - - task: BinSkim@4 - inputs: - InputType: 'Basic' - Function: 'analyze' - TargetPattern: 'guardianGlob' - AnalyzeTargetGlob: '$(Build.SourcesDirectory)\**.dll;$(Build.SourcesDirectory)\**.exe;' - - - task: PublishPipelineArtifact@1 - displayName: 'Publish Artifacts' - inputs: - targetPath: '$(Build.SourcesDirectory)\out\outputs' - artifact: 'drop' - publishLocation: 'pipeline' - - - task: CodeQL3000Finalize@0 - displayName: 'Finalize CodeQL' From 37c9c472c1e8da348d9ce249ff7026141fef6882 Mon Sep 17 00:00:00 2001 From: AMER JUSUPOVIC Date: Thu, 25 Jul 2024 12:02:25 -0700 Subject: [PATCH 2/3] test workflow failure --- tests/Tests.FeatureManagement/FeatureManagement.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Tests.FeatureManagement/FeatureManagement.cs b/tests/Tests.FeatureManagement/FeatureManagement.cs index ce337200..892ef585 100644 --- a/tests/Tests.FeatureManagement/FeatureManagement.cs +++ b/tests/Tests.FeatureManagement/FeatureManagement.cs @@ -33,7 +33,7 @@ public async Task ReadsConfiguration() IFeatureManager featureManager = serviceProvider.GetRequiredService(); - Assert.True(await featureManager.IsEnabledAsync(Features.OnTestFeature)); + Assert.False(await featureManager.IsEnabledAsync(Features.OnTestFeature)); Assert.False(await featureManager.IsEnabledAsync(Features.OffTestFeature)); From 3a9064ec45c22b9266b22fc9c0fa6ce50a86f470 Mon Sep 17 00:00:00 2001 From: AMER JUSUPOVIC Date: Thu, 25 Jul 2024 12:09:47 -0700 Subject: [PATCH 3/3] revert test --- tests/Tests.FeatureManagement/FeatureManagement.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Tests.FeatureManagement/FeatureManagement.cs b/tests/Tests.FeatureManagement/FeatureManagement.cs index 892ef585..ce337200 100644 --- a/tests/Tests.FeatureManagement/FeatureManagement.cs +++ b/tests/Tests.FeatureManagement/FeatureManagement.cs @@ -33,7 +33,7 @@ public async Task ReadsConfiguration() IFeatureManager featureManager = serviceProvider.GetRequiredService(); - Assert.False(await featureManager.IsEnabledAsync(Features.OnTestFeature)); + Assert.True(await featureManager.IsEnabledAsync(Features.OnTestFeature)); Assert.False(await featureManager.IsEnabledAsync(Features.OffTestFeature));