Added: azure pipeline yaml file to support extension build

This commit is contained in:
Hanzhang Zeng (Roger) 2019-03-28 16:15:41 -07:00
Родитель 15ca9df566
Коммит e2b00b9175
8 изменённых файлов: 100 добавлений и 5 удалений

Просмотреть файл

@ -9,6 +9,7 @@ import vsts.release.v4_1.models as models
from ..base.base_manager import BaseManager
from ..pool.pool_manager import PoolManager
from ..constants import (LINUX_CONSUMPTION, LINUX_DEDICATED, WINDOWS)
from ..exceptions import ReleaseErrorException
class ReleaseManager(BaseManager):

Просмотреть файл

@ -100,7 +100,10 @@ class YamlManager(object):
dependencies.append('- script: |')
if self._requires_extensions():
dependencies.append(' dotnet restore')
dependencies.append(' dotnet build --output \'./bin/\'')
if self._app_type == WINDOWS:
dependencies.append(" dotnet build --output {bs}'./bin/{bs}'".format(bs="\\"))
else:
dependencies.append(" dotnet build --runtime ubuntu.16.04-x64 --output './bin/'")
if self._requires_npm():
dependencies.append(' npm install')
dependencies.append(' npm run build --if-present')

Просмотреть файл

@ -15,7 +15,8 @@ jobs:
dotnet restore # COMMENT OUT IF NOT USING FUNCTION EXTENSIONS
dotnet build --runtime ubuntu.16.04-x64 --output './bin/' # COMMENT OUT IF NOT USING FUNCTION EXTENSIONS
npm install
npm run build
npm run build --if-present
npm prune --production
- task: ArchiveFiles@2
displayName: "Archive files"
inputs:
@ -26,7 +27,7 @@ jobs:
inputs:
PathtoPublish: '$(System.DefaultWorkingDirectory)/build$(Build.BuildId).zip'
name: 'drop'
# Download the build artifacts from
# Download the build artifacts from
- job: Deploy
pool:
vmImage: 'VS2017-Win2016'

Просмотреть файл

@ -10,7 +10,8 @@ steps:
dotnet restore # comment out if not using extensions
dotnet build --output \'./bin/\' # comment out if not using extensions
npm install
npm run build
npm run build --if-present
npm prune --production
- task: ArchiveFiles@2
displayName: "Archive files"
inputs:

Просмотреть файл

@ -10,7 +10,8 @@ steps:
dotnet restore # comment out if not using extensions
dotnet build --output \'./bin/\' # comment out if not using extensions
npm install
npm run build
npm run build --if-present
npm prune --production
- task: ArchiveFiles@2
displayName: "Archive files"
inputs:

Просмотреть файл

@ -0,0 +1,26 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
# Starter template for Azure functions build -- node on linux
trigger:
- master
pool:
vmImage: 'ubuntu-16.04'
steps:
- script: |
dotnet restore
dotnet build --runtime ubuntu.16.04-x64 --output './bin/'
npm install
npm run build --if-present
npm prune --production
- task: ArchiveFiles@2
displayName: 'Archive files'
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
includeRootFolder: false
archiveFile: '$(System.DefaultWorkingDirectory)/build$(Build.BuildId).zip'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(System.DefaultWorkingDirectory)/build$(Build.BuildId).zip'
name: 'drop'

Просмотреть файл

@ -0,0 +1,26 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
# Starter template for Azure functions build -- node on windows
trigger:
- master
pool:
vmImage: 'VS2017-Win2016'
steps:
- script: |
dotnet restore
dotnet build --output \'./bin/\'
npm install
npm run build --if-present
npm prune --production
- task: ArchiveFiles@2
displayName: 'Archive files'
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
includeRootFolder: false
archiveFile: '$(System.DefaultWorkingDirectory)/build$(Build.BuildId).zip'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(System.DefaultWorkingDirectory)/build$(Build.BuildId).zip'
name: 'drop'

Просмотреть файл

@ -94,6 +94,24 @@ class TestYamlManager(unittest.TestCase):
result = TestYamlManager.is_two_files_equal("azure-pipelines.yml", yaml_path)
self.assertTrue(result)
def test_create_yaml_node_linux_install_build_extensions(self):
# Create a temporary requirements.txt and make a build script in it
# Create a temporary extensions.csproj
with open("package.json", "w") as f:
json.dump(obj={"scripts": {"build": "echo test"}}, fp=f)
with open("extensions.csproj", "w") as f:
f.write('<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"></Project>')
yaml_manager = YamlManager(language=NODE, app_type=LINUX_CONSUMPTION)
yaml_manager.create_yaml()
os.remove("package.json")
os.remove("extensions.csproj")
yaml_path = os.path.join(self._current_directory, "pipeline_scripts", "node_linux_install_build_extensions.yml")
result = TestYamlManager.is_two_files_equal("azure-pipelines.yml", yaml_path)
self.assertTrue(result)
def test_create_yaml_node_windows(self):
yaml_manager = YamlManager(language=NODE, app_type=WINDOWS)
yaml_manager.create_yaml()
@ -125,6 +143,24 @@ class TestYamlManager(unittest.TestCase):
result = TestYamlManager.is_two_files_equal("azure-pipelines.yml", yaml_path)
self.assertTrue(result)
def test_create_yaml_node_windows_install_build_extensions(self):
# Create a temporary requirements.txt and make a build script in it
# Create a temporary extensions.csproj
with open("package.json", "w") as f:
json.dump(obj={"scripts": {"build": "echo test"}}, fp=f)
with open("extensions.csproj", "w") as f:
f.write('<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"></Project>')
yaml_manager = YamlManager(language=NODE, app_type=WINDOWS)
yaml_manager.create_yaml()
os.remove("package.json")
os.remove("extensions.csproj")
yaml_path = os.path.join(self._current_directory, "pipeline_scripts", "node_windows_install_build_extensions.yml")
result = TestYamlManager.is_two_files_equal("azure-pipelines.yml", yaml_path)
self.assertTrue(result)
@staticmethod
def is_two_files_equal(filepath1, filepath2):
with open(filepath1, "r") as f1: