Skip to content
Open
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
35 changes: 35 additions & 0 deletions .github/workflows/update-test426-fixtures.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: test426 fixtures update
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we move this to .github/workflows/tools.yml?


on:
schedule:
- cron: 0 0 * * 0
workflow_dispatch:

permissions:
contents: read

jobs:
update-test426-fixtures:
if: github.repository == 'nodejs/node' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
persist-credentials: false

- name: Update test426 fixtures from tc39/source-map-tests
run: bash tools/dep_updaters/update-test426-fixtures.sh

- name: Open or update PR for test426 fixtures
uses: gr2m/create-or-update-pull-request-action@77596e3166f328b24613f7082ab30bf2d93079d5
with:
branch: actions/update-test426-fixtures
author: Node.js GitHub Bot <[email protected]>
title: 'test: update test426 fixtures from tc39/source-map-tests'
commit-message: 'test: update test426 fixtures from tc39/source-map-tests'
labels: test
update-pull-request-title-and-body: true
body: |
This is an automated update of the test426 fixtures from https://github.com/tc39/source-map-tests.
env:
GITHUB_TOKEN: ${{ secrets.GH_USER_TOKEN }}
24 changes: 24 additions & 0 deletions tools/dep_updaters/update-test426-fixtures.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh

set -e
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We get a much more useful debug output with set -x

Suggested change
set -e
set -ex


BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd)

TARGET_DIR="$BASE_DIR/test/fixtures/test426"
README="$BASE_DIR/test/test426/README.md"
TARBALL_URL=$(curl -fsIo /dev/null -w '%header{Location}' https://github.com/tc39/source-map-tests/archive/HEAD.tar.gz)
SHA=$(basename "$TARBALL_URL")

TMP_DIR="$(mktemp -d)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
TMP_DIR="$(mktemp -d)"
CURRENT_SHA=$(sed -n 's#^.*https://github.com/tc39/source-map-tests/commit/\([0-9a-f]*\).*$#\1#p' "$README")
if [ "$CURRENT_SHA" = "$SHA" ]; then
echo "Already up-to-date"
exit 0
fi


rm -rf "$TARGET_DIR"
mkdir "$TARGET_DIR"
curl -f "$TARBALL_URL" | tar -xz --strip-components 1 -C "$TARGET_DIR"

rm -rf "$TMP_DIR"

TMP_FILE=$(mktemp)
sed "s#https://github.com/tc39/source-map-tests/commit/[0-9a-f]*#https://github.com/tc39/source-map-tests/commit/$SHA#" "$README" > "$TMP_FILE"
Comment on lines +18 to +21
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rm -rf "$TMP_DIR"
TMP_FILE=$(mktemp)
sed "s#https://github.com/tc39/source-map-tests/commit/[0-9a-f]*#https://github.com/tc39/source-map-tests/commit/$SHA#" "$README" > "$TMP_FILE"
TMP_FILE=$(mktemp)
sed "s/$CURRENT_SHA/$SHA/" "$README" > "$TMP_FILE"

mv "$TMP_FILE" "$README"

echo "test426 fixtures updated to $SHA."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
echo "test426 fixtures updated to $SHA."
# 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=$SHA"

Loading