Azure / azure-sdk-for-java

This repository is for active development of the Azure SDK for Java. For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/java/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-java.
MIT License
2.32k stars 1.97k forks source link

mgmt, fix generate.yml #40781

Closed XiaofeiCao closed 2 months ago

XiaofeiCao commented 3 months ago

Description

This PR does:

  1. Use macOS-13 for TypeSpec code generation. issue: https://github.com/Azure/azure-sdk-tools/issues/8368
  2. Use parameters(instead of variables) for template compile-time expression. https://learn.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=yaml%2Cbatch#understand-variable-syntax
    
    # ${{ <expression> }} is compile time template expression. 
    # For variables, it can only read its initial value, which is defined as
    variables:
    - var1
    value: initialValue

${{ variables.var1 }} # initialValue, not the value passed in

For parameters, it's template parameters and its value can be read in compile time

parameters:

${{ parameters.var1 }} # if not passed in, value1, otherwise, it's passed in value


![image](https://github.com/Azure/azure-sdk-for-java/assets/92354331/6fed748c-cf21-4401-9ae9-08521f61d4d6)

3. Make `jobs` as root, instead of `steps` and move pool vmImage under job. This is due to pool vmImage condition can't happen at the root level.
https://stackoverflow.com/questions/63189744/execute-azure-devops-job-on-a-pool-based-on-conditional-parameter/76075535

Test:
1. Generate from Swagger
  a. pipeline: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=3898539&view=logs&j=42d88303-8e48-5332-e7e9-82bec1356e32&t=33740b31-17c1-53d0-4485-7f460d813a8f
  b. PR: https://github.com/Azure/azure-sdk-for-java/pull/40779
2. Generate from TypeSpec
  a. pipeline: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=3898538&view=logs&j=42d88303-8e48-5332-e7e9-82bec1356e32&t=ce7f9b1c-74d4-53cc-71fb-14221b7018a5
  b. PR: https://github.com/Azure/azure-sdk-for-java/pull/40780

Please add an informative description that covers that changes made by the pull request and link all relevant issues.

If an SDK is being regenerated based on a new swagger spec, a link to the pull request containing these swagger spec changes has been included above.

# All SDK Contribution checklist:
- [x] **The pull request does not introduce [breaking changes]**
- [ ] **CHANGELOG is updated for new features, bug fixes or other significant changes.**
- [ ] **I have read the [contribution guidelines](https://github.com/Azure/azure-sdk-for-java/blob/main/CONTRIBUTING.md).**

## [General Guidelines and Best Practices](https://github.com/Azure/azure-sdk-for-java/blob/main/CONTRIBUTING.md#developer-guide)
- [x] Title of the pull request is clear and informative.
- [x] There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, [see this page](https://github.com/Azure/azure-powershell/blob/master/documentation/development-docs/cleaning-up-commits.md).

### [Testing Guidelines](https://github.com/Azure/azure-sdk-for-java/blob/main/CONTRIBUTING.md#building-and-unit-testing)
- [x] Pull request includes test coverage for the included changes.
XiaofeiCao commented 3 months ago

curious that tsp-client can only run on mac?

I don't know why tsp-client in this pipeline will get permanent stuck on Windows/Linux... Ray hasn't met this issue, and I haven't seen major configuration differences either.

Use macOS for TypeSpec for now. Will switch if root cause is found.

XiaofeiCao commented 2 months ago

/check-enforcer override