Skip to content

Commit

Permalink
[Docs CI] Add configurations for mooncake (Azure#4460)
Browse files Browse the repository at this point in the history
* Add logic for mooncake

* Update the batch file label

* Test for generating xml for all profiles

* Just use profile latest to generate xml files
  • Loading branch information
georgechenchao authored and derekbekoe committed Sep 18, 2017
1 parent efeedc2 commit efcc293
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
75 changes: 75 additions & 0 deletions appveyor-mooncake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
branches:
only:
- master

init:
- git config --global core.autocrlf false

environment:
PYTHON: "C:\\Python35"
access_token:
secure: VMFbecLLHzDq/09YDPbcM0VDDSwwgY57vr5GXK6cZZ4Ti/Xs5RZoylzV8MMr1350

install:
- SET PATH=%PYTHON%;%PYTHON%\Scripts;%PATH%
- python scripts/dev_setup.py
- python -m pip install sphinx==1.5.6

build_script:
- ps: |
$docSourceRaw = Get-Content -Raw -Path "$env:APPVEYOR_BUILD_FOLDER\doc\sphinx\azhelpgen\doc_source_map.json" | ConvertFrom-Json
$docFiles = $docSourceRaw | Get-Member -type NoteProperty | %{ $docSourceRaw."$($_.Name)" }
$docFiles = $docFiles | select -Unique
$fileCommitMap = @{}
foreach($file in $docFiles)
{
$commitId = (git rev-list -1 HEAD $file)
if($commitId -match '^[0-9a-f]{40}$')
{
$date = Get-Date -Date (git log --pretty=format:%cd -n 1 --date=iso $file)
$date = $date.ToUniversalTime()
$date = Get-Date $date -format G
$fileCommitMap[$file] = @{}
$fileCommitMap[$file]["commit"] = $commitId
$fileCommitMap[$file]["date"] = $date
}
else
{
Write-Host -ForegroundColor Red "Failed to get commit id for $file"
$host.SetShouldExit(-1)
}
}
$fileCommitMap | ConvertTo-Json | Out-File "$env:APPVEYOR_BUILD_FOLDER\doc\sphinx\doc_commit_map.json"
- cd doc\sphinx
- make xmlwithlatest
- git config --global credential.helper store
- ps: Add-Content "$env:USERPROFILE\.git-credentials" "https://$($env:access_token):x-oauth-basic@github.com`n"
- git config --global user.email "%GIT_USER_EMAIL%"
- git config --global user.name "%GIT_USER_NAME%"
- git clone --depth 5 -q --branch=%TARGET_BRANCH% %GIT_CONTENT_REPO_URL% %TEMP%\azure-cli-content
- ps: |
$folders = Get-ChildItem -Path "$env:TEMP\azure-cli-content" -Directory
ForEach($folder in $folders)
{
$folderPath = [System.IO.Path]::Combine("$env:TEMP\azure-cli-content", $folder)
$subFolders = Get-ChildItem -Path $folderPath -Directory -Name
if ($subFolders -contains "$env:YML_OUTPUT_FOLDER" -and $subFolders -contains "$env:CONCEPTUAL_DOC_FOLDER")
{
$docsRefAutogenFolder = [System.IO.Path]::Combine($folderPath, "$env:YML_OUTPUT_FOLDER")
Get-ChildItem -Path $docsRefAutogenFolder | Remove-Item -Force -Recurse
}
}
- mkdir %TEMP%\azure-cli-xml2yml
- cd %TEMP%\azure-cli-xml2yml
- nuget install azure.cli.doc.xml2yml -Source https://ci.appveyor.com/nuget/azure-docs-cli-pre-process
- cd azure.cli.doc.xml2yml*\tools
- AzCliDocPreprocessor -s "%APPVEYOR_BUILD_FOLDER%\doc\sphinx\_build\xml" -d "%TEMP%\azure-cli-xml2yml\yml-output" -r "https://github.com/%APPVEYOR_REPO_NAME%" -b "%APPVEYOR_REPO_BRANCH%" -c "%APPVEYOR_BUILD_FOLDER%\doc\sphinx\doc_commit_map.json" -f "%TEMP%\azure-cli-content\TitleMapping.json" -v 1

artifacts:
- path: doc\sphinx\_build

on_success:
- cd %TEMP%\azure-cli-content
- SETLOCAL EnableDelayedExpansion & robocopy %TEMP%\azure-cli-xml2yml\yml-output %TEMP%\azure-cli-content /e & IF !ERRORLEVEL! EQU 1 (exit 0) ELSE (IF !ERRORLEVEL! EQU 3 (exit 0) ELSE (exit 1))
- git add -A
- git diff --quiet --exit-code --cached || git commit -m "Update Document Content" && git push origin %TARGET_BRANCH% && appveyor AddMessage "Document Updated"
9 changes: 9 additions & 0 deletions doc/sphinx/make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,15 @@ if "%1" == "dummy" (
goto end
)

if "%1" == "xmlwithlatest" (
az cloud update --profile latest
%SPHINXBUILD% -E -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml/latest
if errorlevel 1 exit /b 1
echo.
echo.Build finished. The XML files are in %BUILDDIR%/xml/latest.
goto :eof
)

if "%1" == "xmlwithversion" (
call :genxmlwithversion
if errorlevel 1 exit /b 1
Expand Down

0 comments on commit efcc293

Please sign in to comment.