Closed dan-hughes closed 6 months ago
@johlju, for review.
I have an issue I do not understand how to resolve. The metatask does not know how to resolve/find the tasks, what am I doing wrong?
Changelog and Docs are incoming.
Attention: Patch coverage is 85.71429%
with 8 lines
in your changes are missing coverage. Please review.
Project coverage is 95%. Comparing base (
589ccbd
) to head (d30ceb7
).
Hmm. I will take a look, but might not have time today, and maybe not tomorrow either. But will be back as soon as possible. 🙂
Building the module using this PR it seems to work.
Running ./build.ps1 ?
shows the metatask and that it will run the other tasks. Running ./build.ps1 -Task Generate_Wiki_Content
works too. So for some reason the tests don't find it.
It is because in the tests we just point out one of the needed script files, e.g.
invoke-build -Task Generate_Wiki_Content -File .\output\DscResource.DocGenerator\0.13.0\tasks\Generate_Wiki_Content.build.ps1
It returns the same error:
ERROR: Task 'Generate_Wiki_Content': Missing task 'Create_Wiki_Output_Folder'.
At C:\source\DscResource.DocGenerator\output\DscResource.DocGenerator\0.13.0\tasks\Generate_Wiki_Content.build.ps1:87 char:1
+ Task Generate_Wiki_Content Create_Wiki_Output_Folder, Copy_Source_Wik …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Build ABORTED C:\source\DscResource.DocGenerator\output\DscResource.DocGenerator\0.13.0\tasks\Generate_Wiki_Content.build.ps1. 0 tasks, 1 errors, 0 warnings 00:00:00.0277892
Invoke-Build.ps1: Task 'Generate_Wiki_Content': Missing task 'Create_Wiki_Output_Folder'.
At C:\source\DscResource.DocGenerator\output\DscResource.DocGenerator\0.13.0\tasks\Generate_Wiki_Content.build.ps1:87 char:1
+ Task Generate_Wiki_Content Create_Wiki_Output_Folder, Copy_Source_Wik …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TLDR; I think we skip testing the metatask. 🙂
I have tried building a temp script file that dot-sources all the required task script files, but it errors out on not having the parameters we pass in the test.
[-] Should run the build task without throwing 44ms
Expected no exception to be thrown, but an exception "A parameter cannot be found that matches parameter name 'ProjectName'." was thrown from C:\source\DscResource.DocGenerator\tests\unit\tasks\Generate_Wiki_Content.build.Tests.ps1:55 char:25
+ ) -Verbose @taskParameters
+ ~~~~~~~~~~~~~~~.
56: } | Should -Not -Throw
at <ScriptBlock>, C:\source\DscResource.DocGenerator\tests\unit\tasks\Generate_Wiki_Content.build.Tests.ps1: line 44
So only way to make this work is to dynamically build a task script file with all the required tasks in it during testing, but that is not worth the effort so I suggest we skip testing the metatask. I think Invoke-Build
assumes there should be only on script file with all tasks in it, the Sampler build script handles this that way it allows us to split up the tasks in separate files . Maybe the pipeline in this module should actually build the tasks script files into a single file in the built module. Then there would for example only be one script file that holds all parameters and they are not duplicate though out the task script files. 🤔 We would then just test one single script file in each test file. That it can be a future improvement for the project Sampler, it is a big undertaking fixing that - sounds like a "bad weather" project. 😄
Done.
@dan-hughes Impressive work! Awesome! Thank you! 🙇♂️
Pull Request (PR) description
Change
Generate_Wiki_Content
to a metatask, split existingGenerate_Wiki_Content
into individual subtasks. Update tests for new tasks.This Pull Request (PR) fixes the following issues
Task list
This change is