Skip to content

Commit

Permalink
Merge pull request #73 from nodenv/test-workflow
Browse files Browse the repository at this point in the history
Update test.yml
  • Loading branch information
jasonkarns authored May 30, 2024
2 parents 1b813c1 + f98c9b1 commit a05138b
Show file tree
Hide file tree
Showing 12 changed files with 139 additions and 100 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# https://EditorConfig.org
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Release
on:
push: { tags: 'v[0-9]+.[0-9]+.[0-9]+*' }

permissions: read-all

jobs:
release:
permissions: { contents: write }
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/sync-default-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ on:
push: { branches: main }
workflow_dispatch:

permissions: read-all

# One-time commands for users to switch-over:
#
# ```console
Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
name: Test
on: [push, pull_request]
on: [push, pull_request, workflow_dispatch]

permissions: read-all

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm cit
uses: nodenv/.github/.github/workflows/test.yml@v4
permissions:
contents: read
packages: read
statuses: write # to report status checks
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ If installed outside of `NODENV_ROOT`, you must ensure its `share/node-build` di

To install, clone this repository into your `$(nodenv root)/plugins` directory.

$ git clone /~https://github.com/nodenv/node-build-update-defs.git "$(nodenv root)"/plugins/node-build-update-defs
git clone /~https://github.com/nodenv/node-build-update-defs.git "$(nodenv root)"/plugins/node-build-update-defs

### Installing with Homebrew

$ brew install nodenv/nodenv/node-build-update-defs
brew install nodenv/nodenv/node-build-update-defs

*__Note:__
Requires manually adding `$(brew --prefix node-build-update-defs)/share/node-build` directory to `NODE_BUILD_DEFINITIONS`*

### Installation with npm

$ npm install --global @nodenv/node-build-update-defs
npm install --global @nodenv/node-build-update-defs

*__Note:__
Requires manually adding `$(npm -g prefix)/lib/node_modules/@nodenv/node-build-update-defs/share/node-build` directory to `NODE_BUILD_DEFINITIONS`*
Expand All @@ -54,12 +54,12 @@ Unlike virtually every other nodenv plugin, node-build-update-defs actually depe
(The scraper runs on node.)
A somewhat recent version of node is required – it is recommended to configure a node-version within the plugin directory itself (substitute your chosen version):

$ cd "$(nodenv root)"/plugins/node-build-update-defs
$ nodenv local 6.0
cd "$(nodenv root)"/plugins/node-build-update-defs
nodenv local 6.0

## Usage

$ nodenv update-version-defs
nodenv update-version-defs

By default, this will create build definitions in the plugin's `share/node-build/` directory.
This directory can be overridden with `--destination`.
Expand All @@ -84,7 +84,7 @@ In normal operation, build definitions will gradually build up in this plugin's
Eventually, as the scraped definitions are added to node-build itself, these user-scraped definitions will become duplicates when their node-build installation is updated.
In order to ensure one is frequently running on the "proper" build definitions from node-build, any duplicates in the plugin directory ought to be removed.

$ nodenv prune-version-defs
nodenv prune-version-defs

This subcommand removes (or lists with `--dry-run`) any duplicate build definitions.
Like `update-version-defs`, `--destination <dir>` overrides the default value of `<plugin-root>/share/node-build` as the directory from which duplicates are removed.
Expand Down
53 changes: 30 additions & 23 deletions bin/nodenv-prune-version-defs
Original file line number Diff line number Diff line change
Expand Up @@ -54,29 +54,36 @@ shopt -u nullglob
# Provide nodenv completions
while [ $# -gt 0 ]; do
case "$1" in
--complete )
echo --destination
echo --dry-run
echo --force
echo --help
echo --verbose
exit ;;
-d | --destination )
shift
# overwrite the defs write target
NODE_BUILD_DEFINITIONS="$(abs_dirname "${1%/}/"):${NODE_BUILD_DEFINITIONS}" ;;
-f | --force )
FORCE=true ;;
-h | --help )
exec nodenv-help update-version-defs ;;
-n | --dry-run )
DRY_RUN=true
VERBOSE=true ;;
-v | --verbose )
VERBOSE=true ;;
* )
nodenv-help --usage update-version-defs >&2
exit 1;;
--complete)
echo --destination
echo --dry-run
echo --force
echo --help
echo --verbose
exit
;;
-d | --destination)
shift
# overwrite the defs write target
NODE_BUILD_DEFINITIONS="$(abs_dirname "${1%/}/"):${NODE_BUILD_DEFINITIONS}"
;;
-f | --force)
FORCE=true
;;
-h | --help)
exec nodenv-help update-version-defs
;;
-n | --dry-run)
DRY_RUN=true
VERBOSE=true
;;
-v | --verbose)
VERBOSE=true
;;
*)
nodenv-help --usage update-version-defs >&2
exit 1
;;
esac
shift
done
Expand Down
67 changes: 37 additions & 30 deletions bin/nodenv-update-version-defs
Original file line number Diff line number Diff line change
Expand Up @@ -75,37 +75,44 @@ unset PATTERN
# Provide nodenv completions
while [ $# -gt 0 ]; do
case "$1" in
--complete )
echo --destination
echo --dry-run
echo --force
echo --regexp
echo --nodejs
echo --nodejs-pre
echo --nodejs-nightly
echo --chakracore
echo --chakracore-pre
echo --chakracore-nightly
echo --graal
exit ;;
-d | --destination )
shift
# overwrite the defs write target
NODE_BUILD_DEFINITIONS="$(abs_dirname "${1%/}/"):${NODE_BUILD_DEFINITIONS}" ;;
-n | --dry-run)
DRY_RUN=true ;;
-f | --force)
FORCE=true ;;
-e | --regexp)
PATTERN=$2
shift ;;
--nodejs | --nodejs-pre | --nodejs-nightly | \
--complete)
echo --destination
echo --dry-run
echo --force
echo --regexp
echo --nodejs
echo --nodejs-pre
echo --nodejs-nightly
echo --chakracore
echo --chakracore-pre
echo --chakracore-nightly
echo --graal
exit
;;
-d | --destination)
shift
# overwrite the defs write target
NODE_BUILD_DEFINITIONS="$(abs_dirname "${1%/}/"):${NODE_BUILD_DEFINITIONS}"
;;
-n | --dry-run)
DRY_RUN=true
;;
-f | --force)
FORCE=true
;;
-e | --regexp)
PATTERN=$2
shift
;;
--nodejs | --nodejs-pre | --nodejs-nightly | \
--chakracore | --chakracore-pre | --chakracore-nightly | \
--graal )
SCRAPERS+=("${1#--}") ;;
* )
nodenv-help --usage update-version-defs >&2
exit 1;;
--graal)
SCRAPERS+=("${1#--}")
;;
*)
nodenv-help --usage update-version-defs >&2
exit 1
;;
esac
shift
done
Expand Down
4 changes: 4 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions script/commit-definitions
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ IFS=$'\n\t'
cd "$(git rev-parse --show-toplevel)" || exit

