Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions .github/workflows/DoNothing_build_and_test_on_main.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
name: DoNothing Main
permissions:
contents: read

on:
push:
branches:
branches:
- main
paths:
- 'Frends.TestTask.DoNothing/**'
- '.github/workflows/**'
workflow_dispatch:

jobs:
linux_build:
name: build on linux
uses: FrendsPlatform/FrendsTasks/.github/workflows/linux_build_main.yml@main
build:
uses: FrendsPlatform/FrendsTasks/.github/workflows/official_task_pipeline.yml@hot-fix
with:
workflow_mode: main
os: all
workdir: Frends.TestTask.DoNothing
secrets:
badge_service_api_key: ${{ secrets.BADGE_SERVICE_API_KEY }}
windows_build:
name: build on windows
uses: FrendsPlatform/FrendsTasks/.github/workflows/build_main.yml@main
with:
workdir: Frends.TestTask.DoNothing
secrets:
badge_service_api_key: ${{ secrets.BADGE_SERVICE_API_KEY }}
env_vars: |
{
"FOO": ${{ toJSON(secrets.FOO) }},
"BAR": ${{ toJSON(secrets.BAR) }}
}
27 changes: 14 additions & 13 deletions .github/workflows/DoNothing_build_and_test_on_push.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
name: DoNothing Test
permissions:
contents: read

on:
push:
branches-ignore:
- main
paths:
- 'Frends.TestTask.DoNothing/**'
- '.github/workflows/**'
workflow_dispatch:


jobs:
linux_build:
name: build on Linux
uses: FrendsPlatform/FrendsTasks/.github/workflows/linux_build_test.yml@main
with:
workdir: Frends.TestTask.DoNothing
secrets:
badge_service_api_key: ${{ secrets.BADGE_SERVICE_API_KEY }}
test_feed_api_key: ${{ secrets.TASKS_TEST_FEED_API_KEY }}
windows_build:
name: build on windows
uses: FrendsPlatform/FrendsTasks/.github/workflows/build_test.yml@main
build:
uses: FrendsPlatform/FrendsTasks/.github/workflows/official_task_pipeline.yml@hot-fix
with:
workflow_mode: work
os: all
workdir: Frends.TestTask.DoNothing
secrets:
badge_service_api_key: ${{ secrets.BADGE_SERVICE_API_KEY }}
test_feed_api_key: ${{ secrets.TASKS_TEST_FEED_API_KEY }}
target_feed_api_key: ${{ secrets.TASKS_TEST_FEED_API_KEY }}
env_vars: |
{
"FOO": ${{ toJSON(secrets.FOO) }},
"BAR": ${{ toJSON(secrets.BAR) }}
}
11 changes: 7 additions & 4 deletions .github/workflows/DoNothing_release.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
name: DoNothing Release
permissions:
contents: write

on:
workflow_dispatch:


jobs:
build:
uses: FrendsPlatform/FrendsTasks/.github/workflows/release.yml@dont-push-symbols-on-release
uses: FrendsPlatform/FrendsTasks/.github/workflows/official_task_pipeline.yml@hot-fix
with:
workflow_mode: release
os: all
workdir: Frends.TestTask.DoNothing
secrets:
feed_api_key: ${{ secrets.TASKS_FEED_API_KEY }}

badge_service_api_key: ${{ secrets.BADGE_SERVICE_API_KEY }}
target_feed_api_key: ${{ secrets.TASKS_FEED_API_KEY }}
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="nunit" Version="3.10.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
<PackageReference Include="coverlet.collector" Version="3.1.0">
<PackageReference Include="nunit" Version="5.0.0" />
<PackageReference Include="NUnit3TestAdapter" Version="6.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.10.1" />
<PackageReference Include="coverlet.collector" Version="10.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand All @@ -20,4 +20,4 @@
<ProjectReference Include="..\Frends.TestTask.DoNothing\Frends.TestTask.DoNothing.csproj" />
</ItemGroup>

</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
using System;
using System.Threading;
using Frends.TestTask.DoNothing.Definitions;
using NUnit.Framework;

namespace Frends.TestTask.DoNothing.Tests
Expand All @@ -8,8 +11,62 @@ public class TestTaskTests
[Test]
public void DoNothingTest()
{
var result = TestTask.DoNothing();
Assert.IsTrue(result);
var username = Environment.GetEnvironmentVariable("FOO");

var result = TestTask.DoNothing(new Input(), new Options(), CancellationToken.None);

Assert.That(result.Success, Is.False);
Assert.That(username, Is.EqualTo("bar"));
}

[Test]
public void DoNothingTest_WithFullyPopulatedParameters()
{
var input = new Input
{
Content = "foobar",
Repeat = 2,
};

var options = new Options
{
Delimiter = ",",
ThrowErrorOnFailure = false,
ErrorMessageOnFailure = "Custom error message",
};

var result = TestTask.DoNothing(input, options, CancellationToken.None);

Assert.That(result.Success, Is.False);
Assert.That(result.Error, Is.Null);

Assert.That(input.Content, Is.EqualTo("foobar"));
Assert.That(input.Repeat, Is.EqualTo(2));
Assert.That(options.Delimiter, Is.EqualTo(","));
Assert.That(options.ThrowErrorOnFailure, Is.False);
Assert.That(options.ErrorMessageOnFailure, Is.EqualTo("Custom error message"));
}

