-
Notifications
You must be signed in to change notification settings - Fork 2
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 #1 from erikschlegel/erik/insights/initial-commit
Initial commit for ADO Insights Provider Implementation
- Loading branch information
Showing
27 changed files
with
2,141 additions
and
9 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,3 @@ | ||
# Find the Dockerfile for mcr.microsoft.com/azure-functions/python:3.0-python3.8-core-tools at this URL | ||
# https://github.com/Azure/azure-functions-docker/blob/master/host/3.0/buster/amd64/python/python38/python38-core-tools.Dockerfile | ||
FROM mcr.microsoft.com/azure-functions/python:3.0-python3.8-core-tools |
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,24 @@ | ||
{ | ||
"name": "Azure Functions & Python 3", | ||
"dockerFile": "Dockerfile", | ||
"forwardPorts": [ 7071 ], | ||
"mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ], | ||
|
||
// Set *default* container specific settings.json values on container create. | ||
"settings": { | ||
"terminal.integrated.shell.linux": "/bin/bash" | ||
}, | ||
|
||
// Add the IDs of extensions you want installed when the container is created. | ||
"extensions": [ | ||
"ms-azuretools.vscode-azurefunctions", | ||
"ms-azuretools.vscode-docker", | ||
"ms-python.python" | ||
], | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
// "postCreateCommand": "npm install", | ||
|
||
// Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root. | ||
// "remoteUser": "vscode" | ||
} |
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,5 @@ | ||
.git* | ||
.vscode | ||
local.settings.json | ||
test | ||
.venv |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"recommendations": [ | ||
"ms-azuretools.vscode-azurefunctions", | ||
"ms-python.python" | ||
] | ||
} |
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,13 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Attach to Python Functions", | ||
"type": "python", | ||
"request": "attach", | ||
"port": 9091, | ||
"preLaunchTask": "func: host start", | ||
"justMyCode": false | ||
} | ||
] | ||
} |
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,20 @@ | ||
{ | ||
"azureFunctions.deploySubpath": ".", | ||
"azureFunctions.scmDoBuildDuringDeployment": true, | ||
"azureFunctions.pythonVenv": ".venv", | ||
"azureFunctions.projectLanguage": "Python", | ||
"azureFunctions.projectRuntime": "~3", | ||
"debug.internalConsoleOptions": "neverOpen", | ||
"python.pythonPath": ".venv/bin/python", | ||
"python.testing.unittestArgs": [ | ||
"-v", | ||
"-s", | ||
"./GitInsights/tests", | ||
"-p", | ||
"test_*.py" | ||
], | ||
"python.testing.pytestEnabled": false, | ||
"python.testing.autoTestDiscoverOnSaveEnabled": true, | ||
"python.testing.nosetestsEnabled": false, | ||
"python.testing.unittestEnabled": true | ||
} |
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,26 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"type": "func", | ||
"command": "host start", | ||
"problemMatcher": "$func-python-watch", | ||
"isBackground": true, | ||
"dependsOn": "pipInstall" | ||
}, | ||
{ | ||
"label": "pipInstall", | ||
"type": "shell", | ||
"osx": { | ||
"command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt" | ||
}, | ||
"windows": { | ||
"command": "${config:azureFunctions.pythonVenv}/Scripts/python -m pip install -r requirements.txt" | ||
}, | ||
"linux": { | ||
"command": "${config:azureFunctions.pythonVenv}/bin/pip install -r requirements.txt" | ||
}, | ||
"problemMatcher": [] | ||
} | ||
] | ||
} |
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,42 @@ | ||
import datetime | ||
import json | ||
import logging | ||
import os | ||
|
||
import azure.functions as func | ||
|
||
from .mods.ado_client import AzureDevopsInsights | ||
from .mods.kv_client import KeyvaultClient | ||
|
||
def main(mytimer: func.TimerRequest, outputBlob: func.Out[func.InputStream]) -> None: | ||
# Required settings | ||
keyVaultName = os.environ["KeyvaultName"] | ||
patSecretName = os.environ["PatSecretName"] | ||
adoProject = os.environ["AdoProjectName"] | ||
adoOrg = os.environ["AdoOrgName"] | ||
repos = os.environ["AdoRepos"] | ||
teamId = os.environ["BacklogTeamId"] | ||
|
||
# Optional settings | ||
profileAliasOverrides = os.environ.get("ProfileAliases", "{}") # Accounts for local git profile setup discrepencies | ||
aliasDict = json.loads(profileAliasOverrides.replace("\'", "\"")) | ||
|
||
groupByColumns = ['contributor', 'week', 'repo'] | ||
|
||
if not keyVaultName or not patSecretName or not adoProject or not adoOrg or not repos: | ||
raise ValueError('Required environment variables are undefined') | ||
|
||
kvURI = f"https://{keyVaultName}.vault.azure.net" | ||
patToken = KeyvaultClient(kvURI).getSecretValue(patSecretName) | ||
|
||
utc_timestamp = datetime.datetime.utcnow().replace( | ||
tzinfo=datetime.timezone.utc).isoformat() | ||
|
||
if mytimer.past_due: | ||
logging.info('The timer is past due!') | ||
|
||
client = AzureDevopsInsights(adoOrg, adoProject, repos.split(','), teamId, aliasDict) | ||
dataframe = client.aggregatePullRequestActivity(groupByColumns, patToken.value) | ||
outputBlob.set(dataframe.to_csv(index=True)) | ||
|
||
logging.info('Python timer trigger function ran at %s', utc_timestamp) |
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,20 @@ | ||
{ | ||
"scriptFile": "__init__.py", | ||
"bindings": [ | ||
{ | ||
"name": "mytimer", | ||
"type": "timerTrigger", | ||
"direction": "in", | ||
"useMonitor": true, | ||
"schedule": "0 */3 * * * *", | ||
"runOnStartup": false | ||
}, | ||
{ | ||
"type": "blob", | ||
"direction": "out", | ||
"name": "outputBlob", | ||
"path": "outcontainer/{DateTime}.csv", | ||
"connection": "gitinsights_STORAGE" | ||
} | ||
] | ||
} |
Empty file.
Oops, something went wrong.