From 7c73e1be707d86b8a2f5b69a64832a66143818c1 Mon Sep 17 00:00:00 2001 From: MatteoDelOmbra Date: Wed, 10 Dec 2025 10:18:19 +0100 Subject: [PATCH] init --- .github/workflows/Install_release.yml | 16 + .github/workflows/Install_test_on_main.yml | 21 + .github/workflows/Install_test_on_push.yml | 22 + Frends.Python.Install/.gitignore | 421 ++++++++++++++++++ Frends.Python.Install/CHANGELOG.md | 7 + .../ErrorHandlerTest.cs | 54 +++ .../Frends.Python.Install.Tests.csproj | 18 + .../GlobalSuppressions.cs | 7 + .../Frends.Python.Install.Tests/UnitTests.cs | 23 + .../Frends.Python.Install.sln | 40 ++ .../Definitions/Connection.cs | 20 + .../Definitions/Error.cs | 22 + .../Definitions/Input.cs | 25 ++ .../Definitions/Options.cs | 33 ++ .../Definitions/Result.cs | 25 ++ .../Frends.Python.Install.cs | 57 +++ .../Frends.Python.Install.csproj | 35 ++ .../FrendsTaskMetadata.json | 7 + .../GlobalSuppressions.cs | 9 + .../Helpers/ErrorHandler.cs | 24 + .../Frends.Python.Install/migration.json | 12 + Frends.Python.Install/LICENSE | 21 + Frends.Python.Install/README.md | 34 ++ 23 files changed, 953 insertions(+) create mode 100644 .github/workflows/Install_release.yml create mode 100644 .github/workflows/Install_test_on_main.yml create mode 100644 .github/workflows/Install_test_on_push.yml create mode 100644 Frends.Python.Install/.gitignore create mode 100644 Frends.Python.Install/CHANGELOG.md create mode 100644 Frends.Python.Install/Frends.Python.Install.Tests/ErrorHandlerTest.cs create mode 100644 Frends.Python.Install/Frends.Python.Install.Tests/Frends.Python.Install.Tests.csproj create mode 100644 Frends.Python.Install/Frends.Python.Install.Tests/GlobalSuppressions.cs create mode 100644 Frends.Python.Install/Frends.Python.Install.Tests/UnitTests.cs create mode 100644 Frends.Python.Install/Frends.Python.Install.sln create mode 100644 Frends.Python.Install/Frends.Python.Install/Definitions/Connection.cs create mode 100644 Frends.Python.Install/Frends.Python.Install/Definitions/Error.cs create mode 100644 Frends.Python.Install/Frends.Python.Install/Definitions/Input.cs create mode 100644 Frends.Python.Install/Frends.Python.Install/Definitions/Options.cs create mode 100644 Frends.Python.Install/Frends.Python.Install/Definitions/Result.cs create mode 100644 Frends.Python.Install/Frends.Python.Install/Frends.Python.Install.cs create mode 100644 Frends.Python.Install/Frends.Python.Install/Frends.Python.Install.csproj create mode 100644 Frends.Python.Install/Frends.Python.Install/FrendsTaskMetadata.json create mode 100644 Frends.Python.Install/Frends.Python.Install/GlobalSuppressions.cs create mode 100644 Frends.Python.Install/Frends.Python.Install/Helpers/ErrorHandler.cs create mode 100644 Frends.Python.Install/Frends.Python.Install/migration.json create mode 100644 Frends.Python.Install/LICENSE create mode 100644 Frends.Python.Install/README.md diff --git a/.github/workflows/Install_release.yml b/.github/workflows/Install_release.yml new file mode 100644 index 0000000..64621aa --- /dev/null +++ b/.github/workflows/Install_release.yml @@ -0,0 +1,16 @@ +name: Install_release +permissions: + contents: write + +on: + workflow_dispatch: + +jobs: + build: + uses: FrendsPlatform/FrendsTasks/.github/workflows/release.yml@main + with: + workdir: Frends.Python.Install + dotnet_version: 8.0.x + strict_analyzers: true + secrets: + feed_api_key: ${{ secrets.TASKS_FEED_API_KEY }} diff --git a/.github/workflows/Install_test_on_main.yml b/.github/workflows/Install_test_on_main.yml new file mode 100644 index 0000000..f855f9b --- /dev/null +++ b/.github/workflows/Install_test_on_main.yml @@ -0,0 +1,21 @@ +name: Install_test_on_main +permissions: + contents: read + +on: + push: + branches: + - main + paths: + - 'Frends.Python.Install/**' + workflow_dispatch: + +jobs: + build: + uses: FrendsPlatform/FrendsTasks/.github/workflows/linux_build_main.yml@main + with: + workdir: Frends.Python.Install + dotnet_version: 8.0.x + strict_analyzers: true + secrets: + badge_service_api_key: ${{ secrets.BADGE_SERVICE_API_KEY }} diff --git a/.github/workflows/Install_test_on_push.yml b/.github/workflows/Install_test_on_push.yml new file mode 100644 index 0000000..1623e7e --- /dev/null +++ b/.github/workflows/Install_test_on_push.yml @@ -0,0 +1,22 @@ +name: Install_test_on_push +permissions: + contents: read + +on: + push: + branches-ignore: + - main + paths: + - 'Frends.Python.Install/**' + workflow_dispatch: + +jobs: + build: + uses: FrendsPlatform/FrendsTasks/.github/workflows/linux_build_test.yml@main + with: + workdir: Frends.Python.Install + dotnet_version: 8.0.x + strict_analyzers: true + secrets: + badge_service_api_key: ${{ secrets.BADGE_SERVICE_API_KEY }} + test_feed_api_key: ${{ secrets.TASKS_TEST_FEED_API_KEY }} diff --git a/Frends.Python.Install/.gitignore b/Frends.Python.Install/.gitignore new file mode 100644 index 0000000..c393ab5 --- /dev/null +++ b/Frends.Python.Install/.gitignore @@ -0,0 +1,421 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates +*.env + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +[Aa][Rr][Mm]64[Ee][Cc]/ +bld/ +[Oo]bj/ +[Oo]ut/ +[Ll]og/ +[Ll]ogs/ + +# Build results on 'Bin' directories +**/[Bb]in/* +# Uncomment if you have tasks that rely on *.refresh files to move binaries +# (https://github.com/github/gitignore/pull/3736) +#!**/[Bb]in/*.refresh + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* +*.trx + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Approval Tests result files +*.received.* + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.idb +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +# but not Directory.Build.rsp, as it configures directory-level build defaults +!Directory.Build.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +**/.paket/paket.exe +paket-files/ + +# FAKE - F# Make +**/.fake/ + +# CodeRush personal settings +**/.cr/personal + +# Python Tools for Visual Studio (PTVS) +**/__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +#tools/** +#!tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog +MSBuild_Logs/ + +# AWS SAM Build and Temporary Artifacts folder +.aws-sam + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +**/.mfractor/ + +# Local History for Visual Studio +**/.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +**/.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# Rider idea files +.idea/ diff --git a/Frends.Python.Install/CHANGELOG.md b/Frends.Python.Install/CHANGELOG.md new file mode 100644 index 0000000..62a3c2c --- /dev/null +++ b/Frends.Python.Install/CHANGELOG.md @@ -0,0 +1,7 @@ +# Changelog + +## [1.0.0] - 2025-12-10 + +### Added + +- Initial implementation diff --git a/Frends.Python.Install/Frends.Python.Install.Tests/ErrorHandlerTest.cs b/Frends.Python.Install/Frends.Python.Install.Tests/ErrorHandlerTest.cs new file mode 100644 index 0000000..901c130 --- /dev/null +++ b/Frends.Python.Install/Frends.Python.Install.Tests/ErrorHandlerTest.cs @@ -0,0 +1,54 @@ +using System; +using System.Threading; +using Frends.Python.Install.Definitions; +using NUnit.Framework; + +namespace Frends.Python.Install.Tests; + +// TODO: Adjust the test to use a real invalid Input scenario (e.g., missing or malformed data) +[TestFixture] +public class ErrorHandlerTest +{ + private const string CustomErrorMessage = "CustomErrorMessage"; + + [Test] + public void Should_Throw_Error_When_ThrowErrorOnFailure_Is_True() + { + var ex = Assert.Throws(() => + Python.Install(DefaultInput(), DefaultConnection(), DefaultOptions(), CancellationToken.None)); + Assert.That(ex, Is.Not.Null); + } + + [Test] + public void Should_Return_Failed_Result_When_ThrowErrorOnFailure_Is_False() + { + var options = DefaultOptions(); + options.ThrowErrorOnFailure = false; + var result = Python.Install(DefaultInput(), DefaultConnection(), options, CancellationToken.None); + Assert.That(result.Success, Is.False); + } + + [Test] + public void Should_Use_Custom_ErrorMessageOnFailure() + { + var options = DefaultOptions(); + options.ErrorMessageOnFailure = CustomErrorMessage; + var ex = Assert.Throws(() => + Python.Install(DefaultInput(), DefaultConnection(), options, CancellationToken.None)); + Assert.That(ex, Is.Not.Null); + Assert.That(ex.Message, Contains.Substring(CustomErrorMessage)); + } + + private static Input DefaultInput() => new() + { + Repeat = -1, // Invalid value to cause an exception + }; + + private static Connection DefaultConnection() => new(); + + private static Options DefaultOptions() => new() + { + ThrowErrorOnFailure = true, + ErrorMessageOnFailure = string.Empty, + }; +} diff --git a/Frends.Python.Install/Frends.Python.Install.Tests/Frends.Python.Install.Tests.csproj b/Frends.Python.Install/Frends.Python.Install.Tests/Frends.Python.Install.Tests.csproj new file mode 100644 index 0000000..50146c9 --- /dev/null +++ b/Frends.Python.Install/Frends.Python.Install.Tests/Frends.Python.Install.Tests.csproj @@ -0,0 +1,18 @@ + + + net8.0 + false + disable + + + + + + + + + + + + + diff --git a/Frends.Python.Install/Frends.Python.Install.Tests/GlobalSuppressions.cs b/Frends.Python.Install/Frends.Python.Install.Tests/GlobalSuppressions.cs new file mode 100644 index 0000000..f05c0f6 --- /dev/null +++ b/Frends.Python.Install/Frends.Python.Install.Tests/GlobalSuppressions.cs @@ -0,0 +1,7 @@ +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage("StyleCop.CSharp.SpecialRules", "SA0001::XmlCommentAnalysisDisabled", Justification = "Following Frends documentation guidelines")] +[assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1200:UsingDirectivesMustBePlacedWithinNamespace", Justification = "Following Frends documentation guidelines")] +[assembly: SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1503:BracesMustNotBeOmitted", Justification = "Following Frends documentation guidelines")] +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", Justification = "Documentation checked by custom analyzers")] +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1633:FileMustHaveHeader", Justification = "Following Frends documentation guidelines")] diff --git a/Frends.Python.Install/Frends.Python.Install.Tests/UnitTests.cs b/Frends.Python.Install/Frends.Python.Install.Tests/UnitTests.cs new file mode 100644 index 0000000..6c7e0f6 --- /dev/null +++ b/Frends.Python.Install/Frends.Python.Install.Tests/UnitTests.cs @@ -0,0 +1,23 @@ +using System.Threading; +using Frends.Python.Install.Definitions; +using NUnit.Framework; + +namespace Frends.Python.Install.Tests; + +[TestFixture] +public class UnitTests +{ + [Test] + public void ShouldRepeatContentWithDelimiter() + { + var input = new Input { Content = "foobar", Repeat = 3 }; + + var connection = new Connection { ConnectionString = "Host=127.0.0.1;Port=12345" }; + + var options = new Options { Delimiter = ", ", ThrowErrorOnFailure = true, ErrorMessageOnFailure = null }; + + var result = Python.Install(input, connection, options, CancellationToken.None); + + Assert.That(result.Output, Is.EqualTo("foobar, foobar, foobar")); + } +} diff --git a/Frends.Python.Install/Frends.Python.Install.sln b/Frends.Python.Install/Frends.Python.Install.sln new file mode 100644 index 0000000..f7cbbe1 --- /dev/null +++ b/Frends.Python.Install/Frends.Python.Install.sln @@ -0,0 +1,40 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.32112.339 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Frends.Python.Install", "Frends.Python.Install\Frends.Python.Install.csproj", "{35C305C0-8108-4A98-BB1D-AFE5C926239E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Frends.Python.Install.Tests", "Frends.Python.Install.Tests\Frends.Python.Install.Tests.csproj", "{8CA92187-8E4F-4414-803B-EC899479022E}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{78F7F22E-6E20-4BCE-8362-0C558568B729}" + ProjectSection(SolutionItems) = preProject + CHANGELOG.md = CHANGELOG.md + ..\.github\workflows\Install_test_on_main.yml = ..\.github\workflows\Install_test_on_main.yml + ..\.github\workflows\Install_test_on_push.yml = ..\.github\workflows\Install_test_on_push.yml + ..\.github\workflows\Install_release.yml = ..\.github\workflows\Install_release.yml + README.md = README.md + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {35C305C0-8108-4A98-BB1D-AFE5C926239E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {35C305C0-8108-4A98-BB1D-AFE5C926239E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {35C305C0-8108-4A98-BB1D-AFE5C926239E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {35C305C0-8108-4A98-BB1D-AFE5C926239E}.Release|Any CPU.Build.0 = Release|Any CPU + {8CA92187-8E4F-4414-803B-EC899479022E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8CA92187-8E4F-4414-803B-EC899479022E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8CA92187-8E4F-4414-803B-EC899479022E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8CA92187-8E4F-4414-803B-EC899479022E}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {55BC6629-85C9-48D8-8CA2-B0046AF1AF4B} + EndGlobalSection +EndGlobal diff --git a/Frends.Python.Install/Frends.Python.Install/Definitions/Connection.cs b/Frends.Python.Install/Frends.Python.Install/Definitions/Connection.cs new file mode 100644 index 0000000..0168161 --- /dev/null +++ b/Frends.Python.Install/Frends.Python.Install/Definitions/Connection.cs @@ -0,0 +1,20 @@ +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; + +namespace Frends.Python.Install.Definitions; + +// TODO: Remove this class if the task does not make connections + +/// +/// Connection parameters. +/// +public class Connection +{ + /// + /// Connection string to the target service (e.g., database, API endpoint). + /// + /// Host=127.0.0.1;Port=5432 + [DisplayFormat(DataFormatString = "Text")] + [DefaultValue("")] + public string ConnectionString { get; set; } = string.Empty; +} diff --git a/Frends.Python.Install/Frends.Python.Install/Definitions/Error.cs b/Frends.Python.Install/Frends.Python.Install/Definitions/Error.cs new file mode 100644 index 0000000..722841a --- /dev/null +++ b/Frends.Python.Install/Frends.Python.Install/Definitions/Error.cs @@ -0,0 +1,22 @@ +using System; + +namespace Frends.Python.Install.Definitions; + +/// +/// Error that occurred during the task. +/// +public class Error +{ + /// + /// Summary of the error. + /// + /// Unable to join strings. + public string Message { get; set; } + + /// + /// Additional information about the error. + /// + /// object { Exception AdditionalInfo } + // TODO: Add task specific additional information. Strong typing is recommended when reasonable. + public Exception AdditionalInfo { get; set; } +} diff --git a/Frends.Python.Install/Frends.Python.Install/Definitions/Input.cs b/Frends.Python.Install/Frends.Python.Install/Definitions/Input.cs new file mode 100644 index 0000000..bedf03d --- /dev/null +++ b/Frends.Python.Install/Frends.Python.Install/Definitions/Input.cs @@ -0,0 +1,25 @@ +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; + +namespace Frends.Python.Install.Definitions; + +/// +/// Essential parameters. +/// +public class Input +{ + /// + /// The input string to be repeated and output. + /// + /// foobar + [DisplayFormat(DataFormatString = "Text")] + [DefaultValue("Lorem ipsum dolor sit amet.")] + public string Content { get; set; } + + /// + /// Number of times to repeat the input string. + /// + /// 2 + [DefaultValue(3)] + public int Repeat { get; set; } +} diff --git a/Frends.Python.Install/Frends.Python.Install/Definitions/Options.cs b/Frends.Python.Install/Frends.Python.Install/Definitions/Options.cs new file mode 100644 index 0000000..f86704f --- /dev/null +++ b/Frends.Python.Install/Frends.Python.Install/Definitions/Options.cs @@ -0,0 +1,33 @@ +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; + +namespace Frends.Python.Install.Definitions; + +/// +/// Additional parameters. +/// +public class Options +{ + /// + /// Delimiter to use between the repeated strings. + /// + /// , + [DisplayFormat(DataFormatString = "Text")] + [DefaultValue(" ")] + public string Delimiter { get; set; } + + /// + /// Whether to throw an error on failure. + /// + /// true + [DefaultValue(true)] + public bool ThrowErrorOnFailure { get; set; } = true; + + /// + /// Overrides the error message on failure. + /// + /// Custom error message + [DisplayFormat(DataFormatString = "Text")] + [DefaultValue("")] + public string ErrorMessageOnFailure { get; set; } = string.Empty; +} diff --git a/Frends.Python.Install/Frends.Python.Install/Definitions/Result.cs b/Frends.Python.Install/Frends.Python.Install/Definitions/Result.cs new file mode 100644 index 0000000..5424fc1 --- /dev/null +++ b/Frends.Python.Install/Frends.Python.Install/Definitions/Result.cs @@ -0,0 +1,25 @@ +namespace Frends.Python.Install.Definitions; + +/// +/// Result of the task. +/// +public class Result +{ + /// + /// Indicates if the task completed successfully. + /// + /// true + public bool Success { get; set; } + + /// + /// Input string repeated the specified number of times. + /// + /// foobar,foobar + public string Output { get; set; } + + /// + /// Error that occurred during task execution. + /// + /// object { string Message, Exception AdditionalInfo } + public Error Error { get; set; } +} diff --git a/Frends.Python.Install/Frends.Python.Install/Frends.Python.Install.cs b/Frends.Python.Install/Frends.Python.Install/Frends.Python.Install.cs new file mode 100644 index 0000000..c772cad --- /dev/null +++ b/Frends.Python.Install/Frends.Python.Install/Frends.Python.Install.cs @@ -0,0 +1,57 @@ +using System; +using System.ComponentModel; +using System.Linq; +using System.Threading; +using Frends.Python.Install.Definitions; +using Frends.Python.Install.Helpers; + +namespace Frends.Python.Install; + +/// +/// Task Class for Python operations. +/// +public static class Python +{ + /// + /// Task to install Python on machine + /// [Documentation](https://tasks.frends.com/tasks/frends-tasks/Frends-Python-Install) + /// + /// Essential parameters. + /// Connection parameters. + /// x. + /// A cancellation token provided by Frends Platform. + /// object { bool Success, string Output, object Error { string Message, Exception AdditionalInfo } } + // TODO: Remove Connection parameter if the task does not make connections + public static Result Install( + [PropertyTab] Input input, + [PropertyTab] Connection connection, + [PropertyTab] Options options, + CancellationToken cancellationToken) + { + try + { + // TODO: Do something with connection parameters, e.g., connect to a service. + _ = connection.ConnectionString; + + // Cancellation token should be provided to methods that support it + // and checked during long-running operations, e.g., loops + cancellationToken.ThrowIfCancellationRequested(); + + if (input.Repeat < 0) + throw new Exception("Repeat count cannot be negative."); + + var output = string.Join(options.Delimiter, Enumerable.Repeat(input.Content, input.Repeat)); + + return new Result + { + Success = true, + Output = output, + Error = null, + }; + } + catch (Exception ex) + { + return ErrorHandler.Handle(ex, options.ThrowErrorOnFailure, options.ErrorMessageOnFailure); + } + } +} diff --git a/Frends.Python.Install/Frends.Python.Install/Frends.Python.Install.csproj b/Frends.Python.Install/Frends.Python.Install/Frends.Python.Install.csproj new file mode 100644 index 0000000..b3cc1ce --- /dev/null +++ b/Frends.Python.Install/Frends.Python.Install/Frends.Python.Install.csproj @@ -0,0 +1,35 @@ + + + net8.0 + latest + 1.0.0 + Frends + Copyright (c) 2025 Frends EiPaaS + Frends + Frends + Frends + MIT + true + Task to install Python on machine + https://frends.com/ + https://github.com/FrendsPlatform/Frends.Python/tree/main/Frends.Python.Install + disable + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + diff --git a/Frends.Python.Install/Frends.Python.Install/FrendsTaskMetadata.json b/Frends.Python.Install/Frends.Python.Install/FrendsTaskMetadata.json new file mode 100644 index 0000000..5e63453 --- /dev/null +++ b/Frends.Python.Install/Frends.Python.Install/FrendsTaskMetadata.json @@ -0,0 +1,7 @@ +{ + "Tasks": [ + { + "TaskMethod": "Frends.Python.Install.Python.Install" + } + ] +} diff --git a/Frends.Python.Install/Frends.Python.Install/GlobalSuppressions.cs b/Frends.Python.Install/Frends.Python.Install/GlobalSuppressions.cs new file mode 100644 index 0000000..87e3388 --- /dev/null +++ b/Frends.Python.Install/Frends.Python.Install/GlobalSuppressions.cs @@ -0,0 +1,9 @@ +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1200:UsingDirectivesMustBePlacedWithinNamespace", Justification = "Following Frends documentation guidelines")] +[assembly: SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1503:BracesMustNotBeOmitted", Justification = "Following Frends documentation guidelines")] +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", Justification = "Documentation checked by custom analyzers")] +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1623:PropertySummaryDocumentationMustMatchAccessors", Justification = "Following Frends Tasks guidelines")] +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1629:DocumentationTextMustEndWithAPeriod", Justification = "Following Frends Tasks guidelines")] +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1633:FileMustHaveHeader", Justification = "Following Frends documentation guidelines")] +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1649:FileNameMustMatchTypeName", Justification = "Following Frends Tasks guidelines")] diff --git a/Frends.Python.Install/Frends.Python.Install/Helpers/ErrorHandler.cs b/Frends.Python.Install/Frends.Python.Install/Helpers/ErrorHandler.cs new file mode 100644 index 0000000..3619f96 --- /dev/null +++ b/Frends.Python.Install/Frends.Python.Install/Helpers/ErrorHandler.cs @@ -0,0 +1,24 @@ +using System; +using Frends.Python.Install.Definitions; + +namespace Frends.Python.Install.Helpers; + +internal static class ErrorHandler +{ + internal static Result Handle(Exception exception, bool throwOnFailure, string errorMessageOnFailure) + { + if (throwOnFailure) + { + if (string.IsNullOrEmpty(errorMessageOnFailure)) + throw new Exception(exception.Message, exception); + + throw new Exception(errorMessageOnFailure, exception); + } + + var errorMessage = !string.IsNullOrEmpty(errorMessageOnFailure) + ? $"{errorMessageOnFailure}: {exception.Message}" + : exception.Message; + + return new Result { Success = false, Error = new Error { Message = errorMessage, AdditionalInfo = exception } }; + } +} diff --git a/Frends.Python.Install/Frends.Python.Install/migration.json b/Frends.Python.Install/Frends.Python.Install/migration.json new file mode 100644 index 0000000..e6ea1eb --- /dev/null +++ b/Frends.Python.Install/Frends.Python.Install/migration.json @@ -0,0 +1,12 @@ +[ + { + "Task": "Frends.Python.Install", + "Migrations": [ + { + "Version": "1.0.0", + "Description": "", + "Migration": [] + } + ] + } +] \ No newline at end of file diff --git a/Frends.Python.Install/LICENSE b/Frends.Python.Install/LICENSE new file mode 100644 index 0000000..14c1e18 --- /dev/null +++ b/Frends.Python.Install/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Frends EiPaaS + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Frends.Python.Install/README.md b/Frends.Python.Install/README.md new file mode 100644 index 0000000..6444510 --- /dev/null +++ b/Frends.Python.Install/README.md @@ -0,0 +1,34 @@ +# Frends.Python.Install + +Task to install Python on machine + +[![Install_build](https://github.com/FrendsPlatform/Frends.Python/actions/workflows/Install_build_and_test_on_main.yml/badge.svg)](https://github.com/FrendsPlatform/Frends.Python/actions/workflows/Install_build_and_test_on_main.yml) +![Coverage](https://app-github-custom-badges.azurewebsites.net/Badge?key=FrendsPlatform/Frends.Python/Frends.Python.Install|main) +[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT) + +## Installing + +You can install the Task via Frends UI Task View. + +## Building + +### Clone a copy of the repository + +`git clone https://github.com/FrendsPlatform/Frends.Python.git` + +### Build the project + +`dotnet build` + +### Run tests + +Run the tests + +`dotnet test` + +### Create a NuGet package + +`dotnet pack --configuration Release` + +### StyleCop.Analyzers Version +This project uses StyleCop.Analyzers 1.2.0-beta.556, as recommended by the author, to get the latest fixes and improvements not available in the last stable release.