Azure / azure-sdk-tools

Tools repository leveraged by the Azure SDK team.
MIT License
113 stars 177 forks source link

Docs release does not support link substitution for non-default branches #1754

Closed danieljurek closed 1 month ago

danieljurek commented 3 years ago

The link replacement regex (https://github.com/Azure/azure-sdk-tools/blob/main/eng/common/pipelines/templates/steps/publish-blobs.yml#L27) is hadcoded to look for $(DefaultBranch)

This means that links like...

https://github.com/Azure/azure-sdk-for-c/blob/main/sdk/inc/azure/core/az_result.h

... will be properly replaced with the tag because main is the value for $(DefaultBranch)

However, links which target files that are NOT in the default branch will not match the link substitution regex and will not be replaced. For example:

https://github.com/Azure/azure-sdk-for-c/blob/feature/iot_pnp/sdk/samples/iot/paho_iot_pnp_sample.c

The regex which finds these links for substitution today looks like:

(https://github.com/${{ parameters.RepoId }}/(?:blob|tree)/)$(DefaultBranch)

Which, in the case of the C repo, expands to:

(https://github.com/Azure/azure-sdk-for-c/(?:blob|tree)/)main

We should consider potentially adding the "current branch" against which a build is being run to this list, something like:

(https://github.com/Azure/azure-sdk-for-c/(?:blob|tree)/)(?:main|feature/iot_pnp)

This will require some additional work to find the branch name as the predefined variables like $(Build.SourceBranch) prefixes which are not useful to the link substitution (e.g. refs/heads/<branch name>).

However, when integrating back into the default branch, the links will contain the name of a branch which could be deleted and those links may fail at a future time. It may be necessary to, when merging to a default branch, look for instances of links which contain the current branch name and ensure that they are properly evaluated and updated.

danieljurek commented 1 month ago

This could be Build.SourceBranchName which now is just the branch name. https://learn.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml

danieljurek commented 1 month ago

This issue is primarily about releases for the C repo which has a different release and docs architecture from other language repositories.