marceloavf / github-tools-vsts

📦:octocat:🚀 Create and modify GitHub Releases in Azure DevOps Build and Release Management
https://marketplace.visualstudio.com/items?itemName=marcelo-formentao.github-tools
MIT License
24 stars 15 forks source link

Cannot upload assets using multiple minimatch patterns #34

Closed heaths closed 5 years ago

heaths commented 5 years ago

Bug Report

Describe the bug When using multiple minimatch patterns like most other tasks, no assets are uploaded. E.g.

  - task: marcelo-formentao.github-tools.github-release-publish-task.GitHubReleasePublish@0
    inputs:
      githubEndpoint: ***
      githubReleaseAsset: |
        $(Build.ArtifactStagingDirectory)\bin\$(BuildConfiguration)\*.exe
        $(Build.ArtifactStagingDirectory)\bin\$(BuildConfiguration)\*.zip
      githubReleaseDraft: false
      githubReleaseTitle: v$(CloudBuildNumber)
      githubRepository: heaths/Caffeine
      githubTag: v$(BuildVersionSimple)

To Reproduce

Define a YAML build def with task like the one above, such that minimatch patterns should discover multiple artifacts.

2018-10-23T15:36:09.7501793Z ##[debug]Evaluating condition for step: 'Publish build artifacts to GitHub'
2018-10-23T15:36:09.7502328Z ##[debug]Evaluating: SucceededNode()
2018-10-23T15:36:09.7502444Z ##[debug]Evaluating SucceededNode:
2018-10-23T15:36:09.7502675Z ##[debug]=> True
2018-10-23T15:36:09.7502884Z ##[debug]Result: True
2018-10-23T15:36:09.7503063Z ##[section]Starting: Publish build artifacts to GitHub
2018-10-23T15:36:09.7507707Z ==============================================================================
2018-10-23T15:36:09.7507822Z Task         : Create or Modify GitHub Release
2018-10-23T15:36:09.7507886Z Description  : Create or modify GitHub Release, allowing to upload assets, check manifest content and more.
2018-10-23T15:36:09.7507948Z Version      : 0.5.0
2018-10-23T15:36:09.7508039Z Author       : Marcelo Formentão
2018-10-23T15:36:09.7508104Z Help         : [More Information](https://github.com/marceloavf/github-tools-vsts) (Version 0.5.0).
2018-10-23T15:36:09.7508190Z ==============================================================================
2018-10-23T15:36:10.2228912Z ##[debug]agent.TempDirectory=D:\a\_temp
2018-10-23T15:36:10.2252972Z ##[debug]loading inputs and endpoints
2018-10-23T15:36:10.2263630Z ##[debug]loading ENDPOINT_AUTH_af6d67d6-e46f-4f8d-830f-32a041e29412
2018-10-23T15:36:10.2278215Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_af6d67d6-e46f-4f8d-830f-32a041e29412_ACCESSTOKEN
2018-10-23T15:36:10.2282187Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
2018-10-23T15:36:10.2284145Z ##[debug]loading ENDPOINT_AUTH_SCHEME_af6d67d6-e46f-4f8d-830f-32a041e29412
2018-10-23T15:36:10.2286959Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
2018-10-23T15:36:10.2289193Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
2018-10-23T15:36:10.2292113Z ##[debug]loading INPUT_GITHUBDELETEEMPTYTAG
2018-10-23T15:36:10.2293782Z ##[debug]loading INPUT_GITHUBEDITRELEASE
2018-10-23T15:36:10.2295978Z ##[debug]loading INPUT_GITHUBENDPOINT
2018-10-23T15:36:10.2298409Z ##[debug]loading INPUT_GITHUBIGNOREASSETS
2018-10-23T15:36:10.2300360Z ##[debug]loading INPUT_GITHUBRELEASEASSET
2018-10-23T15:36:10.2302013Z ##[debug]loading INPUT_GITHUBRELEASEDRAFT
2018-10-23T15:36:10.2304293Z ##[debug]loading INPUT_GITHUBRELEASEPRERELEASE
2018-10-23T15:36:10.2306151Z ##[debug]loading INPUT_GITHUBRELEASETITLE
2018-10-23T15:36:10.2308268Z ##[debug]loading INPUT_GITHUBREPOSITORY
2018-10-23T15:36:10.2310631Z ##[debug]loading INPUT_GITHUBREUSEDRAFTONLY
2018-10-23T15:36:10.2312618Z ##[debug]loading INPUT_GITHUBREUSERELEASE
2018-10-23T15:36:10.2314477Z ##[debug]loading INPUT_GITHUBSKIPDUPLICATEDASSETS
2018-10-23T15:36:10.2316262Z ##[debug]loading INPUT_GITHUBTAG
2018-10-23T15:36:10.2319045Z ##[debug]loading INPUT_MANIFESTJSON
2018-10-23T15:36:10.2321098Z ##[debug]loading INPUT_MANUALLYSETREPOSITORY
2018-10-23T15:36:10.2328723Z ##[debug]loading SECRET_SYSTEM_ACCESSTOKEN
2018-10-23T15:36:10.2334249Z ##[debug]loaded 22
2018-10-23T15:36:10.2392770Z ##[debug]Agent.ProxyUrl=undefined
2018-10-23T15:36:10.2394359Z ##[debug]Agent.CAInfo=undefined
2018-10-23T15:36:10.2394686Z ##[debug]Agent.ClientCert=undefined
2018-10-23T15:36:10.2395232Z ##[debug]githubEndpoint=af6d67d6-e46f-4f8d-830f-32a041e29412
2018-10-23T15:36:10.2413879Z af6d67d6-e46f-4f8d-830f-32a041e29412 exists true
2018-10-23T15:36:10.2414154Z ##[debug]af6d67d6-e46f-4f8d-830f-32a041e29412 exists true
2018-10-23T15:36:10.2416672Z ##[debug]githubRepository=heaths/Caffeine
2018-10-23T15:36:10.2418640Z ##[debug]githubRepository=heaths/Caffeine
2018-10-23T15:36:10.2418933Z ##[debug]githubOwner=null
2018-10-23T15:36:10.2452247Z ##[debug]githubRepositoryName=null
2018-10-23T15:36:10.2452746Z ##[debug]githubTag=v
2018-10-23T15:36:10.2452969Z ##[debug]githubReleaseTitle=v
2018-10-23T15:36:10.2453183Z ##[debug]githubReleaseNotes=null
2018-10-23T15:36:10.2453362Z ##[debug]githubApiUrl=null
2018-10-23T15:36:10.2453548Z ##[debug]githubTargetCommitsh=null
2018-10-23T15:36:10.2453727Z ##[debug]manuallySetRepository=false
2018-10-23T15:36:10.2455692Z ##[debug]githubReleaseDraft=false
2018-10-23T15:36:10.2456051Z ##[debug]githubReleasePrerelease=false
2018-10-23T15:36:10.2456700Z ##[debug]githubReuseRelease=true
2018-10-23T15:36:10.2457273Z ##[debug]githubReuseDraftOnly=true
2018-10-23T15:36:10.2457609Z ##[debug]githubSkipDuplicatedAssets=false
2018-10-23T15:36:10.2457823Z ##[debug]githubIgnoreAssets=false
2018-10-23T15:36:10.2458027Z ##[debug]githubEditRelease=false
2018-10-23T15:36:10.2458211Z ##[debug]githubDeleteEmptyTag=false
2018-10-23T15:36:10.2458419Z ##[debug]manifestJson=D:\a\1\s
2018-10-23T15:36:10.2458640Z ##[debug]githubReleaseAsset=D:\a\1\a\bin\Release\*.exe
D:\a\1\a\bin\Release\*.zip
2018-10-23T15:36:10.4571831Z Creating release
2018-10-23T15:36:11.3555968Z Release created successfully at
2018-10-23T15:36:11.3557769Z       https://github.com/heaths/Caffeine/releases/tag/v
2018-10-23T15:36:11.3577132Z Finish - Release URL: https://api.github.com/repos/heaths/Caffeine/releases/13611195
2018-10-23T15:36:11.3665042Z ##[section]Finishing: Publish build artifacts to GitHub

Repo: https://github.com/heaths/caffeine Build: https://dev.azure.com/heaths/public/_build/results?buildId=100&view=logs

Expected behavior All files matching all minimatch patterns should be used. Ideally, the input control for the task is higher as well, or the documentation for the field at least clarifies that only one line works, but that is certainly not ideal since you'd need multiple tasks to upload multiple artifacts with different patterns.

Enviroment

heaths commented 5 years ago

Looking at the VSTest@2 task source, they use a multiline input type with corresponding code at https://github.com/Microsoft/azure-pipelines-tasks/blob/c35d1e72b74fa72316e3fa35d71a4fad05ce43f2/Tasks/VsTestV2/distributedtest.ts#L101-L115 that seems to support a wider grammar for minimatch patterns than globbing, which is its own benefit but also introduces consistency with built-in tasks.

I don't imagine this would be a breaking change unless globbing and lstat have some slight nuances, but maybe a new major version of the task would be in order? Willing to contribute if you're interested.

marceloavf commented 5 years ago

Hey @heaths, first of all thank you for the feedback.

I've never used multi-line folders 😞, code implementation from this repository use glob specification only for a string line and convert all files found into an array.

I used another implementation in my digitalocean-tools-vsts that is almost equal to this example of yours, but I never tested either. would be great to implement it here:

https://github.com/marceloavf/github-tools-vsts/blob/ba6266f945f9d9d89cb165a29a28db57569ab72b/Src/GithubReleasePublish/githubReleasePublish.js#L57-L62

Code implementation used in digitalocean-tools-vsts

https://github.com/marceloavf/digitalocean-tools-vsts/blob/21925e50e081107fcbd8bb9c3bb91cb83bf20a78/Tasks/DigitalOceanSpacesUpload/utils/utils.ts#L5-L31

I would be very grateful if you could contribute, since I use semantic-release, it would be easy to bump major version for this one.

heaths commented 5 years ago

I hope to get to this later today. Any problem with just using the same pattern as other built-in tasks? Consistency improves productivity and reduces errors. Since you document that the tasks supports minimatch patterns, I imagine - as I did - devs would assume it's the same pattern they can use with built-in tasks.

heaths commented 5 years ago

PS: I mistakenly pointed out the wrong reference source earlier. Digging in deeper, I see that built-in tasks use https://github.com/Microsoft/azure-pipelines-task-lib/blob/master/node/task.ts#L1412, which does rely on the minimatch library (as does glob) buts adds a bit more processing.

marceloavf commented 5 years ago

No problem @heaths, thank you so much for the PR.

I'll release it into our development channel stage to check it out and then make it to production ok.

marceloavf commented 5 years ago

Tested migrating an release task using 0.5.0 to 1.0.0 and the multiLine new type and worked like a charm.

image

image

Thank you again.