0
0
mirror of https://github.com/tj/n.git synced 2024-11-23 18:17:29 +01:00

Merge branch 'develop' into feature/posix

This commit is contained in:
John Gee 2022-12-14 20:47:20 +13:00
commit 89b8252482
11 changed files with 1 additions and 115 deletions

View File

@ -1,49 +0,0 @@
#!/usr/bin/env bash
# Unoffical bash safe mode
set -euo pipefail
BIN_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
waitproxy() {
while ! nc -z localhost 8080 ; do sleep 1 ; done
}
if nc -z localhost 8080; then
echo "Error: port 8080 already in use. Is mitmdump already running?"
pgrep -f -l mitmdump
exit 2
fi
echo "Launching proxy..."
mitmdump -w proxy~~.dump &> /dev/null &
mitm_process="$!"
echo "Waiting for proxy..."
waitproxy
echo "Recording downloads..."
source tests/shared-functions.bash
unset_n_env
setup_tmp_prefix
# Hack curl to avoid certificate issues with proxy
readonly CURL_HOME="$(dirname "${BIN_DIRECTORY}")/config"
export CURL_HOME
# Go through proxy so it can record traffic, http for taobao redirects
http_proxy="$(hostname):8080"
export http_proxy
https_proxy="$(hostname):8080"
export https_proxy
# Need to do wget first, as curl gets compressed index.tab which will break wget.
# linux, archlinux-curl gets gz archives
docker-compose run archlinux-curl /mnt/test/tests/install-reference-versions.bash
# linux, ubuntu-curl would get compressed index and gz archives
docker-compose run ubuntu-wget /mnt/test/tests/install-reference-versions.bash
# native
tests/install-reference-versions.bash
rm -rf "${TMP_PREFIX_DIR}"
echo "Stopping proxy"
kill "${mitm_process}"

View File

@ -1,12 +0,0 @@
#!/usr/bin/env bash
BIN_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
echo ""
echo "To make use of proxy server:"
echo " export https_proxy=\"$(hostname):8080\""
echo " export http_proxy=\"$(hostname):8080\""
echo " export CURL_HOME=$(dirname "${BIN_DIRECTORY}")/config"
echo ""
echo "Launching proxy server..."
mitmdump --server-replay-nopop --server-replay proxy~~.dump

View File

@ -2,7 +2,7 @@
BIN_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# We want to cover curl and wget especially, gz and xz and variety of OS a bonus.
services=( archlinux-curl ubuntu-wget )
services=( ubuntu-curl ubuntu-wget )
cd "$(dirname "${BIN_DIRECTORY}")" || exit 2
for service in "${services[@]}" ; do

View File

@ -1,2 +0,0 @@
# Allow use of mitm proxy
--insecure

View File

@ -1,2 +0,0 @@
# Allow use of mitm proxy
check_certificate = off

View File

@ -16,10 +16,3 @@ services:
- ../node_modules/bats-assert:/mnt/node_modules/bats-assert
# the n script
- ../bin/n:/usr/local/bin/n
# override settings to allow insecure connection in case using mitm proxy
- ./config/.curlrc:/root/.curlrc
- ./config/.wgetrc:/root/.wgetrc
environment:
# pass through proxy settings to allow caching proxy
- http_proxy
- https_proxy

View File

@ -14,10 +14,3 @@ services:
build:
context: dockerfiles
dockerfile: Dockerfile-ubuntu-wget
archlinux-curl:
extends:
file: ./docker-base.yml
service: testbed
build:
context: dockerfiles
dockerfile: Dockerfile-archlinux-curl

View File

@ -1,3 +0,0 @@
FROM archlinux:latest
CMD ["/bin/bash"]

View File

@ -28,22 +28,6 @@ Run single test on a single system::
npx bats tests/install-contents.bats
docker-compose run ubuntu-curl bats /mnt/test/tests/install-contents.bats
## Proxy
To speed up running tests multiple times, you can optionally run a caching proxy for the node downloads. The curl settings are modified
to allow an insecure connection through the mitm proxy.
cd test
bin/proxy-build
bin/proxy-run
# follow the instructions for configuring environment variables for using proxy, then run tests
`node` versions added to proxy cache (and used in tests):
* v4.9.1
* lts
* latest
## Docker Tips
Using `docker-compose` in addition to `docker` for convenient mounting of `n` script and the tests into the container. Changes to the tests or to `n` itself are reflected immediately without needing to rebuild the containers.

View File

@ -1,16 +0,0 @@
#!/usr/bin/env bash
# These are the versions installed and hence cached by proxy-build.
# Run commands we want to cache downloads for.
# Get index into cache for lookups of expected versions. Uncompressed.
curl --location --fail https://nodejs.org/dist/index.tab &> /dev/null
curl --location --fail https://nodejs.org/download/nightly/index.tab &> /dev/null
# Using 4.9.1 as a well known old version (which is no longer getting updated so does not change)
n --download 4
n --download lts
n --download latest
n --download nightly/latest
N_NODE_MIRROR=https://npmmirror.com/mirrors/node n --download 6.11