diff --git a/.github/workflows/DoNothing_build_and_test_on_main.yml b/.github/workflows/DoNothing_build_and_test_on_main.yml index 777fe2b..d100f9c 100644 --- a/.github/workflows/DoNothing_build_and_test_on_main.yml +++ b/.github/workflows/DoNothing_build_and_test_on_main.yml @@ -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 }} \ No newline at end of file + env_vars: | + { + "FOO": ${{ toJSON(secrets.FOO) }}, + "BAR": ${{ toJSON(secrets.BAR) }} + } \ No newline at end of file diff --git a/.github/workflows/DoNothing_build_and_test_on_push.yml b/.github/workflows/DoNothing_build_and_test_on_push.yml index f90a170..cd1ba77 100644 --- a/.github/workflows/DoNothing_build_and_test_on_push.yml +++ b/.github/workflows/DoNothing_build_and_test_on_push.yml @@ -1,4 +1,6 @@ name: DoNothing Test +permissions: + contents: read on: push: @@ -6,23 +8,22 @@ on: - 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 }} \ No newline at end of file + target_feed_api_key: ${{ secrets.TASKS_TEST_FEED_API_KEY }} + env_vars: | + { + "FOO": ${{ toJSON(secrets.FOO) }}, + "BAR": ${{ toJSON(secrets.BAR) }} + } diff --git a/.github/workflows/DoNothing_release.yml b/.github/workflows/DoNothing_release.yml index 7dd1e47..2505606 100644 --- a/.github/workflows/DoNothing_release.yml +++ b/.github/workflows/DoNothing_release.yml @@ -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 }} - \ No newline at end of file + badge_service_api_key: ${{ secrets.BADGE_SERVICE_API_KEY }} + target_feed_api_key: ${{ secrets.TASKS_FEED_API_KEY }} \ No newline at end of file diff --git a/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing.Tests/Frends.TestTask.DoNothing.Tests.csproj b/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing.Tests/Frends.TestTask.DoNothing.Tests.csproj index 8d0df0a..bd88333 100644 --- a/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing.Tests/Frends.TestTask.DoNothing.Tests.csproj +++ b/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing.Tests/Frends.TestTask.DoNothing.Tests.csproj @@ -1,16 +1,16 @@  - net6.0 + net8.0 false - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -20,4 +20,4 @@ - \ No newline at end of file + diff --git a/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing.Tests/UnitTests.cs b/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing.Tests/UnitTests.cs index 33a3137..3b1a26a 100644 --- a/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing.Tests/UnitTests.cs +++ b/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing.Tests/UnitTests.cs @@ -1,3 +1,6 @@ +using System; +using System.Threading; +using Frends.TestTask.DoNothing.Definitions; using NUnit.Framework; namespace Frends.TestTask.DoNothing.Tests @@ -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)); } } -} \ No newline at end of file +} diff --git a/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing.sln b/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing.sln index 7c04d31..23ba934 100644 --- a/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing.sln +++ b/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing.sln @@ -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 diff --git a/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing/Definitions/Error.cs b/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing/Definitions/Error.cs new file mode 100644 index 0000000..b0e258f --- /dev/null +++ b/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing/Definitions/Error.cs @@ -0,0 +1,21 @@ +using System; + +namespace Frends.TestTask.DoNothing.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 } + public Exception AdditionalInfo { get; set; } +} diff --git a/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing/Definitions/Input.cs b/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing/Definitions/Input.cs new file mode 100644 index 0000000..67f1719 --- /dev/null +++ b/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing/Definitions/Input.cs @@ -0,0 +1,26 @@ +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; + +namespace Frends.TestTask.DoNothing.Definitions; + +/// +/// Essential parameters. +/// +public class Input +{ + /// + /// The input string to be repeated and output. + /// + /// foobar + [DisplayFormat(DataFormatString = "Text")] + [DefaultValue("Lorem ipsum dolor sit amet.")] + [Required] + public string Content { get; set; } = string.Empty; + + /// + /// Number of times to repeat the input string. + /// + /// 2 + [DefaultValue(3)] + public int Repeat { get; set; } +} diff --git a/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing/Definitions/Options.cs b/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing/Definitions/Options.cs new file mode 100644 index 0000000..bab42ef --- /dev/null +++ b/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing/Definitions/Options.cs @@ -0,0 +1,33 @@ +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; + +namespace Frends.TestTask.DoNothing.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.TestTask.DoNothing/Frends.TestTask.DoNothing/Definitions/Result.cs b/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing/Definitions/Result.cs new file mode 100644 index 0000000..48b1c0b --- /dev/null +++ b/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing/Definitions/Result.cs @@ -0,0 +1,19 @@ +namespace Frends.TestTask.DoNothing.Definitions; + +/// +/// Result class for the DoNothing task. +/// +public class Result +{ + /// + /// Indicates if the task completed successfully. + /// + /// true + public bool Success { get; set; } + + /// + /// Error that occurred during task execution. + /// + /// object { string Message, Exception AdditionalInfo } + public Error Error { get; set; } +} diff --git a/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing/DoNothing.cs b/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing/DoNothing.cs deleted file mode 100644 index 06783ba..0000000 --- a/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing/DoNothing.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace Frends.TestTask.DoNothing -{ - public class TestTask - { - /// - /// Not a real task. - /// - public static bool DoNothing() - { - return true; - } - } -} - diff --git a/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing.cs b/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing.cs new file mode 100644 index 0000000..d97cf35 --- /dev/null +++ b/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing.cs @@ -0,0 +1,27 @@ +using System.ComponentModel; +using System.Threading; +using Frends.TestTask.DoNothing.Definitions; + +namespace Frends.TestTask.DoNothing; + +/// +/// docs +/// +public static class TestTask +{ + /// + /// 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) + /// + /// Essential parameters. + /// Additional parameters. + /// A cancellation token provided by Frends Platform. + /// object { bool Success, string Output, object Error { string Message, Exception AdditionalInfo } } + public static Result DoNothing( + [PropertyTab] Input input, + [PropertyTab] Options options, + CancellationToken cancellationToken) + { + return new Result(); + } +} diff --git a/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing.csproj b/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing.csproj index 5fb9881..3878049 100644 --- a/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing.csproj +++ b/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing.csproj @@ -1,31 +1,49 @@  - - net6.0 - Frends - Frends - Frends - Frends - frends - MIT - - true - true - 1.0.3 - This is not a proper Frends task, it is only for testing build and publish pipelines. - https://frends.com/ - https://github.com/FrendsPlatform/Frends.TestTask - + + net8.0 + latest + 1.1.1 + Frends + Frends + Frends + Frends + Frends + MIT + true + This is not a proper Frends task, it is only for testing build and publish pipelines. + https://frends.com/ + https://github.com/FrendsPlatform/Frends.TestTask/tree/main/Frends.TestTask.DoNothing + disable + + CS1591, + + - - - PreserveNewest - - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + - - - + + + + + + + + + + diff --git a/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing/FrendsTaskMetadata.json b/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing/FrendsTaskMetadata.json index 7c6e834..fc94510 100644 --- a/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing/FrendsTaskMetadata.json +++ b/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing/FrendsTaskMetadata.json @@ -1,7 +1,7 @@ { "Tasks": [ { - "TaskMethod": "Deliberately.Not.Putting.Correct.Name" + "TaskMethod": "Frends.TestTask.DoNothing.TestTask.DoNothing" } ] -} \ No newline at end of file +} diff --git a/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing/GlobalSuppressions.cs b/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing/GlobalSuppressions.cs new file mode 100644 index 0000000..4b4cc78 --- /dev/null +++ b/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing/GlobalSuppressions.cs @@ -0,0 +1,10 @@ +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1101:PrefixLocalCallsWithThis", 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", "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.TestTask.DoNothing/Frends.TestTask.DoNothing/migration.json b/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing/migration.json new file mode 100644 index 0000000..a01c477 --- /dev/null +++ b/Frends.TestTask.DoNothing/Frends.TestTask.DoNothing/migration.json @@ -0,0 +1,6 @@ +[ + { + "Task": "Frends.TestTask.DoNothing", + "Migrations": [] + } +] \ No newline at end of file