forked from Azure/azure-resource-manager-schemas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1696 from Azure/jcotillo/generate_onboarded_report
Ggenerate onboarded report
- Loading branch information
Showing
4 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
pr: none | ||
trigger: none | ||
|
||
schedules: | ||
- cron: "0 6 * * 5" | ||
branches: | ||
include: | ||
- master | ||
displayName: Weekly report of onboarded RPs | ||
|
||
jobs: | ||
- job: Generate | ||
timeoutInMinutes: 180 | ||
|
||
pool: | ||
vmImage: 'ubuntu-latest' | ||
|
||
steps: | ||
- checkout: self | ||
clean: true | ||
|
||
- task: DownloadSecureFile@1 | ||
name: schemasDeployKey | ||
inputs: | ||
secureFile: schemas_rsa | ||
displayName: "Download GitHub Deploy Key" | ||
|
||
- task: NodeTool@0 | ||
inputs: | ||
versionSpec: '14.x' | ||
|
||
- script: | | ||
set -Eeuxo pipefail | ||
mkdir ~/.ssh && mv $(schemasDeployKey.secureFilePath) ~/.ssh/schemas_rsa | ||
chmod 700 ~/.ssh | ||
chmod 600 ~/.ssh/schemas_rsa | ||
git config user.name "Autogenerator Pipeline" | ||
git config user.email "[email protected]" | ||
git config core.sshCommand "ssh -i ~/.ssh/schemas_rsa -F /dev/null" | ||
git remote set-url origin [email protected]:Azure/azure-resource-manager-schemas.git | ||
ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts | ||
git fetch | ||
displayName: Configure git | ||
- script: | | ||
set -Eeuxo pipefail | ||
git checkout $(Build.SourceBranchName) | ||
displayName: Checkout repo | ||
- script: | | ||
set -Eeuxo pipefail | ||
cd generator | ||
npm install | ||
displayName: 'Install packages' | ||
- script: | | ||
set -Eeuxo pipefail | ||
cd generator | ||
npm run generate-onboarded-report | ||
displayName: 'Generate report' | ||
- script: | | ||
set -Eeuxo pipefail | ||
git add --all onboarded-report | ||
if ! git diff-index --quiet HEAD --; then | ||
git commit -m "Generated report" | ||
git push origin $(Build.SourceBranchName) | ||
fi | ||
displayName: Commit report |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import * as constants from '../constants'; | ||
import { cloneAndGenerateBasePaths, validateAndReturnReadmePath } from '../specs'; | ||
import chalk from 'chalk'; | ||
import { findAutogenEntries } from '../autogenlist'; | ||
import { executeSynchronous, lowerCaseEquals, writeJsonFile, safeMkdir } from '../utils'; | ||
import { getApiVersionsByNamespace } from '../generate'; | ||
import { keys, partition } from 'lodash'; | ||
import path from 'path'; | ||
|
||
executeSynchronous(async () => { | ||
const basePaths = await cloneAndGenerateBasePaths(constants.specsRepoPath, constants.specsRepoUri, constants.specsRepoCommitHash); | ||
|
||
let allBasePaths = []; | ||
|
||
for (const basePath of basePaths) { | ||
const readme = await validateAndReturnReadmePath(constants.specsRepoPath, basePath); | ||
const namespaces = keys(await getApiVersionsByNamespace(readme)); | ||
const autogenlistEntries = findAutogenEntries(basePath); | ||
|
||
const [autogened, unautogened] = partition( | ||
namespaces, | ||
n => autogenlistEntries.findIndex(w => lowerCaseEquals(w.namespace, n)) > -1); | ||
|
||
if (unautogened.length > 0 && autogened.length > 0) { | ||
// For partial autogeneration only, add two items | ||
// one item containing resource types not onboarded for autogeneration | ||
// and the other item containing resource types onboarded for autogeneration | ||
allBasePaths.push({ | ||
'basePath': basePath, | ||
'onboardedToAutogen': 'no', | ||
'missing': unautogened, | ||
'included': [] | ||
}); | ||
|
||
allBasePaths.push({ | ||
'basePath': basePath, | ||
'onboardedToAutogen': 'yes', | ||
'missing': [], | ||
'included': autogened | ||
}); | ||
} | ||
else { | ||
// unautogened.length === 0 means all resource types are onboarded for autogeneration | ||
allBasePaths.push({ | ||
'basePath': basePath, | ||
'onboardedToAutogen': unautogened.length === 0 ? 'yes' : 'no', | ||
'missing': unautogened, | ||
'onboarded': [] | ||
}); | ||
} | ||
} | ||
|
||
const autogenResultPath = path.join(constants.autogenResultPath, 'result.json'); | ||
await safeMkdir(constants.autogenResultPath); | ||
await writeJsonFile(autogenResultPath, allBasePaths); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters