Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate typespec validation #31033

Merged
merged 52 commits into from
Oct 25, 2024
Merged

Migrate typespec validation #31033

merged 52 commits into from
Oct 25, 2024

Conversation

danieljurek
Copy link
Member

@danieljurek danieljurek commented Oct 15, 2024

Fixes Azure/azure-sdk-tools#9175
Fixes #28974
Fixes #29635

Of note...

  • Uses same name as DevOps pipelines to supersede those checks, removes the old DevOps pipelines yml files
  • The existing pipelines used ignoreLASTEXITCODE: true... there's no direct analog in GitHub Actions (continue-on-error: true hides failures in these cases).
  • Shards using skip/take logic configured in the matrix.

Sharding and performance

For the TypeSpec Validation - All pipeline, this change shards using skip/take logic configured in the matrix. There is significant improvement at the cost of agent time.

Configuration Wall Time Example
DevOps Pipelines (no sharding) 44m 37s example
GitHub Actions (WITH 3 shards) 15m 58s example

In its current configuration, the "last" job will scan all remaining folders after the existing 213 folders have been divided up. Folders that are "displaced" by the addition of a new folder earlier in the sequence can be scanned in later jobs and the "last" job's take: 0 means that all remaining entries will be scanned.

If the "last" job starts taking long the matrix will have to be rebalanced to either add a shard or require other entries to take more folders.

Composite actions

This PR uses composite actions to do Node setup, npm ci, and npm ls -a... These are all collapsed into a single task in the logs. It's possible to further subdivide these for UI benefits if we care. We can use the composite actions in other places (like the eng-tools-test.yaml) but that's outside the scope of this change.

image

Example failure:

PR with contrived failure: https://github.com/Azure/azure-rest-api-specs/actions/runs/11351864042/job/31573371561?pr=31034

When clicking on the failed check in the PR UI...

image

The user is taken straight to the logs:

image

Copy link

openapi-pipeline-app bot commented Oct 15, 2024

Next Steps to Merge

✅ All automated merging requirements have been met! To get your PR merged, see aka.ms/azsdk/specreview/merge.

Copy link

openapi-pipeline-app bot commented Oct 15, 2024

PR validation pipeline restarted successfully. If there is ApiView generated, it will be updated in this comment.

Copy link
Member

@mikeharder mikeharder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main recommendation is changing to use shards and shard

Copy link

PR validation pipeline can not start as the pull request is not merged or mergeable - most likely it has merge conflicts.

1 similar comment
Copy link

PR validation pipeline can not start as the pull request is not merged or mergeable - most likely it has merge conflicts.

* `

* `

* Revert "`"

This reverts commit c26fc6a.
Co-authored-by: Mike Harder <mharder@microsoft.com>
@danieljurek danieljurek marked this pull request as ready for review October 25, 2024 21:57
@danieljurek danieljurek enabled auto-merge (squash) October 25, 2024 22:27
@danieljurek danieljurek merged commit 31d2f2a into main Oct 25, 2024
37 of 38 checks passed
@danieljurek danieljurek deleted the djurek/typespec-validation branch October 25, 2024 22:57
fetch-depth: 2

- name: Setup Node 20 and run `npm ci`
uses: ./.github/actions/setup-node-npm-ci
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mikeharder @danieljurek I thought github force these to be under the workflows directory. Is this a way we can make other reusable pieces for actions?

Copy link
Member

@mikeharder mikeharder Oct 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow itself must be under .github/workflows, but I believe custom actions can live anywhere in your repo, in another repo, etc.

We're still experimenting, but we're considering trying to provide most reusable code through custom actions, rather than using github-script everywhere and sharing JS code.

Custom actions can still use github-script internally, but the goal would be to make most of our leaf-node workflows as declarative as possible (no github-script).

}

if ($totalShards -gt $array.Length) {
throw "Cannot shard array into more pieces than there are elements"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would we hit this case if there were only one spec discovered but we have it sharded in 3? I assume this wouldn't be the case for tsv-all but could be in other cases if we use this logic.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

markcowl pushed a commit to markcowl/azure-rest-api-specs that referenced this pull request Oct 29, 2024
* test breaking change mlc in js (Azure#3451)

* `

* `

* Revert "`"

This reverts commit c26fc6a.

* Update specificationRepositoryConfiguration.json (Azure#3457)

* Update specificationRepositoryConfiguration.json (Azure#3459)

* Update specificationRepositoryConfiguration.json (Azure#3462)

Revert python repo branch change as it was deleted.

* Update specificationRepositoryConfiguration.json (Azure#3463)

* Migrate typespec-validation.yml to GH Actions

* path, fetch depth

* Introduce error

* Test a feature that AI says will collapse logs (doubtful it'll work)

* Revert "Test a feature that AI says will collapse logs (doubtful it'll work)"

This reverts commit 04aed83.

* Log $LASTEXITCODE

* Invalid syntax

* Use error logging, remove continue-on-error because that is different behavior in GitHub Actions compared to ignoreLASTEXITCODE

* Errors also get annotations in GitHub Actions

* String replacement

* Revert Logging-Functions.ps1

* Test composite action

* File location

* Invocation

* Add typespec-validation-all.yml

* Migrate typespec-validation-all.yml

* Revert main.tsp invalid spec

* fetch-depth: 2

* Long paths

* checkout@v4

* Remove pipelines

* *.yml -> *.yaml

* Do not change specificationRepositoryConfiguration.json

* Job names (for checks)

* Add Skip/Take logic and matrix

* Syntax

* Rename

* Remove "shell"

* Try defaults.run.shell (unlikely to work)

* bash

* Name for actions/setup-node@v4 does not appear in the logs. Remove.

* Use sharding semantics

* Shard

* Review feedback

* Review feedback

* +1

* Revert "Shard"... Display is confusing because it starts at 0 and doesn't reach total-shards. Math is not allowed in expressions.

This reverts commit 035bec7.

* Shard only if TotalShards > 0

* Remove description (schema validaiton does not pass, let's see what GH Actions says)

* The `description` property is not absolutely required by GH Actions at this time but adding back in because schema requires it.

* Add array functions and tests

* Move Copy-ApiVersion.Tests.ps1 out of folder (adjust paths so they are accurate)

* Add trailing newline

* Add trailing newline

* Update .github/workflows/typespec-validation.yaml

Co-authored-by: Mike Harder <mharder@microsoft.com>

* Review feedback

* Update eng/scripts/TypeSpec-Validation.ps1

Co-authored-by: Mike Harder <mharder@microsoft.com>

---------

Co-authored-by: Wanpeng Li <wanl@microsoft.com>
Co-authored-by: Peng Jiahui <46921893+Alancere@users.noreply.github.com>
Co-authored-by: Yuchao Yan <yuchaoyan@microsoft.com>
Co-authored-by: Ray Chen <raychen@microsoft.com>
Co-authored-by: Mike Harder <mharder@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants