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

tools: move update-undici.sh to dep_updaters and create brotli maintaining md #47380

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions .github/workflows/tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,10 @@ jobs:
subsystem: deps
label: dependencies
run: |
NEW_VERSION=$(npm view undici dist-tags.latest)
CURRENT_VERSION=$(node -p "require('./deps/undici/src/package.json').version")
if [ "$NEW_VERSION" != "$CURRENT_VERSION" ]; then
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
./tools/update-undici.sh
fi
./tools/dep_updaters/update-undici.sh > temp-output
cat temp-output
tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
rm temp-output
- id: postject
subsystem: deps,test
label: test
Expand Down
25 changes: 25 additions & 0 deletions doc/contributing/maintaining-brotli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Maintaining brotli

The [brotli](https://github.com/google/brotli) dependency is used for
the homonym generic-purpose lossless compression algorithm.

## Updating brotli

The `tools/dep_updaters/update-brotli.sh` script automates the update of the
brotli source files.

Check that Node.js still builds and tests.

## Committing brotli

1. Add brotli:
```console
$ git add deps/brotli
```
2. Commit the changes: `git commit`.
3. Add a message like:
```text
deps: update brotli to <version>

Updated as described in doc/contributing/maintaining-brotli.md.
```
3 changes: 3 additions & 0 deletions doc/contributing/maintaining-http.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ more control is required. The current plan is for the following APIs:
Fetch-based API. As this gets worked out we will discuss which
APIs to expose in the Node.js API surface.

For info see [maintaining undici][].

### Server APIs

For the server APIs we do not yet have a clear path, other than wanting
Expand Down Expand Up @@ -116,3 +118,4 @@ The low-level implementation of
is based on [nghttp2](https://nghttp2.org/). See [maintaining nghttp2][].

[maintaining nghttp2]: ./maintaining-nghttp2.md
[maintaining undici]: ./maintaining-undici.md
1 change: 0 additions & 1 deletion doc/contributing/maintaining-postject.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Check that Node.js still builds and tests.
```
2. Commit the changes: `git commit`.
3. Add a message like:

```text
deps,test: update postject to <version>

Expand Down
25 changes: 25 additions & 0 deletions doc/contributing/maintaining-undici.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Maintaining undici

The [undici](https://github.com/nodejs/undici) dependency is
an HTTP/1.1 client, written from scratch for Node.js.

## Updating undici

The `tools/dep_updaters/update-undici.sh` script automates the update of the
undici source files.

Check that Node.js still builds and tests.

## Committing undici

1. Add undici:
```console
$ git add deps/undici
```
2. Commit the changes: `git commit`.
3. Add a message like:
```text
deps: update undici to <version>

Updated as described in doc/contributing/maintaining-undici.md.
```
30 changes: 21 additions & 9 deletions tools/update-undici.sh → tools/dep_updaters/update-undici.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,22 @@

set -ex

cd "$( dirname "$0" )/.." || exit
ROOT=$(cd "$(dirname "$0")/../.." && pwd)
[ -z "$NODE" ] && NODE="$ROOT/out/Release/node"
[ -x "$NODE" ] || NODE=$(command -v node)
NPM="$ROOT/deps/npm/bin/npm-cli.js"

NEW_VERSION=$("$NODE" "$NPM" view undici dist-tags.latest)
CURRENT_VERSION=$("$NODE" -p "require('./deps/undici/src/package.json').version")

echo "Comparing $NEW_VERSION with $CURRENT_VERSION"

if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
echo "Skipped because Undici is on the latest version."
exit 0
fi

cd "$( dirname "$0" )/../.." || exit
rm -rf deps/undici/src
rm -f deps/undici/undici.js

Expand All @@ -16,25 +31,18 @@ rm -f deps/undici/undici.js
mkdir undici-tmp
cd undici-tmp || exit

ROOT="$PWD/.."
[ -z "$NODE" ] && NODE="$ROOT/out/Release/node"
[ -x "$NODE" ] || NODE=$(command -v node)
NPM="$ROOT/deps/npm/bin/npm-cli.js"

"$NODE" "$NPM" init --yes

"$NODE" "$NPM" install --global-style --no-bin-links --ignore-scripts undici
cd node_modules/undici
"$NODE" "$NPM" run build:node
# get the new version of undici
UNDICI_VERSION=$("$NODE" -p "require('./package.json').version")
# update this version information in src/undici_version.h
FILE_PATH="$ROOT/src/undici_version.h"
echo "// This is an auto generated file, please do not edit." > "$FILE_PATH"
echo "// Refer to tools/update-undici.sh" >> "$FILE_PATH"
echo "#ifndef SRC_UNDICI_VERSION_H_" >> "$FILE_PATH"
echo "#define SRC_UNDICI_VERSION_H_" >> "$FILE_PATH"
echo "#define UNDICI_VERSION \"$UNDICI_VERSION\"" >> "$FILE_PATH"
echo "#define UNDICI_VERSION \"$NEW_VERSION\"" >> "$FILE_PATH"
echo "#endif // SRC_UNDICI_VERSION_H_" >> "$FILE_PATH"
)

Expand All @@ -43,3 +51,7 @@ mv deps/undici/src/undici-fetch.js deps/undici/undici.js
cp deps/undici/src/LICENSE deps/undici/LICENSE

rm -rf undici-tmp/

# The last line of the script should always print the new version,
# as we need to add it to $GITHUB_ENV variable.
echo "NEW_VERSION=$NEW_VERSION"