From b57d905c9d13691f7c8a992a2c117c5f1bb160d0 Mon Sep 17 00:00:00 2001 From: Anatoly Pristensky Date: Mon, 26 Feb 2024 15:09:21 +0100 Subject: [PATCH] [Pipelines] Migrate to 1ES pipeline. (#2474) * Initial template * Add variables * Update appcenter-cli-1ES.yml * Add Ignored directory * Remove unnecessary repo cloning * Update dir * Update dirs * Supress value in tests * Add supress * Fix comments --- appcenter-cli-1ES.yml | 128 ++++++++++++++++++ .../token-store/osx-keychain-parser-test.ts | 2 + 2 files changed, 130 insertions(+) create mode 100644 appcenter-cli-1ES.yml diff --git a/appcenter-cli-1ES.yml b/appcenter-cli-1ES.yml new file mode 100644 index 000000000..0365070d8 --- /dev/null +++ b/appcenter-cli-1ES.yml @@ -0,0 +1,128 @@ +trigger: none + +variables: +- name: API_TOKEN_KEY_VAULT + value: 'distributionStoresInt' +- name: API_TOKEN_KEY_VAULT_AZURE_SUBSCRIPTION + value: 'App Center - INT' + +resources: + repositories: + - repository: 1ESPipelineTemplates + type: git + name: 1ESPipelineTemplates/1ESPipelineTemplates + ref: refs/tags/release + +extends: + template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates + parameters: + pool: + name: 1ES-PT-CBL-Mariner-2.0-Gen2 + os: linux + customBuildTags: + - ES365AIMigrationTooling-BulkMigrated + sdl: + sourceAnalysisPool: 1ES-PT-Windows-2022 + stages: + - stage: Stage + jobs: + - job: HostJob + templateContext: + outputs: + - output: pipelineArtifact + displayName: "Publish Artifact: artifacts" + path: '$(Build.ArtifactStagingDirectory)/npm' + artifactName: npm + + steps: + - task: NodeTool@0 + inputs: + versionSpec: '14.x' + displayName: 'Install Node.js' + + - script: | + npm ci + npm run build + displayName: 'Install and build' + + - script: | + npm run test:ci || [ -f './test-results.xml' ] + displayName: 'Run CLI tests (with JUnit output)' + + - task: PublishTestResults@2 + inputs: + testResultsFormat: 'JUnit' + testResultsFiles: 'test-results.xml' + searchFolder: '$(Build.SourcesDirectory)' + failTaskOnFailedTests: true + testRunTitle: 'CLI unit tests' + displayName: 'Verify CLI unit test result' + + - script: | + npm ci + npm run build + displayName: 'Install and build appcenter-file-upload-client-node' + workingDirectory: $(Build.SourcesDirectory)/appcenter-file-upload-client-node + + - script: | + npm run test:ci || [ -f './test-results.xml' ] + displayName: 'Run appcenter-file-upload-client-node tests' + workingDirectory: $(Build.SourcesDirectory)/appcenter-file-upload-client-node + + - task: PublishTestResults@2 + inputs: + testResultsFormat: 'JUnit' + testResultsFiles: 'test-results.xml' + searchFolder: '$(Build.SourcesDirectory)/appcenter-file-upload-client-node' + failTaskOnFailedTests: true + testRunTitle: 'appcenter-file-upload-client-node unit tests' + displayName: 'Verify appcenter-file-upload-client-node unit test result' + + - task: AzureKeyVault@1 + inputs: + azureSubscription: '$(API_TOKEN_KEY_VAULT_AZURE_SUBSCRIPTION)' + KeyVaultName: '$(API_TOKEN_KEY_VAULT)' + SecretsFilter: 'ac-cli-account-api-token' + + - task: PowerShell@2 + inputs: + filePath: '$(Build.SourcesDirectory)/test/functional/Invoke-FunctionalTests.ps1' + arguments: '-Token $(ac-cli-account-api-token)' + pwsh: true + workingDirectory: $(Build.SourcesDirectory) + displayName: 'Run functional tests' + + - script: | + [ -f './test/functional/testresult.xml' ] + displayName: 'Verify that functional test result file exists' + workingDirectory: $(Build.SourcesDirectory) + + - task: PublishTestResults@2 + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: 'testresult.xml' + searchFolder: '$(Build.SourcesDirectory)/test/functional' + failTaskOnFailedTests: true + testRunTitle: 'Functional tests' + displayName: 'Verify functional test result' + + - script: | + npm pack + npm install -g appcenter-cli*.tgz + displayName: 'Package appcenter-cli' + workingDirectory: $(Build.SourcesDirectory) + + - task: DeleteFiles@1 + inputs: + contents: node_modules + displayName: 'Delete node_modules' + + - task: ArchiveFiles@2 + inputs: + rootFolderOrFile: '$(Build.SourcesDirectory)' + includeRootFolder: false + archiveType: 'tar' + archiveFile: '$(Build.ArtifactStagingDirectory)/npm/$(Build.BuildId).tgz' + replaceExistingArchive: true + verbose: true + displayName: 'Prepare npm artifact' diff --git a/test/util/token-store/osx-keychain-parser-test.ts b/test/util/token-store/osx-keychain-parser-test.ts index a2966f53c..fed4e938d 100644 --- a/test/util/token-store/osx-keychain-parser-test.ts +++ b/test/util/token-store/osx-keychain-parser-test.ts @@ -16,6 +16,7 @@ describe("storing complete data in keychain", function () { const keychain = tokenStore.createOsxTokenStore(); const testUser = "appcenter-user"; + //[SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine", Justification="this is not a secret")] const testPassword = "Sekret!"; const testTokenId = "1234abcd"; @@ -49,6 +50,7 @@ describe("storing data without a tokenId in keychain", function () { const keychain = tokenStore.createOsxTokenStore(); const testUser = "appcenter-user"; + //[SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine", Justification="this is not a secret")] const testPassword = "Sekret!"; before(() => {