| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7c552e6 commit e3f4ff4
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,6 +23,7 @@ on: | |||
| 23 | 23 | - corepack | |
| 24 | 24 | - doc | |
| 25 | 25 | - eslint | |
| 26 | + - googletest | ||
| 26 | 27 | - libuv | |
| 27 | 28 | - lint-md-dependencies | |
| 28 | 29 | - llhttp | |
@@ -235,6 +236,14 @@ jobs: | |||
| 235 | 236 | cat temp-output | |
| 236 | 237 | tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true | |
| 237 | 238 | rm temp-output | |
| 239 | + - id: googletest | ||
| 240 | + subsystem: deps | ||
| 241 | + label: dependencies, test | ||
| 242 | + run: | | ||
| 243 | + ./tools/dep_updaters/update-googletest.sh > temp-output | ||
| 244 | + cat temp-output | ||
| 245 | + tail -n1 temp-output | grep "NEW_VERSION=" >> "$GITHUB_ENV" || true | ||
| 246 | + rm temp-output | ||
| 238 | 247 | steps: | |
| 239 | 248 | - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 | |
| 240 | 249 | if: github.event_name == 'schedule' || inputs.id == 'all' || inputs.id == matrix.id | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,93 @@ | |||
| 1 | + #!/bin/sh | ||
| 2 | + set -e | ||
| 3 | + # Shell script to update GoogleTest in the source tree to the most recent version. | ||
| 4 | + # GoogleTest follows the Abseil Live at Head philosophy and rarely creates tags | ||
| 5 | + # or GitHub releases, so instead, we use the latest commit on the main branch. | ||
| 6 | + | ||
| 7 | + BASE_DIR=$(cd "$(dirname "$0")/../.." && pwd) | ||
| 8 | + DEPS_DIR="$BASE_DIR/deps" | ||
| 9 | + | ||
| 10 | + NEW_UPSTREAM_SHA1=$(git ls-remote "https://github.com/google/googletest.git" HEAD | awk '{print $1}') | ||
| 11 | + NEW_VERSION=$(echo "$NEW_UPSTREAM_SHA1" | head -c 7) | ||
| 12 | + | ||
| 13 | + echo "Comparing $NEW_VERSION with current revision" | ||
| 14 | + | ||
| 15 | + git remote add googletest-upstream https://github.com/google/googletest.git | ||
| 16 | + git fetch googletest-upstream "$NEW_UPSTREAM_SHA1" | ||
| 17 | + git remote remove googletest-upstream | ||
| 18 | + | ||
| 19 | + DIFF_TREE=$( | ||
| 20 | + git diff HEAD:deps/googletest/LICENSE "$NEW_UPSTREAM_SHA1:LICENSE" | ||
| 21 | + git diff-tree HEAD:deps/googletest/include "$NEW_UPSTREAM_SHA1:googletest/include" | ||
| 22 | + git diff-tree HEAD:deps/googletest/src "$NEW_UPSTREAM_SHA1:googletest/src" | ||
| 23 | + ) | ||
| 24 | + | ||
| 25 | + if [ -z "$DIFF_TREE" ]; then | ||
| 26 | + echo "Skipped because googletest is on the latest version." | ||
| 27 | + exit 0 | ||
| 28 | + fi | ||
| 29 | + | ||
| 30 | + # This is a rather arbitrary restriction. This script is assumed to run on | ||
| 31 | + # Sunday, shortly after midnight UTC. This check thus prevents pulling in the | ||
| 32 | + # most recent commits if any changes were made on Friday or Saturday (UTC). | ||
| 33 | + # Because of Google's own "Live at Head" philosophy, new bugs that are likely to | ||
| 34 | + # affect Node.js tend to be fixed quickly, so we don't want to pull in a commit | ||
| 35 | + # that was just pushed, and instead rather wait for the next week's update. If | ||
| 36 | + # no commits have been pushed in the last two days, we assume that the most | ||
| 37 | + # recent commit is stable enough to be pulled in. | ||
| 38 | + LAST_CHANGE_DATE=$(git log -1 --format=%ct "$NEW_UPSTREAM_SHA1" -- LICENSE googletest/include googletest/src) | ||
| 39 | + TWO_DAYS_AGO=$(date -d 'now - 2 days' '+%s') | ||
| 40 | + if [ "$LAST_CHANGE_DATE" -gt "$TWO_DAYS_AGO" ]; then | ||
| 41 | + echo "Skipped because the latest version is too recent." | ||
| 42 | + exit 0 | ||
| 43 | + fi | ||
| 44 | + | ||
| 45 | + echo "Creating temporary work tree" | ||
| 46 | + | ||
| 47 | + WORKSPACE=$(mktemp -d 2> /dev/null || mktemp -d -t 'tmp') | ||
| 48 | + WORKTREE="$WORKSPACE/googletest" | ||
| 49 | + | ||
| 50 | + cleanup () { | ||
| 51 | + EXIT_CODE=$? | ||
| 52 | + [ -d "$WORKTREE" ] && git worktree remove -f "$WORKTREE" | ||
| 53 | + [ -d "$WORKSPACE" ] && rm -rf "$WORKSPACE" | ||
| 54 | + exit $EXIT_CODE | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + trap cleanup INT TERM EXIT | ||
| 58 | + | ||
| 59 | + git worktree add "$WORKTREE" "$NEW_UPSTREAM_SHA1" | ||
| 60 | + | ||
| 61 | + echo "Copying LICENSE, include and src to deps/googletest" | ||
| 62 | + for p in LICENSE googletest/include googletest/src ; do | ||
| 63 | + rm -rf "$DEPS_DIR/googletest/$(basename "$p")" | ||
| 64 | + cp -R "$WORKTREE/$p" "$DEPS_DIR/googletest/$(basename "$p")" | ||
| 65 | + done | ||
| 66 | + | ||
| 67 | + echo "Updating googletest.gyp" | ||
| 68 | + | ||
| 69 | + NEW_GYP=$( | ||
| 70 | + sed "/'googletest_sources': \[/q" "$DEPS_DIR/googletest/googletest.gyp" | ||
| 71 | + for f in $( (cd deps/googletest/ && find include src -type f \( -iname '*.h' -o -iname '*.cc' \) ) | LANG=C LC_ALL=C sort --stable ); do | ||
| 72 | + if [ "$(basename "$f")" != "gtest_main.cc" ] && | ||
| 73 | + [ "$(basename "$f")" != "gtest-all.cc" ] && | ||
| 74 | + [ "$(basename "$f")" != "gtest_prod.h" ] ; then | ||
| 75 | + echo " '$f'," | ||
| 76 | + fi | ||
| 77 | + done | ||
| 78 | + sed -ne '/\]/,$ p' "$DEPS_DIR/googletest/googletest.gyp" | ||
| 79 | + ) | ||
| 80 | + | ||
| 81 | + echo "$NEW_GYP" >"$DEPS_DIR/googletest/googletest.gyp" | ||
| 82 | + | ||
| 83 | + echo "All done!" | ||
| 84 | + echo "" | ||
| 85 | + echo "Please git stage googletest, commit the new version:" | ||
| 86 | + echo "" | ||
| 87 | + echo "$ git stage -A deps/googletest" | ||
| 88 | + echo "$ git commit -m \"deps: update googletest to $NEW_VERSION\"" | ||
| 89 | + echo "" | ||
| 90 | + | ||
| 91 | + # The last line of the script should always print the new version, | ||
| 92 | + # as we need to add it to $GITHUB_ENV variable. | ||
| 93 | + echo "NEW_VERSION=$NEW_VERSION" | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments