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

[draft] LintDiff Migration tests #32697

Draft
wants to merge 25 commits into
base: main
Choose a base branch
from
Draft

Conversation

danieljurek
Copy link
Member

@danieljurek danieljurek commented Feb 19, 2025

Test a few scenarios

  • ARM -- ✅ Correct --openapi-type when editing in data-plane/
  • Data Plane -- ✅ Correct --openapi-type when editing in resource-manager/
  • Add
  • Delete
  • Rename/Move
  • Noop -- https://github.com/Azure/azure-rest-api-specs/pull/32714/files -- Does not work, currently runs autorest over all tags detected in a readme file but should instead find no tags affected because the new file is not referenced in any readme.md

Copy link

openapi-pipeline-app bot commented Feb 19, 2025

Next Steps to Merge

Next steps that must be taken to merge this PR:
  • ❌ This is the public specs repo main branch which is not intended for iterative development.
    You must acknowledge that you understand that after this PR is merged, you won't be able to stop your changes from being published to Azure customers.
    If this is what you intend, add PublishToCustomers label to your PR.
    Otherwise, retarget this PR onto a feature branch, i.e. with prefix release- (see aka.ms/azsdk/api-versions#release--branches).
  • ❌ The required check named Automated merging requirements met has failed. This is the final check that must pass. Refer to the check in the PR's 'Checks' tab for details on how to fix it and consult the aka.ms/ci-fix guide. In addition, refer to step 4 in the PR workflow diagram

Copy link

openapi-pipeline-app bot commented Feb 19, 2025

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

@azure-sdk
Copy link
Collaborator

azure-sdk commented Feb 19, 2025

API change check

APIView has identified API level changes in this PR and created following API reviews.

Azure.Contoso.WidgetManager
Microsoft.Contoso

@@ -0,0 +1,68 @@
name: LintDiff (preview)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
name: LintDiff (preview)
name: LintDiff (Preview)

We have been capitalizing (Preview) in existing checks. I don't feel strongly about capital vs lowercase but I do want to be consistent.

eng/
.github/

- name: Checkout 'after' state
Copy link
Member

Choose a reason for hiding this comment

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

We might be able to optimize the checkouts to only the folders with files changed in the PR diff.

ref: ${{ github.event.pull_request.base.sha }}
path: before

- name: Setup Node and install deps
Copy link
Member

Choose a reason for hiding this comment

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

Add eng/tools/lint-diff to eng/tools/package.json, then it will be included transitively in the root package.json, so users (and CI) only needs to run npm ci at the repo root to install all tools.


# TODO: This can probably be updated to run directly from JS
# TODO: default workspace is the after/ folder
- name: Get changed files
Copy link
Member

Choose a reason for hiding this comment

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

I will be creating JS-based helpers for this: #32637

run: |
realpath ../../../before
realpath ../../../changed-files.txt
npm exec -- lint-diff --path ../../../before --changed-files-path ../../../changed-files.txt --out-file placeholder.txt
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
npm exec -- lint-diff --path ../../../before --changed-files-path ../../../changed-files.txt --out-file placeholder.txt
npm exec --no -- lint-diff --path ../../../before --changed-files-path ../../../changed-files.txt --out-file placeholder.txt

Add param --no to ensure only pre-installed packages are used.


- name: Run LintDiff After
run: |
npm exec -- lint-diff --path ../../../../after --changed-files-path ../../../../changed-files.txt --out-file placeholder.txt
Copy link
Member

@mikeharder mikeharder Feb 22, 2025

Choose a reason for hiding this comment

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

Suggested change
npm exec -- lint-diff --path ../../../../after --changed-files-path ../../../../changed-files.txt --out-file placeholder.txt
npm exec --no -- lint-diff --path ../../../../after --changed-files-path ../../../../changed-files.txt --out-file placeholder.txt

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if we will need this tool long-term. To me this is more "glue code" that is used by CI, rather than a tool for dev inner-loop. But it's fine for now since this is likely the simplest way to lift-and-shift the existing check.

type: "string",
short: "o",
},
"lint-version": {
Copy link
Member

Choose a reason for hiding this comment

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

This parameter should be removed, and instead all necessary dependencies should be listed in a package.json. If the dependencies are to be called directly during dev inner-loop, they should be listed in the root package.json. Else, use the package,json of the tool that calls the dependencies.

Copy link
Member

Choose a reason for hiding this comment

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

Also, autorest is special because, by default, it uses custom code to manage it's own dependendencies. However, it can be convinced to use only pre-installed deps. We will want to use this here, and I'll extract it into a common JS helper.

Here's me making this fix to tsp-client:

Azure/azure-sdk-tools#8610
Azure/azure-sdk-tools#9043

}
}

async function executeCommand(
Copy link
Member

Choose a reason for hiding this comment

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

I will extract this into a shared helper.

* TODO: TESTS
* @param changedFiles List of changed files.
*/
async function getAffectedReadmeFiles(changedFiles: string[], repoRoot: string): Promise<string[]> {
Copy link
Member

Choose a reason for hiding this comment

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

Might be worth making the rest of the file shared code, if we think other tools may want similar file lists.

Copy link
Member

Choose a reason for hiding this comment

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

This should probably also be shared code

* @param path Path to check for existence
* @returns true if the path exists, false otherwise
*/
export async function pathExists(path: string): Promise<boolean> {
Copy link
Member

Choose a reason for hiding this comment

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

Shared code

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.

Left initial comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants