From 1b0cc79785313cc56e2a476491685d0f13dcc61b Mon Sep 17 00:00:00 2001 From: Darshan Sen Date: Sat, 14 Jan 2023 13:19:36 +0530 Subject: [PATCH] tools: add automation for updating postject dependency Signed-off-by: Darshan Sen PR-URL: https://github.com/nodejs/node/pull/46157 Reviewed-By: Antoine du Hamel Reviewed-By: Michael Dawson --- .github/workflows/tools.yml | 10 ++++++++++ doc/contributing/maintaining-postject.md | 23 +++++++++++++++++++++++ tools/dep_updaters/README.md | 20 ++++++++++++++++++++ tools/dep_updaters/update-postject.sh | 22 ++++++++++++++++++++++ 4 files changed, 75 insertions(+) create mode 100644 doc/contributing/maintaining-postject.md create mode 100755 tools/dep_updaters/update-postject.sh diff --git a/.github/workflows/tools.yml b/.github/workflows/tools.yml index f2d1a3a839c8d5..a056aa705bd246 100644 --- a/.github/workflows/tools.yml +++ b/.github/workflows/tools.yml @@ -77,6 +77,16 @@ jobs: echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV ./tools/update-undici.sh fi + - id: postject + subsystem: deps + label: dependencies + run: | + NEW_VERSION=$(npm view postject dist-tags.latest) + CURRENT_VERSION=$(node -p "require('./test/fixtures/postject-copy/node_modules/postject/package.json').version") + if [ "$NEW_VERSION" != "$CURRENT_VERSION" ]; then + echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV + ./tools/dep_updaters/update-postject.sh + fi - id: base64 subsystem: deps label: dependencies diff --git a/doc/contributing/maintaining-postject.md b/doc/contributing/maintaining-postject.md new file mode 100644 index 00000000000000..96746e22796900 --- /dev/null +++ b/doc/contributing/maintaining-postject.md @@ -0,0 +1,23 @@ +# Maintaining postject + +The [postject](https://github.com/nodejs/postject) dependency is used for the +[Single Executable strategic initiative](https://github.com/nodejs/single-executable). + +## Updating postject + +The `tools/dep_updaters/update-postject.sh` script automates the update of the +postject source files. + +Check that Node.js still builds and tests. + +## Committing postject + +Add postject: `git add --all test/fixtures/postject-copy` + +Commit the changes with a message like: + +```text +deps: update postject to 1.0.0-alpha.4 + +Updated as described in doc/contributing/maintaining-postject.md. +``` diff --git a/tools/dep_updaters/README.md b/tools/dep_updaters/README.md index 64c59c9d7d5f99..bae6d2be2d0943 100644 --- a/tools/dep_updaters/README.md +++ b/tools/dep_updaters/README.md @@ -60,3 +60,23 @@ been created with the changes), do the following: 3. Check that Node.js compiles without errors and the tests pass. 4. Create a commit for the update and in the commit message include the important/relevant items from the changelog. + +## postject + +The `update-postject.sh` script downloads postject from the [npm package](http://npmjs.com/package/postject) +and uses it to replace the contents of `test/fixtures/postject-copy`. + +In order to update, the following command can be run: + +```bash +./tools/dep_updaters/update-postject.sh +``` + +Once the script has run (either manually, or by CI in which case a PR will have +been created with the changes), do the following: + +1. Check the [changelog](https://github.com/nodejs/postject/releases/tag/v1.0.0-alpha.4) + for things that might require changes in Node.js. +2. Check that Node.js compiles without errors and the tests pass. +3. Create a commit for the update and in the commit message include the + important/relevant items from the changelog. diff --git a/tools/dep_updaters/update-postject.sh b/tools/dep_updaters/update-postject.sh new file mode 100755 index 00000000000000..ceda1866d237c3 --- /dev/null +++ b/tools/dep_updaters/update-postject.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# Shell script to update postject in the source tree to the latest release. + +# This script must be in the tools directory when it runs because it uses the +# script source file path to determine directories to work in. + +set -ex + +cd "$( dirname "$0" )/../.." || exit +rm -rf test/fixtures/postject-copy +mkdir test/fixtures/postject-copy +cd test/fixtures/postject-copy || 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 --no-bin-links --ignore-scripts postject