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

[Infrastructure] Add a github workflow to update NPM dependencies #54000

Closed
wants to merge 23 commits into from

Conversation

javiercn
Copy link
Member

@javiercn javiercn commented Feb 13, 2024

The workflow removes package-lock.json, runs npm install and if there are changes, it creates a commit for the submodule and a commit for the parent module and sends PRs to the respective repos

@javiercn javiercn requested review from wtgodbe and a team as code owners February 13, 2024 15:31
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework label Feb 13, 2024
@javiercn javiercn force-pushed the javiercn/workflow-to-update-npm-dependencies branch from cf2a973 to fc8f3e7 Compare February 13, 2024 16:16
@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 20, 2024
Copy link
Member

@amcasey amcasey left a comment

Choose a reason for hiding this comment

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

Just nits

# Update the .npmrc file to point to the cache location as a repo instead of a submodule
$npmrcPath = Join-Path -Path $repoRoot -ChildPath ".npmrc"
$content = Get-Content -Path $npmrcPath;
$content = $content -replace "cache=./src/submodules/Node-Externals/cache", "cache=../Node-Externals/cache";
Copy link
Member

Choose a reason for hiding this comment

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

To confirm, the new value is outside the repo root?

Copy link
Member

Choose a reason for hiding this comment

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

I wonder if it could be passed in as an argument so this script wouldn't need knowledge of the workflow?

uses: actions/checkout@v4
with:
repository: 'dotnet/Node-Externals'
path: 'node-externals'
Copy link
Member

Choose a reason for hiding this comment

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

Nit: powershell appears to look for Node-Externals above. But maybe powershell is case-insensitive on all platforms?

run: |
./.github/workflows/update-submodule-commit.ps1 ${{ steps.update-offline-package-cache.outputs.pull-request-head-sha }}

- name: Create PR to update package-lock.json and the offline package cache submodule
Copy link
Member

Choose a reason for hiding this comment

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

It would be cool if this linked to the other PR, but I can see how that might be tricky.

commit-message: 'Update the NPM offline cache'
title: '[Infrastructure] Update the NPM offline cache'
body: 'Updates the npm offline cache to match the associated package-lock.json file in dotnet/aspnetcore.'
labels: 'Type: Dependency Update :arrow_up_small:'
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if this can be done by label ID so it doesn't get out of sync if someone tweaks the emoji or something?

@javiercn
Copy link
Member Author

Switched the approach here and made a script that can be run locally instead and creates the PRs via gh pr create. Setting up a cross-repo workflow is incredibly painful due to the auth requirements, so its better we skip it for now in favor of #54701 which reduces to cloning the repo and running a script to get a similar effect

@javiercn javiercn closed this Mar 22, 2024
@dotnet-policy-service dotnet-policy-service bot added this to the 9.0-preview4 milestone Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants