Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c7b898d

Browse filesBrowse files
marco-ippolitoMoLow
authored andcommitted
tools: automate ngtcp2 and nghttp3 update
PR-URL: #47402 Refs: nodejs/security-wg#828 Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 5e4b243 commit c7b898d
Copy full SHA for c7b898d

File tree

Expand file treeCollapse file tree

4 files changed

+218
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+218
-0
lines changed
Open diff view settings
Collapse file

‎.github/workflows/tools.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/tools.yml
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,22 @@ jobs:
176176
cat temp-output
177177
tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
178178
rm temp-output
179+
- id: ngtcp2
180+
subsystem: deps
181+
label: dependencies
182+
run: |
183+
./tools/dep_updaters/update-ngtcp2.sh > temp-output
184+
cat temp-output
185+
tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
186+
rm temp-output
187+
- id: nghttp3
188+
subsystem: deps
189+
label: dependencies
190+
run: |
191+
./tools/dep_updaters/update-nghttp3.sh > temp-output
192+
cat temp-output
193+
tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
194+
rm temp-output
179195
steps:
180196
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
181197
with:
Collapse file
+62Lines changed: 62 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# ngtcp2 and nghttp3
2+
3+
The ngtcp2 and nghttp3 dependencies provide the core functionality for
4+
QUIC and HTTP/3.
5+
6+
The sources are pulled from:
7+
8+
* ngtcp2: <https://github.com/ngtcp2/ngtcp2>
9+
* nghttp3: <https://github.com/ngtcp2/nghttp3>
10+
11+
In both the `ngtcp2` and `nghttp3` git repos, the active development occurs
12+
in the default branch (currently named `main` in each). Tagged versions do not
13+
always point to the default branch.
14+
15+
We only use a subset of the sources for each.
16+
17+
## Updating
18+
19+
The `nghttp3` library depends on `ngtcp2`. Both should always be updated
20+
together. From `ngtcp2` we only want the contents of the `lib` and `crypto`
21+
directories; from `nghttp3` we only want the contents of the `lib` directory.
22+
23+
After updating either dependency, check if any source files or include
24+
directories have been added or removed and update `ngtcp2.gyp` accordingly.
25+
26+
### Updating ngtcp2
27+
28+
The `tools/dep_updaters/update-ngtcp2.sh` script automates the update of the
29+
ngtcp2 source files.
30+
31+
Check that Node.js still builds and tests.
32+
33+
1. Add ngtcp2:
34+
```console
35+
$ git add deps/ngtcp2
36+
```
37+
2. Commit the changes: `git commit`.
38+
3. Add a message like:
39+
```text
40+
deps: update ngtcp2 to <version>
41+
42+
Updated as described in doc/contributing/maintaining-ngtcp2.md.
43+
```
44+
45+
### Updating nghttp3
46+
47+
The `tools/dep_updaters/update-nghttp3.sh` script automates the update of the
48+
nghttp3 source files.
49+
50+
Check that Node.js still builds and tests.
51+
52+
1. Add nghttp3:
53+
```console
54+
$ git add deps/ngtcp2
55+
```
56+
2. Commit the changes: `git commit`.
57+
3. Add a message like:
58+
```text
59+
deps: update nghttp3 to <version>
60+
61+
Updated as described in doc/contributing/maintaining-ngtcp2.md.
62+
```
Collapse file
+67Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/sh
2+
set -e
3+
# Shell script to update nghttp3 in the source tree to a specific version
4+
5+
BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd)
6+
DEPS_DIR="$BASE_DIR/deps"
7+
[ -z "$NODE" ] && NODE="$BASE_DIR/out/Release/node"
8+
[ -x "$NODE" ] || NODE=$(command -v node)
9+
10+
NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
11+
const res = await fetch('https://api.github.com/repos/ngtcp2/nghttp3/releases');
12+
if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
13+
const releases = await res.json()
14+
const { tag_name } = releases.at(0);
15+
console.log(tag_name.replace('v', ''));
16+
EOF
17+
)"
18+
19+
NGHTTP3_VERSION_H="$DEPS_DIR/ngtcp2/nghttp3/lib/includes/nghttp3/version.h"
20+
21+
CURRENT_VERSION=$(grep "#define NGHTTP3_VERSION" "$NGHTTP3_VERSION_H" | sed -n "s/^.*VERSION \"\(.*\)\"/\1/p")
22+
23+
if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
24+
echo "Skipped because http3 is on the latest version."
25+
exit 0
26+
fi
27+
28+
WORKSPACE=$(mktemp -d 2> /dev/null || mktemp -d -t 'tmp')
29+
30+
cleanup () {
31+
EXIT_CODE=$?
32+
[ -d "$WORKSPACE" ] && rm -rf "$WORKSPACE"
33+
exit $EXIT_CODE
34+
}
35+
36+
trap cleanup INT TERM EXIT
37+
38+
NGHTTP3_REF="v$NEW_VERSION"
39+
NGHTTP3_ZIP="nghttp3-$NEW_VERSION"
40+
41+
cd "$WORKSPACE"
42+
43+
echo "Fetching nghttp3 source archive..."
44+
curl -sL -o "$NGHTTP3_ZIP.zip" "https://github.com/ngtcp2/nghttp3/archive/refs/tags/$NGHTTP3_REF.zip"
45+
unzip "$NGHTTP3_ZIP.zip"
46+
rm "$NGHTTP3_ZIP.zip"
47+
mv "$NGHTTP3_ZIP" nghttp3
48+
49+
cd nghttp3
50+
51+
autoreconf -i
52+
53+
./configure --prefix="$PWD/build" --enable-lib-only
54+
55+
cp -R lib/* "$DEPS_DIR/ngtcp2/nghttp3/lib/"
56+
57+
echo "All done!"
58+
echo ""
59+
echo "Please git add nghttp3, commit the new version:"
60+
echo ""
61+
echo "$ git add -A deps/nghttp3"
62+
echo "$ git commit -m \"deps: update nghttp3 to $NEW_VERSION\""
63+
echo ""
64+
65+
# The last line of the script should always print the new version,
66+
# as we need to add it to $GITHUB_ENV variable.
67+
echo "NEW_VERSION=$NEW_VERSION"
Collapse file
+73Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/sh
2+
set -e
3+
# Shell script to update ngtcp2 in the source tree to a specific version
4+
5+
BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd)
6+
DEPS_DIR="$BASE_DIR/deps"
7+
[ -z "$NODE" ] && NODE="$BASE_DIR/out/Release/node"
8+
[ -x "$NODE" ] || NODE=$(command -v node)
9+
10+
NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
11+
const res = await fetch('https://api.github.com/repos/ngtcp2/ngtcp2/releases');
12+
if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
13+
const releases = await res.json()
14+
const { tag_name } = releases.at(0);
15+
console.log(tag_name.replace('v', ''));
16+
EOF
17+
)"
18+
19+
NGTCP2_VERSION_H="$DEPS_DIR/ngtcp2/ngtcp2/lib/includes/ngtcp2/version.h"
20+
21+
CURRENT_VERSION=$(grep "#define NGTCP2_VERSION" "$NGTCP2_VERSION_H" | sed -n "s/^.*VERSION \"\(.*\)\"/\1/p")
22+
23+
if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
24+
echo "Skipped because ngtcp2 is on the latest version."
25+
exit 0
26+
fi
27+
28+
WORKSPACE=$(mktemp -d 2> /dev/null || mktemp -d -t 'tmp')
29+
30+
cleanup () {
31+
EXIT_CODE=$?
32+
[ -d "$WORKSPACE" ] && rm -rf "$WORKSPACE"
33+
exit $EXIT_CODE
34+
}
35+
36+
trap cleanup INT TERM EXIT
37+
38+
NGTCP2_REF="v$NEW_VERSION"
39+
NGTCP2_ZIP="ngtcp2-$NEW_VERSION"
40+
41+
cd "$WORKSPACE"
42+
43+
echo "Fetching ngtcp2 source archive..."
44+
curl -sL -o "$NGTCP2_ZIP.zip" "https://github.com/ngtcp2/ngtcp2/archive/refs/tags/$NGTCP2_REF.zip"
45+
unzip "$NGTCP2_ZIP.zip"
46+
rm "$NGTCP2_ZIP.zip"
47+
mv "$NGTCP2_ZIP" ngtcp2
48+
49+
cd ngtcp2
50+
51+
autoreconf -i
52+
53+
# For Mac users who have installed libev with MacPorts, append
54+
# ',-L/opt/local/lib' to LDFLAGS, and also pass
55+
# CPPFLAGS="-I/opt/local/include" to ./configure.
56+
57+
./configure --prefix="$PWD/build" --enable-lib-only
58+
59+
cp -R lib/* "$DEPS_DIR/ngtcp2/ngtcp2/lib/"
60+
61+
cp -R crypto/* "$DEPS_DIR/ngtcp2/ngtcp2/crypto/"
62+
63+
echo "All done!"
64+
echo ""
65+
echo "Please git add ngtcp2, commit the new version:"
66+
echo ""
67+
echo "$ git add -A deps/ngtcp2"
68+
echo "$ git commit -m \"deps: update ngtcp2 to $NEW_VERSION\""
69+
echo ""
70+
71+
# The last line of the script should always print the new version,
72+
# as we need to add it to $GITHUB_ENV variable.
73+
echo "NEW_VERSION=$NEW_VERSION"

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.