From a807470e6a7be84c6c1af2350456f57e14c5fe34 Mon Sep 17 00:00:00 2001 From: Eric Jizba Date: Fri, 31 May 2024 13:19:42 -0700 Subject: [PATCH] Switch to 1es pipelines [v3.x] --- README.md | 2 +- azure-pipelines/build.yml | 72 -------------------------- azure-pipelines/official-build.yml | 50 ++++++++++++++++++ azure-pipelines/public-build.yml | 49 ++++++++++++++++++ azure-pipelines/templates/build.yml | 46 +++++++++++++++++ azure-pipelines/templates/test.yml | 35 +++++++++++++ azure-pipelines/test.yml | 78 ----------------------------- package.json | 3 +- 8 files changed, 182 insertions(+), 153 deletions(-) delete mode 100644 azure-pipelines/build.yml create mode 100644 azure-pipelines/official-build.yml create mode 100644 azure-pipelines/public-build.yml create mode 100644 azure-pipelines/templates/build.yml create mode 100644 azure-pipelines/templates/test.yml delete mode 100644 azure-pipelines/test.yml diff --git a/README.md b/README.md index 2514a6a..0c495cc 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ |Branch|Status|Support level|Node.js Versions| |---|---|---|---| -|v3.x|[![Build Status](https://img.shields.io/azure-devops/build/azfunc/Azure%2520Functions/145/v3.x)](https://azfunc.visualstudio.com/Azure%20Functions/_build/latest?definitionId=145&branchName=v3.x) [![Test Status](https://img.shields.io/azure-devops/tests/azfunc/Azure%2520Functions/146/v3.x?compact_message)](https://azfunc.visualstudio.com/Azure%20Functions/_build/latest?definitionId=146&branchName=v3.x)|GA|20 (Preview), 18, 16, 14| +|v3.x|[![Build Status](https://img.shields.io/azure-devops/build/azfunc/public/514/v3.x)](https://azfunc.visualstudio.com/public/_build/latest?definitionId=514&branchName=v3.x) [![Test Status](https://img.shields.io/azure-devops/tests/azfunc/public/514/v3.x?compact_message)](https://azfunc.visualstudio.com/public/_build/latest?definitionId=514&branchName=v3.x)|GA|20, 18, 16, 14| ## Install diff --git a/azure-pipelines/build.yml b/azure-pipelines/build.yml deleted file mode 100644 index 9371d33..0000000 --- a/azure-pipelines/build.yml +++ /dev/null @@ -1,72 +0,0 @@ -parameters: -- name: IsPrerelease - type: boolean - default: true - -pr: - branches: - include: - - v3.x - -trigger: -- v3.x - -jobs: -- job: BuildArtifacts - pool: - name: '1ES-Hosted-AzFunc' - demands: - - ImageOverride -equals MMS2019TLS - steps: - - task: NodeTool@0 - inputs: - versionSpec: 14.x - displayName: 'Install Node.js' - - script: npm ci - displayName: 'npm ci' - - script: npm run updateVersion -- --buildNumber $(Build.BuildNumber) - displayName: 'npm run updateVersion' - condition: and(succeeded(), eq(${{ parameters.IsPrerelease }}, true)) - - script: npm run build - displayName: 'npm run build' - - script: npm run minify - displayName: 'npm run minify' - - task: CopyFiles@2 - displayName: 'Copy files to staging' - inputs: - sourceFolder: '$(Build.SourcesDirectory)' - contents: | - dist/** - src/** - types/** - LICENSE - package.json - README.md - targetFolder: '$(Build.ArtifactStagingDirectory)' - cleanTargetFolder: true - - script: npm prune --production - displayName: 'npm prune --production' # so that only production dependencies are included in SBOM - - task: ManifestGeneratorTask@0 - displayName: 'Generate SBOM' - inputs: - BuildDropPath: '$(Build.ArtifactStagingDirectory)' - # The list of components can't be determined from the webpacked file in the staging dir, so reference the original node_modules folder - BuildComponentPath: '$(Build.SourcesDirectory)/node_modules' - PackageName: 'Azure Functions Node.js Framework' - - script: npm pack - displayName: 'npm pack' - workingDirectory: '$(Build.ArtifactStagingDirectory)' - - task: CopyFiles@2 - displayName: 'Copy package to staging drop folder' - inputs: - sourceFolder: '$(Build.ArtifactStagingDirectory)' - contents: | - *.tgz - targetFolder: '$(Build.ArtifactStagingDirectory)/drop' - cleanTargetFolder: true - - task: PublishPipelineArtifact@1 - displayName: 'Publish drop' - inputs: - targetPath: '$(Build.ArtifactStagingDirectory)/drop' - artifact: 'drop' - publishLocation: 'pipeline' diff --git a/azure-pipelines/official-build.yml b/azure-pipelines/official-build.yml new file mode 100644 index 0000000..9e88769 --- /dev/null +++ b/azure-pipelines/official-build.yml @@ -0,0 +1,50 @@ +parameters: + - name: IsPrerelease + type: boolean + default: true + +trigger: + batch: true + branches: + include: + - v3.x + +# CI only, does not trigger on PRs. +pr: none + +resources: + repositories: + - repository: 1es + type: git + name: 1ESPipelineTemplates/1ESPipelineTemplates + ref: refs/tags/release + +extends: + template: v1/1ES.Official.PipelineTemplate.yml@1es + parameters: + pool: + name: 1es-pool-azfunc + image: 1es-windows-2022 + os: windows + + stages: + - stage: WindowsUnitTests + dependsOn: [] + jobs: + - template: /azure-pipelines/templates/test.yml@self + + - stage: LinuxUnitTests + dependsOn: [] + jobs: + - template: /azure-pipelines/templates/test.yml@self + pool: + name: 1es-pool-azfunc + image: 1es-ubuntu-22.04 + os: linux + + - stage: Build + dependsOn: [] + jobs: + - template: /azure-pipelines/templates/build.yml@self + parameters: + IsPrerelease: ${{ parameters.IsPrerelease }} diff --git a/azure-pipelines/public-build.yml b/azure-pipelines/public-build.yml new file mode 100644 index 0000000..cf00452 --- /dev/null +++ b/azure-pipelines/public-build.yml @@ -0,0 +1,49 @@ +# This build is used for public PR and CI builds. + +trigger: + batch: true + branches: + include: + - v3.x + +pr: + branches: + include: + - v3.x + +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: WindowsUnitTests + dependsOn: [] + jobs: + - template: /azure-pipelines/templates/test.yml@self + + - stage: LinuxUnitTests + dependsOn: [] + jobs: + - template: /azure-pipelines/templates/test.yml@self + pool: + name: 1es-pool-azfunc-public + image: 1es-ubuntu-22.04 + os: linux + + - stage: Build + dependsOn: [] + jobs: + - template: /azure-pipelines/templates/build.yml@self + parameters: + IsPrerelease: true diff --git a/azure-pipelines/templates/build.yml b/azure-pipelines/templates/build.yml new file mode 100644 index 0000000..63dd49b --- /dev/null +++ b/azure-pipelines/templates/build.yml @@ -0,0 +1,46 @@ +jobs: + - job: + templateContext: + outputs: + - output: pipelineArtifact + path: $(Build.ArtifactStagingDirectory)/dropOutput + artifact: drop + sbomBuildDropPath: '$(Build.ArtifactStagingDirectory)/dropInput' + sbomPackageName: 'Azure Functions Node.js Programming Model' + # The list of components can't be determined from the webpacked file in the staging dir, so reference the original node_modules folder + sbomBuildComponentPath: '$(Build.SourcesDirectory)/node_modules' + steps: + - task: NodeTool@0 + inputs: + versionSpec: 20.x + displayName: 'Install Node.js' + - script: npm ci + displayName: 'npm ci' + - script: npm run updateVersion -- --buildNumber $(Build.BuildNumber) + displayName: 'npm run updateVersion' + condition: and(succeeded(), eq(${{ parameters.IsPrerelease }}, true)) + - script: npm run build + displayName: 'npm run build' + - script: npm run minify + displayName: 'npm run minify' + - task: CopyFiles@2 + displayName: 'Copy files to staging' + inputs: + sourceFolder: '$(Build.SourcesDirectory)' + contents: | + dist/** + src/** + types/** + LICENSE + package.json + README.md + targetFolder: '$(Build.ArtifactStagingDirectory)/dropInput' + cleanTargetFolder: true + - script: npm prune --production + displayName: 'npm prune --production' # so that only production dependencies are included in SBOM + - script: npm pack + displayName: 'npm pack' + workingDirectory: '$(Build.ArtifactStagingDirectory)/dropInput' + - script: mkdir dropOutput && mv dropInput/*.tgz dropOutput + displayName: 'Move package to dropOutput' + workingDirectory: '$(Build.ArtifactStagingDirectory)' diff --git a/azure-pipelines/templates/test.yml b/azure-pipelines/templates/test.yml new file mode 100644 index 0000000..7c1de9a --- /dev/null +++ b/azure-pipelines/templates/test.yml @@ -0,0 +1,35 @@ +jobs: + - job: UnitTests + + strategy: + matrix: + Node14: + NODE_VERSION: '14.x' + Node16: + NODE_VERSION: '16.x' + Node18: + NODE_VERSION: '18.x' + Node20: + NODE_VERSION: '20.x' + + steps: + - task: NodeTool@0 + inputs: + versionSpec: $(NODE_VERSION) + displayName: 'Install Node.js' + - script: npm ci + displayName: 'npm ci' + - script: npm run build + displayName: 'npm run build' + - script: npm run lint + displayName: 'npm run lint' + - script: npm run updateVersion -- --validate + displayName: 'validate version' + - script: npm test + displayName: 'Run unit tests' + - task: PublishTestResults@2 + displayName: 'Publish Unit Test Results' + inputs: + testResultsFiles: 'test/unit-test-results.xml' + testRunTitle: '$(Agent.JobName)' + condition: succeededOrFailed() diff --git a/azure-pipelines/test.yml b/azure-pipelines/test.yml deleted file mode 100644 index 463aa0c..0000000 --- a/azure-pipelines/test.yml +++ /dev/null @@ -1,78 +0,0 @@ -variables: { - NODE_14: '14.x', - NODE_16: '16.x', - NODE_18: '18.x', - NODE_20: '20.x' -} - -pr: - branches: - include: - - v3.x - -trigger: -- v3.x - -jobs: -- job: UnitTests - strategy: - matrix: - UBUNTU_NODE14: - IMAGE_TYPE: 'ubuntu-latest' - NODE_VERSION: $(NODE_14) - UBUNTU_NODE16: - IMAGE_TYPE: 'ubuntu-latest' - NODE_VERSION: $(NODE_16) - UBUNTU_NODE18: - IMAGE_TYPE: 'ubuntu-latest' - NODE_VERSION: $(NODE_18) - UBUNTU_NODE20: - IMAGE_TYPE: 'ubuntu-latest' - NODE_VERSION: $(NODE_20) - WINDOWS_NODE14: - IMAGE_TYPE: 'windows-latest' - NODE_VERSION: $(NODE_14) - WINDOWS_NODE16: - IMAGE_TYPE: 'windows-latest' - NODE_VERSION: $(NODE_16) - WINDOWS_NODE18: - IMAGE_TYPE: 'windows-latest' - NODE_VERSION: $(NODE_18) - WINDOWS_NODE20: - IMAGE_TYPE: 'windows-latest' - NODE_VERSION: $(NODE_20) - MAC_NODE14: - IMAGE_TYPE: 'macOS-latest' - NODE_VERSION: $(NODE_14) - MAC_NODE16: - IMAGE_TYPE: 'macOS-latest' - NODE_VERSION: $(NODE_16) - MAC_NODE18: - IMAGE_TYPE: 'macOS-latest' - NODE_VERSION: $(NODE_18) - MAC_NODE20: - IMAGE_TYPE: 'macOS-latest' - NODE_VERSION: $(NODE_20) - pool: - vmImage: $(IMAGE_TYPE) - steps: - - task: NodeTool@0 - inputs: - versionSpec: $(NODE_VERSION) - displayName: 'Install Node.js' - - script: npm ci - displayName: 'npm ci' - - script: npm run build - displayName: 'npm run build' - - script: npm run lint - displayName: 'npm run lint' - - script: npm run updateVersion -- --validate - displayName: 'validate version' - - script: npm test - displayName: 'Run unit tests' - - task: PublishTestResults@2 - displayName: 'Publish Unit Test Results' - inputs: - testResultsFiles: 'test/unit-test-results.xml' - testRunTitle: '$(Agent.JobName)' - condition: succeededOrFailed() diff --git a/package.json b/package.json index 73888ce..78ec35d 100644 --- a/package.json +++ b/package.json @@ -25,8 +25,7 @@ "src/", "types/", "LICENSE", - "README.md", - "_manifest" + "README.md" ], "scripts": { "build": "webpack --mode development",