git ls-files --others --exclude-standard -- share/node-build |
while read -r node_def; do
node_name=${node_def##*/}
git add -- "$node_def"
git commit --quiet --message "$node_name" --message "Created with \`npm run submit-definitions\`." --only -- "$node_def"
echo "$node_name"
done
while read -r node_def; do
node_name=${node_def##*/}
git add -- "$node_def"
git commit --quiet --message "$node_name" --message "Created with \`npm run submit-definitions\`." --only -- "$node_def"
echo "$node_name"
done
12 changes: 7 additions & 5 deletions script/lts-lint-definitions
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ TODAY=$(date -u +'%F')

for arg in "$@"; do
case "$arg" in
--fix) FIX=1;;
*) DIR=$arg;;
--fix) FIX=1 ;;
*) DIR=$arg ;;
esac
done

Expand Down Expand Up @@ -87,7 +87,7 @@ prepend_message() {
local file=$2

sed -e "1 i\\
$msg" "$file" 1<> "$file"
$msg" "$file" 1<>"$file"
}

assert_message() {
Expand Down Expand Up @@ -116,8 +116,10 @@ assert_warnings() {

echo "v$version maint: $maint_date eol: $eol_date" >&2
{
if past "$eol_date"; then assert_message eol "$version"
elif past "$maint_date"; then assert_message lts "$version"
if past "$eol_date"; then
assert_message eol "$version"
elif past "$maint_date"; then
assert_message lts "$version"
fi
} || status=$?
done
Expand Down
44 changes: 23 additions & 21 deletions script/verify-definitions
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set -eufo pipefail
IFS=$'\n\t'

help_text() {
sed -ne '/^#/!q;s/.\{1,2\}//;1d;p' < "$0"
sed -ne '/^#/!q;s/.\{1,2\}//;1d;p' <"$0"
}

compute_sha2() {
Expand All @@ -27,7 +27,7 @@ download_and_verify() {
local file="$2"
local expected="$3"
download_package "$url" "$file" || return $?
checksum="$(compute_sha2 < "$file")"
checksum="$(compute_sha2 <"$file")"
if [ "$checksum" != "$expected" ]; then
{
echo "Error: $url doesn't match its checksum:"
Expand Down Expand Up @@ -64,7 +64,7 @@ verify() {
url="${url%#*}"
echo "Verifying checksum for $url"
file="${TMPDIR:-/tmp}/$checksum"
download_and_verify "$url" "$file" "$checksum" || (( status += 1))
download_and_verify "$url" "$file" "$checksum" || ((status += 1))
done < <(xargs cat | extract_urls)

if [ "$status" != 0 ]; then
Expand All @@ -74,23 +74,25 @@ verify() {
}

case "${1-}" in
'' )
{ echo "COMMIT_RANGE or FILES required"
help_text
} >&2
exit 1;;
-h | --help )
'')
{
echo "COMMIT_RANGE or FILES required"
help_text
;;
- )
verify
;;
-- )
echo "$@" | verify
;;
* )
echo "Verifying changes from $1"
changed_files "$1"
potentially_new_packages "$1" | verify
;;
} >&2
exit 1
;;
-h | --help)
help_text
;;
-)
verify
;;
--)
echo "$@" | verify
;;
*)
echo "Verifying changes from $1"
changed_files "$1"
potentially_new_packages "$1" | verify
;;
esac
6 changes: 3 additions & 3 deletions src/definition-graal.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ module.exports = class GraalDefinition extends Definition {
return ({ url, sha }) =>
url.match(/\.tar\.gz$/)
? {
platform: this.platformFrom(url),
downloadUri: `${url}#${sha}`
}
platform: this.platformFrom(url),
downloadUri: `${url}#${sha}`
}
: null
}

Expand Down

0 comments on commit a05138b

Please sign in to comment.