Skip to content

Commit 0d6120e

Browse files
shreyas-gopalakrishnakaibocai
authored andcommitted
Updating java core library pipeline with the new library architecture
and end to end tests
1 parent 6ac8454 commit 0d6120e

File tree

3 files changed

+92
-27
lines changed

3 files changed

+92
-27
lines changed

azure-pipelines.yml

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,48 @@ jobs:
2727
Write-Host "Java_HOME: $JAVA_HOME"
2828
Get-Command mvn
2929
displayName: 'Check Maven is installed'
30-
- pwsh: '& .\build.ps1'
30+
31+
- pwsh: |
32+
Invoke-WebRequest 'https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.ps1' -OutFile 'dotnet-install.ps1'
33+
./dotnet-install.ps1 -InstallDir "$env:ProgramFiles/dotnet" -Version "6.0.100-rc.2.21505.57" -Channel 'release'
34+
displayName: 'Install the .Net version used by the Core Tools for Windows'
35+
condition: eq( variables['Agent.OS'], 'Windows_NT' )
36+
- bash: |
37+
curl -sSL https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.sh | bash /dev/stdin -v '6.0.100-rc.2.21505.57' -c 'release' --install-dir /usr/share/dotnet
38+
displayName: 'Install the .Net version used by the Core Tools for Linux'
39+
condition: eq( variables['Agent.OS'], 'Linux' )
40+
41+
- pwsh: '& .\build.ps1'
42+
displayName: 'Build project with java core library'
43+
- pwsh: |
44+
$currDir = Get-Location
45+
$Env:Path = $Env:Path+";$currDir\Azure.Functions.Cli"
46+
ls $currDir\Azure.Functions.Cli
47+
func --version
48+
cd ./azure-functions-java-worker/endtoendtests
49+
mvn clean package `-Dmaven`.javadoc`.skip=true `-Dmaven`.test`.skip `-Dorg`.slf4j`.simpleLogger`.log`.org`.apache`.maven`.cli`.transfer`.Slf4jMavenTransferListener=warn `-B
50+
Copy-Item "confluent_cloud_cacert.pem" ".\target\azure-functions\azure-functions-java-endtoendtests"
51+
displayName: 'Package Java for E2E'
52+
- task: DotNetCoreCLI@2
53+
inputs:
54+
command: 'test'
55+
projects: |
56+
azure-functions-java-worker\endtoendtests\Azure.Functions.Java.Tests.E2E\Azure.Functions.Java.Tests.E2E\Azure.Functions.Java.Tests.E2E.csproj
57+
env:
58+
AzureWebJobsStorage: $(AzureWebJobsStorage)
59+
AzureWebJobsCosmosDBConnectionString: $(AzureWebJobsCosmosDBConnectionString)
60+
AzureWebJobsServiceBus: $(AzureWebJobsServiceBus)
61+
AzureWebJobsEventHubReceiver: $(AzureWebJobsEventHubReceiver)
62+
AzureWebJobsEventHubSender_2: $(AzureWebJobsEventHubSender_2)
63+
AzureWebJobsEventHubSender: $(AzureWebJobsEventHubSender)
64+
AzureWebJobsEventHubPath: $(AzureWebJobsEventHubPath)
65+
SBTopicName: $(SBTopicName)
66+
SBTopicSubName: $(SBTopicSubName)
67+
CosmosDBDatabaseName: $(CosmosDBDatabaseName)
68+
SBQueueName: $(SBQueueName)
69+
BrokerList": $(BrokerList)
70+
ConfluentCloudUsername: $(ConfluentCloudUsername)
71+
ConfluentCloudPassword: $(ConfluentCloudPassword)
72+
AzureWebJobsEventGridOutputBindingTopicUriString: $(AzureWebJobsEventGridOutputBindingTopicUriString)
73+
AzureWebJobsEventGridOutputBindingTopicKeyString: $(AzureWebJobsEventGridOutputBindingTopicKeyString)
74+
displayName: 'Build & Run tests for java 8'

build.ps1

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,34 @@ if ([string]::IsNullOrEmpty($pluginVersion))
4040
StopOnFailedExecution
4141

4242

43-
# Get azure-functions-library
44-
Write-Host "Build and install azure-functions-java-library"
43+
# Get azure-functions-core-library
44+
Write-Host "Build and install azure-functions-java-core-library"
45+
cmd.exe /c '.\mvnBuild.bat'
46+
StopOnFailedExecution
47+
$coreLibraryPom = Get-Content "pom.xml" -Raw
48+
$coreLibraryPom -match "<version>(.*)</version>"
49+
$coreLibraryVersion = $matches[1]
50+
Write-Host "coreLibraryVersion: " $coreLibraryVersion
51+
52+
# Get azure-functions-library
53+
git clone https://github.com/Azure/azure-functions-java-library.git -b dev
54+
Push-Location -Path "./azure-functions-java-library" -StackName libraryDir
55+
Write-Host "Updating azure-functions-java-library to use current version of azure-functions-java-core-library"
56+
cmd.exe /c .\..\updateVersions.bat $coreLibraryVersion
57+
Write-Host "Building azure-functions-java-library"
4558
cmd.exe /c '.\mvnBuild.bat'
4659
StopOnFailedExecution
4760
$libraryPom = Get-Content "pom.xml" -Raw
4861
$libraryPom -match "<version>(.*)</version>"
4962
$libraryVersion = $matches[1]
5063
Write-Host "libraryVersion: " $libraryVersion
64+
Pop-Location -StackName "libraryDir"
5165

5266
# Download azure-functions-core-tools
67+
$FUNC_RUNTIME_VERSION = '4'
68+
$arch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString().ToLowerInvariant()
69+
$os = if ($IsWindows) { "win" } else { if ($IsMacOS) { "osx" } else { "linux" } }
70+
5371
$currDir = Get-Location
5472
$skipCliDownload = $false
5573
if($args[0])
@@ -64,11 +82,11 @@ Remove-Item -Force ./Azure.Functions.Cli.zip -ErrorAction Ignore
6482
Remove-Item -Recurse -Force ./Azure.Functions.Cli -ErrorAction Ignore
6583

6684
Write-Host "Downloading Functions Core Tools...."
67-
Invoke-RestMethod -Uri 'https://functionsclibuilds.blob.core.windows.net/builds/2/latest/version.txt' -OutFile version.txt
85+
Invoke-RestMethod -Uri "https://functionsclibuilds.blob.core.windows.net/builds/$FUNC_RUNTIME_VERSION/latest/version.txt" -OutFile version.txt
6886
Write-Host "Using Functions Core Tools version: $(Get-Content -Raw version.txt)"
6987
Remove-Item version.txt
7088

71-
$url = "https://functionsclibuilds.blob.core.windows.net/builds/2/latest/Azure.Functions.Cli.win-x86.zip"
89+
$url = "https://functionsclibuilds.blob.core.windows.net/builds/$FUNC_RUNTIME_VERSION/latest/Azure.Functions.Cli.$os-$arch.zip"
7290
$output = "$currDir\Azure.Functions.Cli.zip"
7391
$wc = New-Object System.Net.WebClient
7492
$wc.DownloadFile($url, $output)
@@ -78,32 +96,30 @@ Expand-Archive ".\Azure.Functions.Cli.zip" -DestinationPath ".\Azure.Functions.C
7896
}
7997
$Env:Path = $Env:Path+";$currDir\Azure.Functions.Cli"
8098

81-
# Generate HttpTrigger Function via archetype version built above
82-
md -Name ciTestDir
83-
Push-Location -Path "./ciTestDir" -StackName libraryDir
84-
Write-Host "Generating project with archetype"
85-
cmd.exe /c '.\..\mvnGenerateArchetype.bat' $atchetypeVersion
86-
Pop-Location -StackName "libraryDir"
87-
88-
#Build HttpTrigger Function
89-
90-
Push-Location -Path "./ciTestDir/e2etestproject" -StackName libraryDir
91-
Remove-Item -Recurse -Force "src/test" -ErrorAction Ignore
92-
cmd.exe /c .\..\..\updateVersions.bat $libraryVersion $pluginVersion
93-
StopOnFailedExecution
94-
#Update versions in the HttpTrigger pom.xml
95-
cmd.exe /c '.\..\..\mvnBuild.bat'
96-
StopOnFailedExecution
97-
Pop-Location -StackName "libraryDir"
98-
9999
# Clone and build azure-functions-java-worker
100100
git clone https://github.com/azure/azure-functions-java-worker -b dev
101101
Push-Location -Path "./azure-functions-java-worker" -StackName libraryDir
102-
Write-Host "Updating azure-functions-java-worker to use current version of library"
102+
Write-Host "Updating azure-functions-java-worker to use current version of the java core library"
103103

104-
cmd.exe /c .\..\updateVersions.bat $libraryVersion
104+
cmd.exe /c .\..\updateVersions.bat $coreLibraryVersion
105105
Write-Host "Building azure-functions-java-worker"
106106
cmd.exe /c '.\mvnBuild.bat'
107107
StopOnFailedExecution
108108
Pop-Location -StackName "libraryDir"
109109

110+
# Update core tools with the new Java worker
111+
Write-Host "Replacing Java worker binaries in the Core Tools..."
112+
Get-ChildItem -Path "./azure-functions-java-worker/target/*" -Include 'azure*' -Exclude '*shaded.jar','*tests.jar' | ForEach-Object {
113+
Copy-Item $_.FullName "./Azure.Functions.Cli/workers/java/azure-functions-java-worker.jar" -Force -Verbose
114+
}
115+
Copy-Item -Path ".\Azure.Functions.Cli" -Destination ".\azure-functions-java-worker\Azure.Functions.Cli" -Recurse
116+
117+
# Updating end to end tests with the new library
118+
Push-Location -Path "./azure-functions-java-worker/endtoendtests" -StackName libraryDir
119+
Write-Host "Updating azure-functions-java-worker endtoendtests to use current version of the java core library"
120+
121+
cmd.exe /c .\..\..\updateVersions.bat $coreLibraryVersion $libraryVersion $pluginVersion
122+
Write-Host "Building azure-functions-java-worker end to end tests"
123+
cmd.exe /c '.\..\..\mvnBuild.bat'
124+
StopOnFailedExecution
125+
Pop-Location -StackName "libraryDir"

updateVersions.bat

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
set libraryVersion=%1
2-
set pluginVersion=%2
1+
set coreLibraryVersion=%1
2+
set libraryVersion=%2
3+
set pluginVersion=%3
4+
echo setting azure.functions.java.core.library.version to %coreLibraryVersion%
5+
call mvn versions:set-property -Dproperty=azure.functions.java.core.library.version -DnewVersion=%coreLibraryVersion% -U -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B
6+
IF DEFINED libraryVersion (
37
echo setting azure.functions.java.library.version to %libraryVersion%
48
call mvn versions:set-property -Dproperty=azure.functions.java.library.version -DnewVersion=%libraryVersion% -U -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B
9+
)
510
IF DEFINED pluginVersion (
611
echo setting azure.functions.maven.plugin.version to %pluginVersion%
712
call mvn versions:set-property -Dproperty=azure.functions.maven.plugin.version -DnewVersion=%pluginVersion% -U -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B

0 commit comments

Comments
 (0)