-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
build: add GitHub Action to update tools modules #40644
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: "tools update" | ||
on: | ||
schedule: | ||
# Run once a week at 00:05 AM UTC on Saturday. | ||
- cron: '5 0 * * 6' | ||
|
||
workflow_dispatch: | ||
|
||
jobs: | ||
tools_update: | ||
if: github.repository == 'nodejs/node' | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false # Prevent other jobs from aborting if one fails | ||
matrix: | ||
include: | ||
- id: eslint | ||
run: | | ||
cd tools | ||
NEW_VERSION=$(npm view eslint dist-tags.latest) | ||
CURRENT_VERSION=$(node -p "require('./node_modules/eslint/package.json').version") | ||
if [ "$NEW_VERSION" != "$CURRENT_VERSION" ]; then | ||
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV | ||
tools/update-eslint.sh | ||
fi | ||
- id: "@babel/eslint-parser" | ||
run: | | ||
cd tools | ||
NEW_VERSION=$(npm view @babel/eslint-parser dist-tags.latest) | ||
CURRENT_VERSION=$(node -p "require('./node_modules/@babel/eslint-parser/package.json').version") | ||
if [ "$NEW_VERSION" != "$CURRENT_VERSION" ]; then | ||
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV | ||
tools/update-babel-eslint.sh | ||
fi | ||
- id: "lint-md dependencies" | ||
run: | | ||
cd tools/lint-md | ||
NEW_VERSION=$(npm outdated --omit=dev --parseable | cut -d: -f4 | xargs) | ||
if [ "$NEW_VERSION" != "" ]; then | ||
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV | ||
rm -rf package-lock.json node_modules && npm install --ignore-scripts) | ||
make lint-md-rollup | ||
fi | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: ${{ matrix.run }} | ||
- uses: gr2m/create-or-update-pull-request-action@v1 # Create a PR or update the Action's existing PR | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_USER_TOKEN }} | ||
with: | ||
author: Node.js GitHub Bot <[email protected]> | ||
body: "This is an automated update of ${{ matrix.id }} to ${{ env.NEW_VERSION }}." | ||
branch: "actions/tools-update-${{ matrix.id }}" # Custom branch *just* for this Action. | ||
commit-message: "tools: update ${{ matrix.id }} to ${{ env.NEW_VERSION }}" | ||
labels: tools | ||
title: "tools: update ${{ matrix.id }} to ${{ env.NEW_VERSION }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ ROOT="$PWD/../.." | |
NPM="$ROOT/deps/npm/bin/npm-cli.js" | ||
|
||
"$NODE" "$NPM" init --yes | ||
"$NODE" "$NPM" install --global-style --no-bin-links --production --no-package-lock @babel/core @babel/eslint-parser@latest @babel/plugin-syntax-import-assertions@latest | ||
"$NODE" "$NPM" install --global-style --no-bin-links --ignore-scripts --no-package-lock @babel/core @babel/eslint-parser @babel/plugin-syntax-import-assertions | ||
|
||
# Use dmn to remove some unneeded files. | ||
"$NODE" "$NPM" exec -- [email protected] -f clean | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,8 +20,7 @@ rm -rf node_modules/eslint node_modules/eslint-plugin-markdown | |
|
||
"$NODE" "$NPM" init --yes | ||
|
||
"$NODE" "$NPM" install --global-style --no-bin-links --production --no-package-lock eslint@latest | ||
"$NODE" "$NPM" install --global-style --no-bin-links --production --no-package-lock eslint-plugin-markdown@latest | ||
"$NODE" "$NPM" install --global-style --no-bin-links --ignore-scripts --no-package-lock eslint eslint-plugin-markdown | ||
|
||
# Use dmn to remove some unneeded files. | ||
"$NODE" "$NPM" exec -- [email protected] -f clean | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I was thinking of something like
or
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea, but there a few small obstacles:
npm outdated
will not work foreslint
or@babel/eslint-parser
the way we have them installed. That's why I'm doing things the way I am in those instances.$NEW_VERSIONS
contains newline characters, then"NEW_VERSIONS=$NEW_VERSIONS"
won't work.)For
lint-md
, the format you propose would be better than what I'm doing, as the way I'm doing it will result in lines longer than 72 characters frequently.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose I can use some other character as a placeholder for the newline and then convert it in the relevant step.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the new versions are in a string with a format like "[email protected] [email protected] [email protected]" then I can convert the spaces to newlines and the problem is solved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah
Indeed, but it is possible by using outputs and escaping new lines. The runner will automatically take care of unescaping it:
And then use it as
${{ steps.update.outputs.version }}