GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — tools: automate cares update · nodejs/node@a3f272e

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .github/workflows
    • tools.yml
  • doc/contributing
    • maintaining-c-ares.md
  • tools
    • dep_updaters
      • update-c-ares.sh
    • update-cares.sh
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.github/workflows/tools.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/tools.yml
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,14 @@ jobs:
153153
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
154154
./tools/update-llhttp.sh "$NEW_VERSION"
155155
fi
156+
- id: c-ares
157+
subsystem: deps
158+
label: dependencies
159+
run: |
160+
./tools/dep_updaters/update-c-ares.sh > temp-output
161+
cat temp-output
162+
tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true
163+
rm temp-output
156164
steps:
157165
- uses: actions/checkout@v3
158166
with:
Collapse file

‎doc/contributing/maintaining-c-ares.md‎

Copy file name to clipboardExpand all lines: doc/contributing/maintaining-c-ares.md
+4-12Lines changed: 4 additions & 12 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,11 @@ Updates to the c-ares dependency involve the following steps:
1313

1414
## Running the update script
1515

16-
The `tools/update-cares.sh` script automates the update of the c-ares source
17-
files, preserving the existing files added by Node.js.
16+
The `tools/dep_updaters/update-c-ares.sh` script automates the update of
17+
the c-ares source files, preserving the existing files added by Node.js.
1818

19-
In the following examples, `x.y.z` should match the c-ares version to update to.
20-
21-
```console
22-
./tools/update-cares.sh x.y.z
23-
```
24-
25-
e.g.
26-
27-
```console
28-
./tools/update-cares.sh 1.18.1
19+
```bash
20+
./tools/dep_updaters/update-c-ares.sh
2921
```
3022

3123
## Check that Node.js still builds and tests
Collapse file

‎tools/dep_updaters/update-c-ares.sh‎

Copy file name to clipboard
+71Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/bin/sh
2+
set -e
3+
# Shell script to update c-ares in the source tree to a specific version
4+
5+
BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd)
6+
DEPS_DIR="$BASE_DIR/deps"
7+
8+
[ -z "$NODE" ] && NODE="$BASE_DIR/out/Release/node"
9+
[ -x "$NODE" ] || NODE=$(command -v node)
10+
11+
NEW_VERSION="$("$NODE" --input-type=module <<'EOF'
12+
const res = await fetch('https://api.github.com/repos/c-ares/c-ares/releases/latest');
13+
if (!res.ok) throw new Error(`FetchError: ${res.status} ${res.statusText}`, { cause: res });
14+
const { tag_name } = await res.json();
15+
console.log(tag_name.replace('cares-', '').replaceAll('_', '.'));
16+
EOF
17+
)"
18+
19+
CURRENT_VERSION=$(grep "#define ARES_VERSION_STR" ./deps/cares/include/ares_version.h | sed -n "s/^.*VERSION_STR \"\(.*\)\"/\1/p")
20+
21+
echo "Comparing $NEW_VERSION with $CURRENT_VERSION"
22+
23+
if [ "$NEW_VERSION" = "$CURRENT_VERSION" ]; then
24+
echo "Skipped because c-ares is on the latest version."
25+
exit 0
26+
fi
27+
28+
echo "Making temporary workspace"
29+
30+
WORKSPACE=$(mktemp -d 2> /dev/null || mktemp -d -t 'tmp')
31+
32+
cleanup () {
33+
EXIT_CODE=$?
34+
[ -d "$WORKSPACE" ] && rm -rf "$WORKSPACE"
35+
exit $EXIT_CODE
36+
}
37+
38+
trap cleanup INT TERM EXIT
39+
40+
ARES_REF="cares-$(echo "$NEW_VERSION" | tr . _)"
41+
ARES_TARBALL="c-ares-$NEW_VERSION.tar.gz"
42+
43+
cd "$WORKSPACE"
44+
45+
echo "Fetching c-ares source archive"
46+
curl -sL "https://github.com/c-ares/c-ares/releases/download/$ARES_REF/$ARES_TARBALL" | tar xz
47+
mv "c-ares-$NEW_VERSION" cares
48+
49+
echo "Removing tests"
50+
rm -rf "$WORKSPACE/cares/test"
51+
52+
echo "Copying existing .gitignore, config and gyp files"
53+
cp -R "$DEPS_DIR/cares/config" "$WORKSPACE/cares"
54+
cp "$DEPS_DIR/cares/.gitignore" "$WORKSPACE/cares"
55+
cp "$DEPS_DIR/cares/cares.gyp" "$WORKSPACE/cares"
56+
57+
echo "Replacing existing c-ares"
58+
rm -rf "$DEPS_DIR/cares"
59+
mv "$WORKSPACE/cares" "$DEPS_DIR/"
60+
61+
echo "All done!"
62+
echo ""
63+
echo "Please git add c-ares, commit the new version:"
64+
echo ""
65+
echo "$ git add -A deps/cares"
66+
echo "$ git commit -m \"deps: update c-ares to $NEW_VERSION\""
67+
echo ""
68+
69+
# The last line of the script should always print the new version,
70+
# as we need to add it to $GITHUB_ENV variable.
71+
echo "NEW_VERSION=$NEW_VERSION"
Collapse file

‎tools/update-cares.sh‎

Copy file name to clipboardExpand all lines: tools/update-cares.sh
-56Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.