Skip to content

Commit

Permalink
tools: add automation for updating postject dependency
Browse files Browse the repository at this point in the history
Signed-off-by: Darshan Sen <raisinten@gmail.com>
PR-URL: #46157
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
  • Loading branch information
RaisinTen authored and juanarbol committed Jan 31, 2023
1 parent d7a8c07 commit 1b0cc79
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions doc/contributing/maintaining-postject.md
Original file line number Diff line number Diff line change
@@ -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.
```
20 changes: 20 additions & 0 deletions tools/dep_updaters/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
22 changes: 22 additions & 0 deletions tools/dep_updaters/update-postject.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1b0cc79

Please sign in to comment.