Skip to content

Commit 15557a1

Browse files
authored
Fix azure pipelines (#615)
1 parent aa4bea9 commit 15557a1

File tree

4 files changed

+68
-58
lines changed

4 files changed

+68
-58
lines changed

.ci/linux_devops_tools.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/bin/bash
22

3-
sudo add-apt-repository -y \
4-
'deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main' \
3+
wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb \
4+
&& sudo dpkg -i packages-microsoft-prod.deb \
55
&& sudo apt-get update \
6-
&& sudo apt-get install -y \
7-
azure-functions-core-tools
6+
&& sudo apt-get install -y azure-functions-core-tools

azure-pipelines.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ trigger:
55
- master
66

77
variables:
8-
DOTNET_VERSION: '2.2.402'
8+
DOTNET_VERSION: '2.2.x'
99

1010
jobs:
1111
- job: Tests
@@ -25,12 +25,7 @@ jobs:
2525
inputs:
2626
versionSpec: '$(pythonVersion)'
2727
addToPath: true
28-
- task: ShellScript@2
29-
inputs:
30-
disableAutoCwd: true # Execute in current directory
31-
scriptPath: .ci/linux_devops_tools.sh
32-
displayName: 'Install Core Tools'
33-
- task: DotNetCoreInstaller@0
28+
- task: UseDotNet@2
3429
inputs:
3530
packageType: 'sdk'
3631
version: $(DOTNET_VERSION)

azure_functions_worker/testutils.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import typing
2626
import unittest
2727
import uuid
28+
import re
2829

2930
import grpc
3031
import requests
@@ -67,11 +68,7 @@
6768
"prefetchCount": 1000,
6869
"batchCheckpointFrequency": 1
6970
},
70-
"functionTimeout": "00:05:00",
71-
"extensionBundle": {
72-
"id": "Microsoft.Azure.Functions.ExtensionBundle",
73-
"version": "[1.*, 2.0.0)"
74-
}
71+
"functionTimeout": "00:05:00"
7572
}
7673
"""
7774

@@ -139,12 +136,21 @@ def __new__(mcls, name, bases, dct):
139136
@functools.wraps(test_case)
140137
def wrapper(self, *args, __meth__=test_case,
141138
__check_log__=check_log_case, **kwargs):
139+
142140
if __check_log__ is not None and callable(__check_log__):
143141
# Check logging output for unit test scenarios
144142
result = self._run_test(__meth__, *args, **kwargs)
145-
output_lines = self.host_out.splitlines()
146-
host_out = list(map(lambda s: s.strip(), output_lines))
147-
self._run_test(__check_log__, host_out=host_out)
143+
144+
# Trim off host output timestamps
145+
host_output = getattr(self, 'host_out', '')
146+
output_lines = host_output.splitlines()
147+
ts_re = r"^\[\d+\/\d+\/\d+ \d+\:\d+\:\d+ (A|P)M\]"
148+
output = list(map(
149+
lambda s: re.sub(ts_re, '', s).strip(),
150+
output_lines))
151+
152+
# Execute check_log_ test cases
153+
self._run_test(__check_log__, host_out=output)
148154
return result
149155
else:
150156
# Check normal unit test
@@ -162,7 +168,6 @@ class WebHostTestCase(unittest.TestCase, metaclass=WebHostTestCaseMeta):
162168
this test case class logs WebHost stdout/stderr in case
163169
a unit test fails.
164170
"""
165-
166171
host_stdout_logger = logging.getLogger('webhosttests')
167172

168173
@classmethod
@@ -178,7 +183,6 @@ def setUpClass(cls):
178183
cls.host_stdout = tempfile.NamedTemporaryFile('w+t')
179184

180185
_setup_func_app(TESTS_ROOT / script_dir)
181-
182186
try:
183187
cls.webhost = start_webhost(script_dir=script_dir,
184188
stdout=cls.host_stdout)
@@ -615,7 +619,7 @@ def popen_webhost(*, stdout, stderr, script_root=FUNCS_PATH, port=None):
615619
'languageWorkers:python:workerDirectory': str(worker_path),
616620
'host:logger:consoleLoggingMode': 'always',
617621
'AZURE_FUNCTIONS_ENVIRONMENT': 'development',
618-
'AzureWebJobsSecretStorageType': 'files',
622+
'AzureWebJobsSecretStorageType': 'files'
619623
}
620624

621625
if testconfig and 'azure' in testconfig:
@@ -666,7 +670,6 @@ def start_webhost(*, script_dir=None, stdout=None):
666670
script_root=script_root, port=port)
667671

