-
Notifications
You must be signed in to change notification settings - Fork 1
/
azure-pipelines-Copy.yml
109 lines (98 loc) · 4.97 KB
/
azure-pipelines-Copy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
steps:
- script: echo Hello, world!
displayName: 'Run a one-line script'
- script: |
echo Add other tasks to build, test, and deploy your project.
echo See https://aka.ms/yaml
git clone https://github.com/chunyu3/autorest.cli.git ~/autorest.cli
git clone -b azure_backend https://github.com/VSChina/magic-modules/ ~/magic-modules
git clone https://chunyu3:${TF_TOKEN}@github.com/chunyu3/terraform.git ~/terraform
git clone https://github.com/houkms/cli-input-tools.git ~/cli-input-tools
displayName: 'clone git repo'
- bash: |
#git clone https://github.com/Azure/autorest.cli.git ~/autorest.cli
echo $(pwd)
cd ~
#export DOCKER_ACR_SERVER=terraformbuild.azurecr.io
docker login ${DOCKER_ACR_SERVER} -u=${DOCKER_USER} -p=${DOCKER_PASSWORD}
docker build --tag ${DOCKER_ACR_SERVER}/autorest.cli.base -f ~/terraform/Dockerfile-base .
docker push ${DOCKER_ACR_SERVER}/autorest.cli.base
docker build --tag ${DOCKER_ACR_SERVER}/autorest.cli --build-arg DOCKERSERVER=${DOCKER_ACR_SERVER} -f ~/terraform/Dockerfile .
docker push ${DOCKER_ACR_SERVER}/autorest.cli
displayName: 'build docker image'
condition: eq(variables['build_image'], 'true')
- bash: |
git clone https://github.com/Azure/azure-rest-api-specs.git ~/azure-rest-api-specs
git clone https://audevbot:${GH_TOKEN}@github.com/audevbot/autorest.cli.debug.git ~/autorest.cli.debug
git clone https://audevbot:${GH_TOKEN}@github.com/Azure/magic-module-specs.git ~/magic-module-specs
# git clone https://chunyu3:${TF_TOKEN}@github.com/chunyu3/terraform.git ~/terraform
cd ~/autorest.cli
export CURRENT_PATH=$(pwd)
echo ${CURRENT_PATH}
ls ${CURRENT_PATH}/input
cd ~/autorest.cli.debug; git checkout autogenerated-test -- ~/autorest.cli.debug || git checkout -B autogenerated-test
mkdir -p ~/autorest.cli.debug/generated
rm -rf ~/autorest.cli.debug/generated/*
mkdir -p ~/mmoutput
# 'cd ${CURRENT_PATH}/input;
# for d in *; do
# echo ---------------------------------------------------------------------------------;
# echo Processing: $d;
# echo ---------------------------------------------------------------------------------;
# docker run -t -i
# -v ~/azure-rest-api-specs:/azure-rest-api-specs
# -v ~/autorest.cli.debug/generated:/generated
# -v ~/magic-modules:/magic-modules
# -v ~/mmoutput:/mmoutput
# zikalino/autorest.cli
# /autorest.cli/input/$d;
# break;
# done'
# for d in ${CURRENT_PATH}/input/; do
# echo "Processing: $d";
# # docker run -t -i -v ~/azure-rest-api-specs:/azure-rest-api-specs -v ~/autorest.cli.debug/generated:/generated -v ~/magic-modules:/magic-modules -v ~/mmoutput:/mmoutput zikalino/autorest.cli /autorest.cli/input/$d;
# docker run -t -i -v ~/azure-rest-api-specs:/azure-rest-api-specs -v ~/autorest.cli.debug/generated:/generated -v ~/mmoutput:/mmoutput zikalino/autorest.cli /autorest.cli/input/$d;
# break;
# done
echo "get total number of service"
num=$(python3 ~/cli-input-tools/list_readme_path_of_all_services.py ~/azure-rest-api-specs/specification |wc -l)
echo $num
per_docker=$NUM_PER_DOCKER
echo $per_docker
round=$(( num/per_docker ))
mod=$(( num%per_docker ))
if [ $(( mod >= 0 )) ]; then
(( round++ ))
fi
start=0
echo "docker run start"
docker login ${DOCKER_ACR_SERVER} -u=${DOCKER_USER} -p=${DOCKER_PASSWORD}
for ((j=0; j<round; j++)); do
docker run -v ~/azure-rest-api-specs:/azure-rest-api-specs -v ~/autorest.cli.debug/generated:/generated -v ~/mmoutput:/mmoutput ${DOCKER_ACR_SERVER}/autorest.cli /azure-rest-api-specs/specification $start $per_docker
start=$(( start+per_docker ))
done
# docker run -v ~/azure-rest-api-specs:/azure-rest-api-specs -v ~/autorest.cli.debug/generated:/generated -v ~/mmoutput:/mmoutput ${DOCKER_ACR_SERVER}/autorest.cli /azure-rest-api-specs/specification 0 30
displayName: 'build magic-module input files'
timeoutInMinutes: 360
- bash: |
echo "success"
cd ~/terraform; git config credential.helper store ; git config --global user.email "[email protected]";git config --global user.name "chunyu3; git pull origin master"
cp -R ~/autorest.cli.debug/generated/magic-modules-input ~/terraform
# ls -al ~/mmoutput/azurerm
cp -R ~/mmoutput ~/terraform
# ls -aRl ~/terraform
echo "https://chunyu3:${TF_TOKEN}@github.com" > ~/.git-credentials
cd ~/terraform; git pull origin master; git add -A; git commit -m "autogenerated"; git push --set-upstream origin master;
displayName: 'commit Magic-module input files'
condition: always()
- bash: |
echo "upload terraform code"
displayName: 'upload terraform code'