Skip to content

Commit

Permalink
About of use Azure SDK script
Browse files Browse the repository at this point in the history
  • Loading branch information
lijinpei2008 committed May 8, 2020
1 parent c63d862 commit fb4f264
Show file tree
Hide file tree
Showing 6 changed files with 419 additions and 232 deletions.
23 changes: 23 additions & 0 deletions CopyJsonAddAsync.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
$allTestcaseFolders = Get-ChildItem -name
function getAnother([string] $FolderName)
{
$FolderName
if($FolderName.Contains("json") -and !$FolderName.Contains("Async"))
{
$FolderNameAsync =$FolderName -replace ".json","Async.json"
copy-item $FolderName $FolderNameAsync
}else
{
cd $FolderName
$allTestcase = Get-ChildItem -name
ForEach($folderDetail in $allTestcase)
{
getAnother($folderDetail);
}
cd ..
}
}
ForEach($folder in $allTestcaseFolders)
{
getAnother($folder);
}
16 changes: 16 additions & 0 deletions RenameScript.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

path=$1
files=$(ls $path)
for filename in $files
do
echo ${filename%.*} >> filename.txt
done

filenamelist=$(cat filename.txt | awk '{print $0}')
for name in $filenamelist
do
cp ${name}.json ${name}Async.json
done

# rm -rf filename.txt RenameScript.sh
148 changes: 148 additions & 0 deletions SDKAutoTest.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
#requires -version 2.0

[cmdletbinding()]

$file="c:\TrackV2Validation.xlsx"

function AutoTextFunction($path){
$Obj = "what"| Select-Object -Property HasSpecConfiguration,Generate,Build
$mainpath= 'C:\AME\azure-sdk-for-net\sdk'
cd $mainpath
#get current path from excel
$currentpath= $path
$loadEnvPath
cd $currentpath
$fileList =ls -Name
foreach($file in $fileList)
{
if($file.startswith('Azure.Management'))
{
$loadEnvPath= $file + '\src'
break
}
}
#then comfirm the path
if (-Not (Test-Path -Path $loadEnvPath)) {
#obj can not be find,end
$Obj.HasSpecConfiguration="NO"
cd ../../..
}else
{
#obj can be find,continue
$Obj.HasSpecConfiguration="YES"
#enter the foldfile
cd $loadEnvPath
$generateString = dotnet msbuild /t:GenerateCode |Out-string
$isGenSuccess = $generateString.contains("EXEC : error") -or $generateString.contains("): error")
#if not exist then continue 'build'
if(!$isGenSuccess)
{
#write 'Yes' in line 'Generated' of excel
$Obj.Generate="YES"
#run 'dotnet msbuild'
dotnet restore
$buildString = dotnet msbuild |Out-string
$isBuildSuccess = $buildString.contains("): error")
#if not exist then write 'Yes' in line 'Generated' of excel
if(!$isBuildSuccess)
{
#write 'Yes' in line 'Build' of excel
$Obj.Build="YES"
}else
{
#write 'NO' in line 'Build' of excel
$Obj.Build="NO"
dotnet msbuild > C:\AME\ErrorLogs\$currentpath-Build.log
}
}else
{
#write 'NO' in line 'Generated' of excel
$Obj.Generate="NO"
#log
dotnet msbuild /t:GenerateCode > C:\AME\ErrorLogs\$currentpath-generate.log
}
cd ../../../../../..
}
return $Obj
}

#excel软件本身
$Excel=New-Object -ComObject "Excel.Application"
#打开excel文件
$Workbook=$Excel.Workbooks.Open($file)
#选中工作表
$Sheet = $Workbook.Worksheets.Item('generator-v0326')
#添加工作表并重命名为当前日期
$newSheet = $Workbook.Worksheets.Add()
$newSheet.Name = "generator-v$(Get-date -Format 'MMdd')"
#初始化第一行
$newSheet.Cells.Item(1,1) = 'Service Name'
$newSheet.Cells.Item(1,2) = 'Has Spec Configuration'
$newSheet.Cells.Item(1,3) = 'Can Generate'
$newSheet.Cells.Item(1,4) = 'Can Build'
#excel是否可见
$Excel.visible=$true
#excel内容变更时,警告是否可见
$Excel.displayAlerts=$true