668672
addr = f'http://127.0.0.1:{port}'
669-
670673
for n in range(10):
671674
try:
672675
r = requests.get(f'{addr}/api/ping',
@@ -748,8 +751,7 @@ def _setup_func_app(app_root):
748751
f.write(HOST_JSON_TEMPLATE)
749752

750753
_symlink_dir(TESTS_ROOT / 'common' / 'ping', ping_func)
751-
if EXTENSIONS_PATH.exists():
752-
_symlink_dir(EXTENSIONS_PATH, extensions)
754+
_symlink_dir(EXTENSIONS_PATH, extensions)
753755

754756

755757
def _teardown_func_app(app_root):

setup.py

Lines changed: 47 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,41 @@
2222
'/Functions.Binaries.2.0.12888.no-runtime.zip')
2323

2424
# Extensions necessary for non-core bindings.
25-
AZURE_EXTENSIONS = [
26-
{
27-
"id": "Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator",
28-
"version": "1.0.1"
29-
},
30-
{
31-
"id": "Microsoft.Azure.WebJobs.Extensions.CosmosDB",
32-
"version": "3.0.1"
33-
},
34-
{
35-
"id": "Microsoft.Azure.WebJobs.Extensions.EventHubs",
36-
"version": "3.0.0"
37-
},
38-
{
39-
"id": "Microsoft.Azure.WebJobs.Extensions.EventGrid",
40-
"version": "2.0.0"
41-
},
42-
{
43-
"id": "Microsoft.Azure.WebJobs.Extensions.Storage",
44-
"version": "3.0.0"
45-
},
46-
{
47-
"id": "Microsoft.Azure.WebJobs.ServiceBus",
48-
"version": "3.0.0-beta8"
49-
},
50-
]
25+
AZURE_EXTENSIONS = """\
26+
<Project Sdk="Microsoft.NET.Sdk">
27+
<PropertyGroup>
28+
<TargetFramework>netstandard2.0</TargetFramework>
29+
<WarningsAsErrors></WarningsAsErrors>
30+
<DefaultItemExcludes>**</DefaultItemExcludes>
31+
</PropertyGroup>
32+
<ItemGroup>
33+
<PackageReference
34+
Include="Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator"
35+
Version="1.0.1"
36+
/>
37+
<PackageReference
38+
Include="Microsoft.Azure.WebJobs.Extensions.CosmosDB"
39+
Version="3.0.1"
40+
/>
41+
<PackageReference
42+
Include="Microsoft.Azure.WebJobs.Extensions.EventHubs"
43+
Version="3.0.0"
44+
/>
45+
<PackageReference
46+
Include="Microsoft.Azure.WebJobs.Extensions.EventGrid"
47+
Version="2.0.0"
48+
/>
49+
<PackageReference
50+
Include="Microsoft.Azure.WebJobs.Extensions.Storage"
51+
Version="3.0.0"
52+
/>
53+
<PackageReference
54+
Include="Microsoft.Azure.WebJobs.ServiceBus"
55+
Version="3.0.0-beta8"
56+
/>
57+
</ItemGroup>
58+
</Project>
59+
"""
5160

5261

5362
NUGET_CONFIG = """\
@@ -218,20 +227,25 @@ def _install_extensions(self):
218227

219228
if not (self.extensions_dir / 'host.json').exists():
220229
with open(self.extensions_dir / 'host.json', 'w') as f:
221-
print(r'{}', file=f)
230+
print('{}', file=f)
231+
232+
if not (self.extensions_dir / 'extensions.csproj').exists():
233+
with open(self.extensions_dir / 'extensions.csproj', 'w') as f:
234+
print(AZURE_EXTENSIONS, file=f)
222235

223236
with open(self.extensions_dir / 'NuGet.config', 'w') as f:
224237
print(NUGET_CONFIG, file=f)
225238

226239
env = os.environ.copy()
227240
env['TERM'] = 'xterm' # ncurses 6.1 workaround
228-
229-
for ext in AZURE_EXTENSIONS:
230-
subprocess.run([
231-
'func', 'extensions', 'install', '--package', ext['id'],
232-
'--version', ext['version']],
233-
check=True, cwd=str(self.extensions_dir),
241+
try:
242+
subprocess.run(
243+
args=['dotnet', 'build', '-o', 'bin'], check=True,
244+
cwd=str(self.extensions_dir),
234245
stdout=sys.stdout, stderr=sys.stderr, env=env)
246+
except Exception:
247+
print(f"dotnet core SDK is required")
248+
sys.exit(1)
235249

236250
def run(self):
237251
self._install_webhost()

0 commit comments

Comments
 (0)