[Test]
public void ResultTest_SuccessAndErrorCanBeSetAndRead()
{
var exception = new InvalidOperationException("Something went wrong.");
var error = new Error
{
Message = "Unable to join strings.",
AdditionalInfo = exception,
};

var result = new Result
{
Success = true,
Error = error,
};

Assert.That(result.Success, Is.True);
Assert.That(result.Error, Is.Not.Null);
Assert.That(result.Error.Message, Is.EqualTo("Unable to join strings."));
Assert.That(result.Error.AdditionalInfo, Is.SameAs(exception));
}
}
}
}
7 changes: 6 additions & 1 deletion Frends.TestTask.DoNothing/Frends.TestTask.DoNothing.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Frends.TestTask.DoNothing.T
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{78F7F22E-6E20-4BCE-8362-0C558568B729}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
README.md = README.md
CHANGELOG.md = CHANGELOG.md
..\.gitignore = ..\.gitignore
..\README.md = ..\README.md
..\.github\workflows\DoNothing_build_and_test_on_main.yml = ..\.github\workflows\DoNothing_build_and_test_on_main.yml
..\.github\workflows\DoNothing_build_and_test_on_push.yml = ..\.github\workflows\DoNothing_build_and_test_on_push.yml
..\.github\workflows\DoNothing_release.yml = ..\.github\workflows\DoNothing_release.yml
EndProjectSection
EndProject
Global
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;

namespace Frends.TestTask.DoNothing.Definitions;

/// <summary>
/// Error that occurred during the task.
/// </summary>
public class Error
{
/// <summary>
/// Summary of the error.
/// </summary>
/// <example>Unable to join strings.</example>
public string Message { get; set; }

/// <summary>
/// Additional information about the error.
/// </summary>
/// <example>object { Exception AdditionalInfo }</example>
public Exception AdditionalInfo { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

namespace Frends.TestTask.DoNothing.Definitions;

/// <summary>
/// Essential parameters.
/// </summary>
public class Input
{
/// <summary>
/// The input string to be repeated and output.
/// </summary>
/// <example>foobar</example>
[DisplayFormat(DataFormatString = "Text")]
[DefaultValue("Lorem ipsum dolor sit amet.")]
[Required]
public string Content { get; set; } = string.Empty;

/// <summary>
/// Number of times to repeat the input string.
/// </summary>
/// <example>2</example>
[DefaultValue(3)]
public int Repeat { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

namespace Frends.TestTask.DoNothing.Definitions;

/// <summary>
/// Additional parameters.
/// </summary>
public class Options
{
/// <summary>
/// Delimiter to use between the repeated strings.
/// </summary>
/// <example>,</example>
[DisplayFormat(DataFormatString = "Text")]
[DefaultValue(" ")]
public string Delimiter { get; set; }

/// <summary>
/// Whether to throw an error on failure.
/// </summary>
/// <example>true</example>
[DefaultValue(true)]
public bool ThrowErrorOnFailure { get; set; } = true;

/// <summary>
/// Overrides the error message on failure.
/// </summary>
/// <example>Custom error message</example>
[DisplayFormat(DataFormatString = "Text")]
[DefaultValue("")]
public string ErrorMessageOnFailure { get; set; } = string.Empty;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace Frends.TestTask.DoNothing.Definitions;

/// <summary>
/// Result class for the DoNothing task.
/// </summary>
public class Result
{
/// <summary>
/// Indicates if the task completed successfully.
/// </summary>
/// <example>true</example>
public bool Success { get; set; }

/// <summary>
/// Error that occurred during task execution.
/// </summary>
/// <example>object { string Message, Exception AdditionalInfo }</example>
public Error Error { get; set; }
}
14 changes: 0 additions & 14 deletions Frends.TestTask.DoNothing/Frends.TestTask.DoNothing/DoNothing.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.ComponentModel;
using System.Threading;
using Frends.TestTask.DoNothing.Definitions;

namespace Frends.TestTask.DoNothing;

/// <summary>
/// docs
/// </summary>
public static class TestTask
{
/// <summary>
/// This is not a proper Frends task, it is only for testing build and publish pipelines.
/// [Documentation](https://tasks.frends.com/tasks/frends-tasks/Party-Echo-Execute)
/// </summary>
/// <param name="input">Essential parameters.</param>
/// <param name="options">Additional parameters.</param>
/// <param name="cancellationToken">A cancellation token provided by Frends Platform.</param>
/// <returns>object { bool Success, string Output, object Error { string Message, Exception AdditionalInfo } }</returns>
public static Result DoNothing(
[PropertyTab] Input input,
[PropertyTab] Options options,
CancellationToken cancellationToken)
{
return new Result();
}
}
Loading
Loading