$Row=2

$hasSpecConfiguration=$Null
$generateMessage=$Null
$buildMessage=$Null

do {
#循环获取A2~A100单元格的内容
$serviceName=$Sheet.Range("A$Row").Text

if ($serviceName) {
#调用方法,获取执行结果返回值
$message = "what"| Select-Object -Property HasSpecConfiguration,Generate,Build
$message = AutoTextFunction($serviceName)

if($message.HasSpecConfiguration){
$hasSpecConfiguration=$message.HasSpecConfiguration
}else{
$hasSpecConfiguration=$Null
}

if($message.Generate){
$generateMessage=$message.Generate
}else{
$generateMessage=$Null
}

if($message.Build){
$buildMessage=$message.Build
}
else{
$buildMessage=$Null
}

#添加serviceName
$newSheet.Cells.Item($Row,1) = $serviceName

#修改单元格B2~B101的内容
$newSheet.Cells.Item($Row,2) = $hasSpecConfiguration

#修改单元格C2~C101的内容
$newSheet.Cells.Item($Row,3) = $generateMessage
#如果$generateMessage的值是no,则改变单元格颜色为 红
if($generateMessage -eq "NO"){
$newSheet.cells.item($Row,3).Interior.ColorIndex = 3
}

#修改单元格D2~D101的内容
$newSheet.Cells.Item($Row,4) = $buildMessage
#如果$buildMessage的值是no,则改变单元格颜色为 黄
if($buildMessage -eq "NO"){
$newSheet.cells.item($Row,4).Interior.ColorIndex = 6
}
}
$Row++
} While ($Row -le 101)

$Workbook.Close()
$Excel.Quit()

Write-Verbose "Finished"
166 changes: 83 additions & 83 deletions installAzCLIAndDocker.sh → installAzCLIAndDocker.txt
Original file line number Diff line number Diff line change
@@ -1,84 +1,84 @@
#!/bin/bash
echo "======================================================================= Please Run WSL As AdminiStrator ============================================================================"
read whit

echo "=============================================================================== sudo apt update ===================================================================================="
sudo apt update

echo "============================================================================== sudo apt upgrade ==================================================================================="
sudo apt upgrade

echo "====================================================================== Install Azure Container Registry ============================================================================"
echo "================================================================ Get Packages Needed For The Install Process ======================================================================="
sudo apt update

sudo apt install ca-certificates curl apt-transport-https lsb-release gnupg

echo "=============================================================== Download And Install The Microsoft Signing Key ====================================================================="
curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc.gpg > /dev/null

echo "==================================================================== Add The Azure CLI Software Repository ========================================================================="
AZ_REPO=$(lsb_release -cs)

echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" | sudo tee /etc/apt/sources.list.d/azure-cli.list

echo "======================================================= Update Repository Information And Install The Azure-cli Package ============================================================"
sudo apt update

sudo apt install azure-cli

echo "======================================================================== Test Azure Contianer Registry ============================================================================="
az login

echo "=============================================================================== Install Docker ====================================================================================="
echo "============================================================================ Uninstall Old Versions ================================================================================"
sudo apt remove docker docker-engine docker.io containerd runc

echo "========================================================================= Update The Apt Package Index ============================================================================="
sudo apt update

echo "=========================================================== Install Packages To Allow Apt To Use A Repository Over HTTPS ==========================================================="
sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common

echo "========================================================================= Add Docker’s Official GPG Key ============================================================================"
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

echo "============================================================== Verify That You Now Have The Key With The Fingerprint ==============================================================="
sudo apt-key fingerprint 0EBFCD88

echo "==================================================================== To Add The Nightly Or Test Repository ========================================================================="
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

echo "==================================================== Install The Latest Version Of Docker Engine-Community And Containerd =========================================================="
sudo apt update

sudo apt install docker-ce docker-ce-cli containerd.io

