Skip to content

Commit

Permalink
Merge pull request #4 from nexus-main/reenable-python
Browse files Browse the repository at this point in the history
Reenable python
  • Loading branch information
Apollo3zehn authored Jan 21, 2025
2 parents ab77e93 + 514873c commit 4345b7c
Show file tree
Hide file tree
Showing 42 changed files with 879 additions and 411 deletions.
75 changes: 43 additions & 32 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,19 @@ jobs:
uses: actions/setup-dotnet@v4
with:
dotnet-version: "9.0.x"
dotnet-quality: "preview"

# - name: Set up Python
# uses: actions/setup-python@v3
# with:
# python-version: '3.9'
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.10"

- name: Create Docker Output Folder
run: mkdir --parent artifacts/images

# - name: Install
# run: |
# npm install -g pyright
# python -m pip install build wheel pytest pytest-asyncio
# python -m pip install --pre --index-url https://www.myget.org/F/apollo3zehn-dev/python/ nexus-extensibility
- name: Install
run: |
npm install -g pyright
python -m pip install -r requirements.txt
- name: Docker Setup
id: buildx
Expand All @@ -66,18 +64,21 @@ jobs:
- name: Build
run: |
dotnet publish -c Release -o app /p:GeneratePackage=true src/agent/dotnet/agent.csproj
# python -m build --wheel --outdir artifacts/package --no-isolation src/remoting/python
python -m build --wheel --outdir artifacts/package --no-isolation src/remoting/python
- name: Test
run: |
dotnet test -c Release
# pyright
# pytest
pyright
pytest
- name: Docker Build
run: |
docker build -t nexus-main/nexus-agent:v_next -f src/agent/dotnet/Dockerfile .
docker save --output artifacts/images/nexus_agent_image.tar nexus-main/nexus-agent:v_next
docker build -t nexus-main/nexus-agent-dotnet:v_next -f src/agent/dotnet/Dockerfile .
docker save --output artifacts/images/nexus_agent_dotnet_image.tar nexus-main/nexus-agent-dotnet:v_next
docker build -t nexus-main/nexus-agent-python:v_next -f src/agent/dotnet/Dockerfile .
docker save --output artifacts/images/nexus_agent_python_image.tar nexus-main/nexus-agent-python:v_next
- name: Upload Artifacts
uses: actions/upload-artifact@v3
Expand Down Expand Up @@ -109,17 +110,19 @@ jobs:
path: artifacts

- name: Docker Load Image
run: docker load --input artifacts/images/nexus_agent_image.tar
run: |
docker load --input artifacts/images/nexus_agent_dotnet_image.tar
docker load --input artifacts/images/nexus_agent_python_image.tar
- name: Nuget package (MyGet)
run: dotnet nuget push 'artifacts/package/release/*.nupkg' --api-key ${MYGET_API_KEY} --source https://www.myget.org/F/apollo3zehn-dev/api/v3/index.json
env:
MYGET_API_KEY: ${{ secrets.MYGET_API_KEY }}

# - name: Python package (MyGet)
# run: 'for filePath in artifacts/package/*.whl; do curl -k -X POST https://www.myget.org/F/apollo3zehn-dev/python/upload -H "Authorization: Bearer ${MYGET_API_KEY}" -F "data=@$filePath"; done'
# env:
# MYGET_API_KEY: ${{ secrets.MYGET_API_KEY }}
- name: Python package (MyGet)
run: 'for filePath in artifacts/package/*.whl; do curl -k -X POST https://www.myget.org/F/apollo3zehn-dev/python/upload -H "Authorization: Bearer ${MYGET_API_KEY}" -F "data=@$filePath"; done'
env:
MYGET_API_KEY: ${{ secrets.MYGET_API_KEY }}

- name: Docker Login (Github Container Registry)
uses: docker/login-action@v1
Expand All @@ -130,8 +133,11 @@ jobs:

- name: Docker Push
run: |
docker tag nexus-main/nexus-agent:v_next ghcr.io/nexus-main/nexus-agent:${{ needs.build.outputs.version }}
docker push ghcr.io/nexus-main/nexus-agent:${{ needs.build.outputs.version }}
docker tag nexus-main/nexus-agent-dotnet:v_next ghcr.io/nexus-main/nexus-agent-dotnet:${{ needs.build.outputs.version }}
docker push ghcr.io/nexus-main/nexus-agent-dotnet:${{ needs.build.outputs.version }}
docker tag nexus-main/nexus-agent-python:v_next ghcr.io/nexus-main/nexus-agent-python:${{ needs.build.outputs.version }}
docker push ghcr.io/nexus-main/nexus-agent-python:${{ needs.build.outputs.version }}
publish_release:

Expand All @@ -143,9 +149,9 @@ jobs:

steps:

# - name: Install
# run: |
# python -m pip install twine
- name: Install
run: |
python -m pip install twine
- name: Download Artifacts
uses: actions/download-artifact@v3
Expand All @@ -154,7 +160,9 @@ jobs:
path: artifacts

- name: Docker Load Image
run: docker load --input artifacts/images/nexus_agent_image.tar
run: |
docker load --input artifacts/images/nexus_agent_dotnet_image.tar
docker load --input artifacts/images/nexus_agent_python_image.tar
- name: GitHub Release Artifacts
uses: softprops/action-gh-release@v1
Expand All @@ -166,10 +174,10 @@ jobs:
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}

# - name: Python Package (PyPI)
# run: twine upload artifacts/package/*.whl -u__token__ -p"${PYPI_API_KEY}"
# env:
# PYPI_API_KEY: ${{ secrets.PYPI_API_KEY }}
- name: Python Package (PyPI)
run: twine upload artifacts/package/*.whl -u__token__ -p"${PYPI_API_KEY}"
env:
PYPI_API_KEY: ${{ secrets.PYPI_API_KEY }}

- name: Docker Login (Docker Hub)
uses: docker/login-action@v1
Expand All @@ -179,5 +187,8 @@ jobs:

- name: Docker Push
run: |
docker tag nexus-main/nexus-agent:v_next nexusmain/nexus-agent:${{ needs.build.outputs.version }}
docker push nexusmain/nexus-agent:${{ needs.build.outputs.version }}
docker tag nexus-main/nexus-agent-dotnet:v_next nexusmain/nexus-agent-dotnet:${{ needs.build.outputs.version }}
docker push nexusmain/nexus-agent-dotnet:${{ needs.build.outputs.version }}
docker tag nexus-main/nexus-agent-python:v_next nexusmain/nexus-agent-python:${{ needs.build.outputs.version }}
docker push nexusmain/nexus-agent-python:${{ needs.build.outputs.version }}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"Configuration": {
"path": "../../../tests/Nexus.Sources.Remote.Tests/dotnet",
"version": "v1",
"csproj": "remote.csproj"
"entrypoint": "test.csproj"
}
}
}
11 changes: 11 additions & 0 deletions .nexus-agent-python/config/packages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"c05b592f-e198-472d-9902-3f60cf0a6332": {
"provider": "local",
"configuration": {
"path": "../../../tests/Nexus.Sources.Remote.Tests/python",
"version": "v1",
"module-name": "foo",
"entrypoint": "test.py"
}
}
}
18 changes: 16 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"version": "0.2.0",
"configurations": [
{
"name": "Launch Nexus.Agent",
"name": "Nexus.Agent (dotnet)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build-nexus-agent",
Expand All @@ -12,7 +12,21 @@
"stopAtEntry": false,
"env": {
"ASPNETCORE_ENVIRONMENT": "Development",
"NEXUSAGENT_Paths__Config": "../../.nexus-agent/config"
"NEXUSAGENT_PATHS__CONFIG": "../../../.nexus-agent-dotnet/config",
"NEXUSAGENT_SYSTEM__JSONRPCLISTENPORT": "60000"
}
},
{
"name": "Nexus.Agent (python)",
"type": "debugpy",
"request": "launch",
"module": "fastapi",
"args": ["run", "main.py"],
"cwd": "${workspaceFolder}/src/agent/python",
"env": {
"PYTHONPATH": "${workspaceFolder}/src/remoting/python",
"NEXUSAGENT_PATHS__CONFIG": "../../../.nexus-agent-python/config",
"NEXUSAGENT_SYSTEM__JSONRPCLISTENPORT": "60001"
}
}
]
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v2.0.0-beta.40 - 2025-01-21

- Release nexus-agent-dotnet and nexus-agent-python.

## v2.0.0-beta.39 - 2025-01-08

- Release Nexus.Agent.
Expand Down
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
</RestoreAdditionalProjectSources>
<UseArtifactsOutput>true</UseArtifactsOutput>
<ArtifactsPath>$(MSBuildThisFileDirectory)artifacts</ArtifactsPath>
<NoWarn>NU1507</NoWarn>
</PropertyGroup>

</Project>
22 changes: 22 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Apollo3zehn.PackageManagement" Version="1.0.0-beta.1.19" />
<PackageVersion Include="Asp.Versioning.Mvc" Version="8.1.0" />
<PackageVersion Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.1.0" />
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="5.1.0" />
<PackageVersion Include="Moq" Version="4.20.72" />
<PackageVersion Include="Nexus.Extensibility" Version="2.0.0-beta.42" />
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="9.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageVersion Include="NSwag.AspNetCore" Version="14.1.0" />
<PackageVersion Include="Scalar.AspNetCore" Version="1.2.64" />
<PackageVersion Include="SharpZipLib" Version="1.4.2" />
<PackageVersion Include="StreamJsonRpc" Version="2.20.20" />
<PackageVersion Include="xunit" Version="2.9.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.0" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion benchmarks/Nexus.Benchmarks/Nexus.Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
<PackageReference Include="BenchmarkDotNet" />
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions pyrightconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"include": [
"src/agent/python",
"src/remoting/python",
"tests/remoting/python-tests",
"tests/Nexus.Sources.Remote.Tests/python"
Expand Down
7 changes: 7 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# keep versions in sync with src/agent/python/requirements.txt
apollo3zehn-package-management==1.0.0-b1
build
fastapi[standard]
nexus-extensibility==2.0.0-beta.42
pytest-asyncio
wheel
4 changes: 2 additions & 2 deletions src/Nexus.Sources.Remote/Nexus.Sources.Remote.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Nexus.Extensibility" Version="2.0.0-beta.34">
<PackageReference Include="Nexus.Extensibility">
<ExcludeAssets>runtime;native</ExcludeAssets>
</PackageReference>

<PackageReference Include="StreamJsonRpc" Version="2.20.20" />
<PackageReference Include="StreamJsonRpc" />
</ItemGroup>

</Project>
3 changes: 3 additions & 0 deletions src/Nexus.Sources.Remote/Remote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ public partial class Remote : IDataSource, IDisposable
private const int DEFAULT_AGENT_PORT = 56145;

private ReadDataHandler? _readData;

private static readonly int API_LEVEL = 1;

private RemoteCommunicator _communicator = default!;

private IJsonRpcServer _rpcServer = default!;

/* Possible features to be implemented for this data source:
Expand Down
39 changes: 5 additions & 34 deletions src/agent/dotnet/Controllers/PackageReferencesController.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
// MIT License
// Copyright (c) [2024] [nexus-main]

using Asp.Versioning;
using Microsoft.AspNetCore.Mvc;
using Nexus.PackageManagement.Services;
using Nexus.PackageManagement;
using Apollo3zehn.PackageManagement.Services;
using Apollo3zehn.PackageManagement;

namespace Nexus.Controllers;
namespace Nexus.Agent.Controllers;

/// <summary>
/// Provides access to package references.
Expand All @@ -15,18 +11,14 @@ namespace Nexus.Controllers;
[ApiVersion("1.0")]
[Route("api/v{version:apiVersion}/[controller]")]
internal class PackageReferencesController(
IPackageService packageService,
IExtensionHive extensionHive) : ControllerBase
IPackageService packageService) : ControllerBase
{
// GET /api/packagereferences
// POST /api/packagereferences
// DELETE /api/packagereferences/{id}
// GET /api/packagereferences/{id}/versions

private readonly IPackageService _packageService = packageService;

private readonly IExtensionHive _extensionHive = extensionHive;

/// <summary>
/// Gets the list of package references.
/// </summary>
Expand All @@ -43,7 +35,7 @@ public Task<IReadOnlyDictionary<Guid, PackageReference>> GetAsync()
/// <param name="packageReference">The package reference to create.</param>
[HttpPost]
public Task<Guid> CreateAsync(
[FromBody] PackageReference packageReference)
PackageReference packageReference)
{
return _packageService.PutAsync(packageReference);
}
Expand All @@ -58,25 +50,4 @@ public Task DeleteAsync(
{
return _packageService.DeleteAsync(id);
}

/// <summary>
/// Gets package versions.
/// </summary>
/// <param name="id">The ID of the package reference.</param>
/// <param name="cancellationToken">A token to cancel the current operation.</param>
[HttpGet("{id}/versions")]
public async Task<ActionResult<string[]>> GetVersionsAsync(
Guid id,
CancellationToken cancellationToken)
{
var packageReferenceMap = await _packageService.GetAllAsync();

if (!packageReferenceMap.TryGetValue(id, out var packageReference))
return NotFound($"Unable to find package reference with ID {id}.");

var result = await _extensionHive
.GetVersionsAsync(packageReference, cancellationToken);

return result;
}
}
Loading

0 comments on commit 4345b7c

Please sign in to comment.