Skip to content

Commit

Permalink
Ingest repo (C# only) (autogenhub#7)
Browse files Browse the repository at this point in the history
* ingest WIP function

* ingest WIP

* analyze WIP

* WIP

* ingester WIP

* ingester WIP

* ingester WIP

* fix github download

* working ingester
  • Loading branch information
kostapetan authored Nov 3, 2023
1 parent f423e15 commit ddd5fa0
Show file tree
Hide file tree
Showing 21 changed files with 1,309 additions and 102 deletions.
6 changes: 2 additions & 4 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
FROM mcr.microsoft.com/devcontainers/dotnet:0-7.0
# Install the xz-utils package
RUN apt-get update && apt-get install -y xz-utils nodejs npm
RUN apt-get update && apt-get install -y xz-utils ca-certificates curl gnupg

RUN curl -fsSL https://aka.ms/install-azd.sh | bash

RUN curl -s https://ngrok-agent.s3.amazonaws.com/ngrok.asc | \
sudo tee /etc/apt/trusted.gpg.d/ngrok.asc >/dev/null && \
echo "deb https://ngrok-agent.s3.amazonaws.com buster main" | \
sudo tee /etc/apt/sources.list.d/ngrok.list && \
sudo apt update && sudo apt install ngrok

RUN npm i -g azure-functions-core-tools@4 --unsafe-perm true
sudo apt update && sudo apt install ngrok
11 changes: 10 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@
"ghcr.io/devcontainers/features/azure-cli:1": {},
"ghcr.io/devcontainers/features/common-utils:2": {},
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/azure/azure-dev/azd:latest": {}
"ghcr.io/azure/azure-dev/azd:latest": {},
"ghcr.io/devcontainers/features/node:1": {
"nodeGypDependencies": true,
"version": "18",
"nvmVersion": "latest"
},
"ghcr.io/azure/azure-dev/azd:0": {
"version": "stable"
},
"ghcr.io/jlaundry/devcontainer-features/azure-functions-core-tools:1": {}
},
"postCreateCommand": "bash .devcontainer/startup.sh",
"hostRequirements": {
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -495,4 +495,5 @@ elsa.sqlite.*
elsa-core/
sk-azfunc-server/local.settings.json
.azure
temp
temp

25 changes: 16 additions & 9 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to .NET Functions",
"type": "coreclr",
"request": "attach",
"processId": "${command:azureFunctions.pickProcess}"
}
]
"version": "0.2.0",
"configurations": [
{
"name": "Attach to .NET Functions",
"type": "coreclr",
"request": "attach",
"processId": "${command:azureFunctions.pickProcess}"
},
{
"name": "Attach to Node Functions",
"type": "node",
"request": "attach",
"port": 9229,
"preLaunchTask": "func: host start"
}
]
}
9 changes: 6 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{
"dotnet.defaultSolution": "sk-dev-team.sln",
"azureFunctions.deploySubpath": "sk-azfunc-server/bin/Release/net7.0/publish",
"azureFunctions.projectLanguage": "C#",
"azureFunctions.deploySubpath": "src/apps/ingest",
"azureFunctions.projectLanguage": "JavaScript",
"azureFunctions.projectRuntime": "~4",
"debug.internalConsoleOptions": "neverOpen",
"azureFunctions.preDeployTask": "publish (functions)"
"azureFunctions.preDeployTask": "npm prune (functions)",
"azureFunctions.postDeployTask": "npm install (functions)",
"azureFunctions.projectLanguageModel": 4,
"azureFunctions.projectSubpath": "src/apps/ingest"
}
176 changes: 97 additions & 79 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,81 +1,99 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "clean (functions)",
"command": "dotnet",
"args": [
"clean",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"type": "process",
"problemMatcher": "$msCompile",
"options": {
"cwd": "${workspaceFolder}/sk-azfunc-server"
}
},
{
"label": "build (functions)",
"command": "dotnet",
"args": [
"build",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"type": "process",
"dependsOn": "clean (functions)",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": "$msCompile",
"options": {
"cwd": "${workspaceFolder}/sk-azfunc-server"
}
},
{
"label": "clean release (functions)",
"command": "dotnet",
"args": [
"clean",
"--configuration",
"Release",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"type": "process",
"problemMatcher": "$msCompile",
"options": {
"cwd": "${workspaceFolder}/sk-azfunc-server"
}
},
{
"label": "publish (functions)",
"command": "dotnet",
"args": [
"publish",
"--configuration",
"Release",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"type": "process",
"dependsOn": "clean release (functions)",
"problemMatcher": "$msCompile",
"options": {
"cwd": "${workspaceFolder}/sk-azfunc-server"
}
},
{
"type": "func",
"dependsOn": "build (functions)",
"options": {
"cwd": "${workspaceFolder}/sk-azfunc-server/bin/Debug/net7.0"
},
"command": "host start",
"isBackground": true,
"problemMatcher": "$func-dotnet-watch"
}
]
"version": "2.0.0",
"tasks": [
{
"label": "clean (functions)",
"command": "dotnet",
"args": [
"clean",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"type": "process",
"problemMatcher": "$msCompile",
"options": {
"cwd": "${workspaceFolder}/sk-azfunc-server"
}
},
{
"label": "build (functions)",
"command": "dotnet",
"args": [
"build",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"type": "process",
"dependsOn": "clean (functions)",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": "$msCompile",
"options": {
"cwd": "${workspaceFolder}/sk-azfunc-server"
}
},
{
"label": "clean release (functions)",
"command": "dotnet",
"args": [
"clean",
"--configuration",
"Release",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"type": "process",
"problemMatcher": "$msCompile",
"options": {
"cwd": "${workspaceFolder}/sk-azfunc-server"
}
},
{
"label": "publish (functions)",
"command": "dotnet",
"args": [
"publish",
"--configuration",
"Release",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"type": "process",
"dependsOn": "clean release (functions)",
"problemMatcher": "$msCompile",
"options": {
"cwd": "${workspaceFolder}/sk-azfunc-server"
}
},
{
"type": "func",
"label": "func: host start",
"command": "host start",
"problemMatcher": "$func-node-watch",
"isBackground": true,
"dependsOn": "npm install (functions)",
"options": {
"cwd": "${workspaceFolder}/src/apps/ingest"
}
},
{
"type": "shell",
"label": "npm install (functions)",
"command": "npm install",
"options": {
"cwd": "${workspaceFolder}/src/apps/ingest"
}
},
{
"type": "shell",
"label": "npm prune (functions)",
"command": "npm prune --production",
"problemMatcher": [],
"options": {
"cwd": "${workspaceFolder}/src/apps/ingest"
}
}
]
}
1 change: 0 additions & 1 deletion src/apps/gh-flow-df/Activities/PullRequestActivities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Azure.ResourceManager.ContainerInstance.Models;
using Azure.ResourceManager.Resources;
using Azure.Storage.Files.Shares;
using Microsoft.AspNetCore.Http;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
using Microsoft.DurableTask.Client;
Expand Down
8 changes: 8 additions & 0 deletions src/apps/gh-flow/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSingleton<WebhookEventProcessor, GithubWebHookProcessor>();
builder.Services.AddTransient(CreateKernel);
builder.Services.AddHttpClient();

builder.Services.AddSingleton(s =>
{
Expand Down Expand Up @@ -43,9 +44,15 @@
{
configuration.GetSection("QdrantOptions").Bind(settings);
});
builder.Services.AddOptions<ServiceOptions>()
.Configure<IConfiguration>((settings, configuration) =>
{
configuration.GetSection("ServiceOptions").Bind(settings);
});

builder.Services.AddSingleton<IManageAzure, AzureService>();
builder.Services.AddSingleton<IManageGithub, GithubService>();
builder.Services.AddSingleton<IAnalyzeCode, CodeAnalyzer>();


builder.Host.UseOrleans(siloBuilder =>
Expand Down Expand Up @@ -130,6 +137,7 @@
endpoints.MapGitHubWebhooks();
});


app.Run();

static IKernel CreateKernel(IServiceProvider provider)
Expand Down
19 changes: 19 additions & 0 deletions src/apps/gh-flow/Services/GithubWebHookProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Microsoft.AI.DevTeam.Skills;
using Octokit.Webhooks;
using Octokit.Webhooks.Events;
using Octokit.Webhooks.Events.CommitComment;
using Octokit.Webhooks.Events.IssueComment;
using Octokit.Webhooks.Events.Issues;
using Octokit.Webhooks.Models;
Expand Down Expand Up @@ -62,6 +63,19 @@ protected override async Task ProcessIssueCommentWebhookAsync(
}
}

// TODO: implement
protected override Task ProcessPushWebhookAsync(WebhookHeaders headers, PushEvent pushEvent)
{
var org = pushEvent.Organization.Login;
var repo = pushEvent.Repository.Name;
// Assumes the label follows the following convention: Skill.Function example: PM.Readme

var suffix = $"{org}-{repo}";
var ingester = _grains.GetGrain<IIngestRepo>(suffix);

return Task.CompletedTask;
}

private async Task HandleClosingIssue(long issueNumber, string skillName, string functionName, string suffix, string org, string repo)
{
if (skillName == nameof(PM) && functionName == nameof(PM.Readme))
Expand Down Expand Up @@ -183,6 +197,11 @@ private async Task HandleNewAsk(long issueNumber, string skillName, string funct
var conductor = _grains.GetGrain<IOrchestrateWorkflows>(issueNumber, suffix);
await conductor.InitialFlow(input, org, repo, issueNumber);
}
else if (skillName == "Repo" && functionName == "Ingest")
{
var ingestor = _grains.GetGrain<IIngestRepo>(suffix);
await ingestor.IngestionFlow(org, repo, "main");
}
else if (skillName == nameof(PM) && functionName == nameof(PM.Readme))
{
var pm = _grains.GetGrain<IManageProduct>(issueNumber, suffix);
Expand Down
1 change: 1 addition & 0 deletions src/apps/gh-flow/gh-flow.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<PackageReference Include="Microsoft.Orleans.Clustering.Cosmos" Version="7.2.1" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.21.0" />
<PackageReference Include="Microsoft.Orleans.Reminders.Cosmos" Version="7.2.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>


Expand Down
10 changes: 10 additions & 0 deletions src/apps/ingest/.funcignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*.js.map
*.ts
.git*
.vscode
__azurite_db*__.json
__blobstorage__
__queuestorage__
local.settings.json
test
tsconfig.json
Loading

0 comments on commit ddd5fa0

Please sign in to comment.