echo "============================================================================ Start Docker Service =================================================================================="
#echo "export DOCKER_HOST='tcp://0.0.0.0:2375'" >> ~/.bashrc

sudo service docker status

sudo service docker start

sudo service docker status

echo "============================================================================= Installation Java SDK ================================================================================"
sudo apt update

sudo apt install openjdk-8-jdk

echo "============================================================================= Check Java SDK Version ==============================================================================="
java -version

echo "========================================================================= The Installation Is Complete ============================================================================="
echo "=========================================================================== If Docker Is Not Running ==============================================================================="
echo "=========================================================== Restart Docker Desktop And Restart WSL As AdminiStrator ================================================================"
echo "=================================== [sudo gpasswd -a \$USER docker] [newgrp docker] [sudo chown \"\$USER\":\"\$USER\" /home/\"\$USER\"/.docker -R] ==========================================="
echo "============================================== [sudo chmod g+rwx \"/home/\$USER/.docker\" -R] [sudo chmod a+rw /var/run/docker.sock] =================================================="

#Find History
history

#Clean History
#!/bin/bash
echo "======================================================================= Please Run WSL As AdminiStrator ============================================================================"
read whit

echo "=============================================================================== sudo apt update ===================================================================================="
sudo apt update

echo "============================================================================== sudo apt upgrade ==================================================================================="
sudo apt upgrade

echo "====================================================================== Install Azure Container Registry ============================================================================"
echo "================================================================ Get Packages Needed For The Install Process ======================================================================="
sudo apt update

sudo apt install ca-certificates curl apt-transport-https lsb-release gnupg

echo "=============================================================== Download And Install The Microsoft Signing Key ====================================================================="
curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc.gpg > /dev/null

echo "==================================================================== Add The Azure CLI Software Repository ========================================================================="
AZ_REPO=$(lsb_release -cs)

echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" | sudo tee /etc/apt/sources.list.d/azure-cli.list

echo "======================================================= Update Repository Information And Install The Azure-cli Package ============================================================"
sudo apt update

sudo apt install azure-cli

echo "======================================================================== Test Azure Contianer Registry ============================================================================="
az login

echo "=============================================================================== Install Docker ====================================================================================="
echo "============================================================================ Uninstall Old Versions ================================================================================"
sudo apt remove docker docker-engine docker.io containerd runc

echo "========================================================================= Update The Apt Package Index ============================================================================="
sudo apt update

echo "=========================================================== Install Packages To Allow Apt To Use A Repository Over HTTPS ==========================================================="
sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common

echo "========================================================================= Add Docker’s Official GPG Key ============================================================================"
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

echo "============================================================== Verify That You Now Have The Key With The Fingerprint ==============================================================="
sudo apt-key fingerprint 0EBFCD88

echo "==================================================================== To Add The Nightly Or Test Repository ========================================================================="
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

echo "==================================================== Install The Latest Version Of Docker Engine-Community And Containerd =========================================================="
sudo apt update

sudo apt install docker-ce docker-ce-cli containerd.io

echo "============================================================================ Start Docker Service =================================================================================="
#echo "export DOCKER_HOST='tcp://0.0.0.0:2375'" >> ~/.bashrc

sudo service docker status

sudo service docker start

sudo service docker status

echo "============================================================================= Installation Java SDK ================================================================================"
sudo apt update

sudo apt install openjdk-8-jdk

echo "============================================================================= Check Java SDK Version ==============================================================================="
java -version

echo "========================================================================= The Installation Is Complete ============================================================================="
echo "=========================================================================== If Docker Is Not Running ==============================================================================="
echo "=========================================================== Restart Docker Desktop And Restart WSL As AdminiStrator ================================================================"
echo "=================================== [sudo gpasswd -a \$USER docker] [newgrp docker] [sudo chown \"\$USER\":\"\$USER\" /home/\"\$USER\"/.docker -R] ==========================================="
echo "============================================== [sudo chmod g+rwx \"/home/\$USER/.docker\" -R] [sudo chmod a+rw /var/run/docker.sock] =================================================="

#Find History
history

#Clean History
history -c
Loading

0 comments on commit fb4f264

Please sign in to comment.