Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic integration tests #11

Merged
merged 176 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from 175 commits
Commits
Show all changes
176 commits
Select commit Hold shift + click to select a range
83e9ef6
WIP: started putting together verdaccio proxy config + CI logic
dherman Sep 10, 2023
e30f290
bump versions before building
dherman Sep 10, 2023
c1d1779
verbose logs?
dherman Sep 10, 2023
36df2ff
--verbose not -vv
dherman Sep 10, 2023
6cb7a70
diagnostics
dherman Sep 10, 2023
1448f58
diagnostixxxxxxx
dherman Sep 10, 2023
a0cc0ce
moar diags
dherman Sep 10, 2023
888b985
diagnosticismness
dherman Sep 10, 2023
1a41db9
update lockfile
dherman Sep 10, 2023
f830a35
ok that's working, clean up some cruft and print out the dist/ directory
dherman Sep 10, 2023
34dbd06
start the proxy, determine the tarball to publish
dherman Sep 10, 2023
9e671ad
ok now we can start publishing packages to the proxy
dherman Sep 10, 2023
8b33f30
show the verdaccio log
dherman Sep 10, 2023
e32ee29
directly run verdaccio for any additional output it might produce
dherman Sep 10, 2023
8b31b70
try npm config set always-auth true
dherman Sep 10, 2023
195d6eb
set always-auth through the env
dherman Sep 10, 2023
0eb6db7
0.0.0.0?
dherman Sep 10, 2023
65459fb
dont use npx
dherman Sep 10, 2023
fdf0c30
127.0.0.1?
dherman Sep 10, 2023
c4300b5
sleep for a few seconds in case this is a race
dherman Sep 10, 2023
610ad8a
diagnosticification
dherman Sep 10, 2023
afc1320
more diagnostics
dherman Sep 10, 2023
5b262e8
more sleeps
dherman Sep 10, 2023
7410b72
more diagnostics
dherman Sep 10, 2023
3ca6437
guard with a test for existence
dherman Sep 10, 2023
90b5c90
explicitly listen on 127.0.0.1:4873
dherman Sep 10, 2023
7a0748a
now that that's working, comment out the waits and see if it's still …
dherman Sep 10, 2023
6e6d007
ok let's try sleep 10
dherman Sep 10, 2023
723c3dd
diagnostics
dherman Sep 10, 2023
b7c8c3a
diag
dherman Sep 10, 2023
6a84c65
more diags
dherman Sep 10, 2023
4ec935f
diagnostics
dherman Sep 10, 2023
b9f36b5
diagnostics
dherman Sep 10, 2023
228f9fd
more diagnostics
dherman Sep 10, 2023
e737020
path off-by-one
dherman Sep 10, 2023
29e2145
does.. the order of the npm publish arguments matter?
dherman Sep 10, 2023
dd498b0
is it sensitive to cwd???!?
dherman Sep 10, 2023
c2d0b34
relative path bug
dherman Sep 10, 2023
f3560a0
missing '/'
dherman Sep 10, 2023
cdb68d6
cleanup now that it's working
dherman Sep 10, 2023
ec637fc
let's try to be more precise about waiting for the verdaccio server t…
dherman Sep 10, 2023
9871719
use `tail -F` to wait for the file to exist
dherman Sep 10, 2023
9936597
add a timeout of 3m to the proxy server step
dherman Sep 10, 2023
19e6b22
can we avoid multiple adduser commands?
dherman Sep 10, 2023
61deae5
golf things down a bit
dherman Sep 10, 2023
5ae1914
try using npx again
dherman Sep 10, 2023
c857ffa
move proxy script into proxy.sh
dherman Sep 10, 2023
36b7c2f
move check-bundles lint into file
dherman Sep 10, 2023
0ade96b
pass ${{ env.PROXY }} correctly into proxy.sh as a command-line arg
dherman Sep 10, 2023
8fb5a82
add sniff-bytes integration test
dherman Sep 10, 2023
2ed0326
build sniff-bytes integration test
dherman Sep 10, 2023
8dd8d94
I guess cargo requires a patch number?
dherman Sep 10, 2023
b56b743
make it a workspace so it's excluded from the rest of the repo
dherman Sep 10, 2023
ddc8aea
exclude from the root to keep the integration test clean
dherman Sep 10, 2023
bd47ff2
publish the integration test to the proxy
dherman Sep 10, 2023
5f74424
again, 1.0.0 not 1.0
dherman Sep 10, 2023
0c02eee
diagnostics
dherman Sep 10, 2023
63cb9e9
authorize integration test packages in proxy
dherman Sep 11, 2023
afd0d65
add test-sniff-bytes integration test package
dherman Sep 11, 2023
134d406
add darwin-arm64 target so I can test locally
dherman Sep 11, 2023
f8cd0f4
add dependency on sniff-bytes to test-sniff-bytes
dherman Sep 11, 2023
a8fc5cf
load fixtures
dherman Sep 11, 2023
34304dd
print sniffBytes output
dherman Sep 11, 2023
1182e1e
debugging
dherman Sep 11, 2023
24505c0
print shasum
dherman Sep 11, 2023
02d6590
get the integrity checksum from the proxy
dherman Sep 12, 2023
e3ffc5d
integrity
dherman Sep 12, 2023
ecdab4d
integrrrrrity
dherman Sep 12, 2023
cb9bf94
diagnostics
dherman Sep 12, 2023
e1e8f99
use npm view
dherman Sep 12, 2023
2be8967
remove the lockfile -- let's see what `npm ci` does, otherwise we can…
dherman Sep 23, 2023
c9abaff
`npm i` instead of `npm ci`
dherman Sep 23, 2023
a44dac4
npm i needs to use the proxy registry
dherman Sep 23, 2023
8f35027
diagnostification
dherman Sep 23, 2023
4dffd12
path
dherman Sep 23, 2023
8497f78
see if explicitly adding the @babel/plugin-syntax-typescript devDepen…
dherman Sep 23, 2023
cdd36df
oops, that was in the wrong package.json
dherman Sep 23, 2023
a9cc5eb
add @babel/plugin-syntax-jsx now. heaven knows why this workaround is…
dherman Sep 23, 2023
e88f9f2
now @jest/source-map
dherman Sep 23, 2023
8c6aee6
and now "@types/stack-utils"
dherman Sep 23, 2023
969dbd5
next: @types/graceful-fs
dherman Sep 23, 2023
80caba9
@babel/plugin-syntax-top-level-await
dherman Sep 23, 2023
4d1830c
@babel/plugin-syntax-optional-chaining
dherman Sep 23, 2023
9c11699
@babel/plugin-syntax-optional-catch-binding
dherman Sep 23, 2023
43d1483
@babel/plugin-syntax-object-rest-spread
dherman Sep 23, 2023
b208f0d
@babel/plugin-syntax-numeric-separator
dherman Sep 23, 2023
2db7bfa
@babel/plugin-syntax-nullish-coalescing-operator
dherman Sep 23, 2023
4ee35c4
@babel/plugin-syntax-logical-assignment-operators
dherman Sep 23, 2023
22b0e4c
@babel/plugin-syntax-json-strings
dherman Sep 23, 2023
2425635
@babel/plugin-syntax-import-meta
dherman Sep 23, 2023
6880160
@babel/plugin-syntax-class-properties
dherman Sep 23, 2023
c2beff7
@babel/plugin-syntax-bigint
dherman Sep 23, 2023
106c11c
@babel/plugin-syntax-async-generators
dherman Sep 23, 2023
9187a05
@types/babel__traverse
dherman Sep 23, 2023
fc37d63
@types/babel__template
dherman Sep 23, 2023
046ef9f
@types/babel__generator
dherman Sep 23, 2023
c1470ea
@types/babel__core
dherman Sep 23, 2023
8e6aa65
@jest/test-sequencer
dherman Sep 23, 2023
6bab484
@istanbuljs/schema
dherman Sep 23, 2023
38a800c
@istanbuljs/load-nyc-config
dherman Sep 23, 2023
ae64358
@bcoe/v8-coverage
dherman Sep 23, 2023
70712fa
@jest/transform
dherman Sep 23, 2023
437d60c
@jest/reporters
dherman Sep 23, 2023
207c896
@jest/core
dherman Sep 23, 2023
47ffbf5
@jest/expect-utils
dherman Sep 23, 2023
e8a03ad
@types/yargs-parser
dherman Sep 23, 2023
2d5151b
@types/istanbul-lib-report
dherman Sep 23, 2023
e4dacfa
@sinonjs/commons
dherman Sep 23, 2023
0e48c55
@jridgewell/resolve-uri
dherman Sep 23, 2023
2fa56b2
@jridgewell/sourcemap-codec
dherman Sep 23, 2023
57ce8b5
@jridgewell/set-array
dherman Sep 23, 2023
3c37291
@sinclair/typebox
dherman Sep 23, 2023
d47e2d8
@types/yargs
dherman Sep 23, 2023
18fe3e7
@types/istanbul-reports
dherman Sep 23, 2023
8653bb6
@jest/schemas
dherman Sep 23, 2023
23e2e76
@types/istanbul-lib-coverage
dherman Sep 23, 2023
600a1e5
@sinonjs/fake-timers
dherman Sep 23, 2023
5092da6
@jest/fake-timers
dherman Sep 23, 2023
09ed408
@jest/expect
dherman Sep 23, 2023
f1f9083
@jest/environment
dherman Sep 23, 2023
68ab8b0
@types/node
dherman Sep 23, 2023
0e44ba4
@jest/types
dherman Sep 23, 2023
6419a05
@jest/test-result
dherman Sep 23, 2023
0ad63cc
@jest/console
dherman Sep 23, 2023
f9afb6f
@babel/helper-string-parser
dherman Sep 23, 2023
2a940af
@babel/helper-hoist-variables
dherman Sep 23, 2023
1f0814b
@babel/helper-function-name
dherman Sep 23, 2023
e67b337
does it help to put these in the config.yml??
dherman Sep 23, 2023
7118484
@babel/helper-plugin-utils
dherman Sep 23, 2023
bc27a38
@babel/helper-validator-identifier
dherman Sep 23, 2023
fa8e29f
@babel/helper-split-export-declaration
dherman Sep 23, 2023
aa5d9af
@babel/helper-simple-access
dherman Sep 23, 2023
cd6c50a
@babel/helper-module-imports
dherman Sep 23, 2023
465872f
@babel/helper-environment-visitor
dherman Sep 23, 2023
fdae525
@babel/helper-validator-option
dherman Sep 23, 2023
3c8794c
@babel/compat-data
dherman Sep 23, 2023
5f6dd8f
@babel/highlight
dherman Sep 23, 2023
5b8a7cf
@jridgewell/trace-mapping
dherman Sep 23, 2023
5aa925f
@jridgewell/gen-mapping
dherman Sep 23, 2023
10f8df5
@babel/types
dherman Sep 23, 2023
73611bf
@babel/traverse
dherman Sep 23, 2023
153e809
@babel/template
dherman Sep 23, 2023
e11b979
delete the extraneous configs
dherman Sep 23, 2023
81f8947
@babel/parser
dherman Sep 23, 2023
e5b387d
@babel/helpers
dherman Sep 24, 2023
ce8d021
@babel/helper-module-transforms
dherman Sep 24, 2023
7e54cd9
@babel/helper-compilation-targets
dherman Sep 24, 2023
501582f
@babel/generator
dherman Sep 24, 2023
1b96faa
@babel/code-frame
dherman Sep 24, 2023
56e81db
@ampproject/remapping
dherman Sep 24, 2023
4455404
would `publish: $authenticated` for the npm uplink help?
dherman Sep 24, 2023
039f84a
try extending the timeout
dherman Sep 24, 2023
8493565
try npm i twice in a row??
dherman Sep 24, 2023
ce2da4c
try eagerly installing @types/yargs-parser
dherman Sep 24, 2023
599d1be
just stabbing around randomly here
dherman Sep 24, 2023
f4fcf51
try forcing pre-fetching with `npm cache add`
dherman Sep 24, 2023
d8d0dbe
gitignore lockfile in sniff-bytes
Oct 2, 2023
cf7dbc8
`npm i` instead of `npm ci` for sniff-bytes now that there's no lockfile
Oct 2, 2023
90d485d
let's try disabling the cache, and see if it's bug https://github.com…
Oct 13, 2023
51e7ed5
try verdaccio 6 pre-release to see if the bug is fixed
Oct 20, 2023
0d5c28d
Stop using uplinks and don't worry about testing cargo-messages in th…
Oct 27, 2023
7af387b
now that sniff-bytes is scoped, explicitly tell `neon dist` the unsco…
Oct 27, 2023
9fd4ba9
remove debugging line that's irrelevant now
Oct 27, 2023
d71626b
@sniff-bytes/* and @neon-rs/* should load from verdaccio as well
Oct 27, 2023
b7c2d08
workflow cleanup
Oct 29, 2023
4a6ef3a
two integration tests
Oct 29, 2023
621f0ec
test fix: was accessing the wrong property name
Oct 29, 2023
3efe67b
try moving most of the proxy setup into a script that also works for …
Oct 30, 2023
da5614f
add back authentication temporarily
Oct 30, 2023
f192aa0
CIPROXY not PROXY
Oct 30, 2023
01a1fd3
fix authentication in the script
Oct 30, 2023
78d43c2
get rid of all the duplicated configuration values in the CI workflow…
Oct 30, 2023
bd1ba98
remove diagnostics
Oct 30, 2023
1581c1a
remove more diagnostics
Oct 30, 2023
62122e6
remove spurious comment
Oct 30, 2023
9419c14
Comment the scripts to describe their purpose.
Oct 30, 2023
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
67 changes: 47 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: CI

env:
NODE_VERSION: 18.x

on:
push:
# Prevent duplicate runs of this workflow on our own internal PRs.
Expand All @@ -23,23 +26,47 @@ jobs:
fetch-depth: 0
- name: Check Bundles
shell: bash
run: |
echo "Checking that all bundled tools are up to date..."
dirty_workspaces=()
for input_workspace in `find src -type d -mindepth 1 -maxdepth 1 -not -name node_modules` ; do
output_workspace=$(echo $input_workspace | sed -e 's/^src/pkgs/')
input_mtime=$(git log -1 --format=%ct $input_workspace)
output_mtime=$(git log -1 --format=%ct $output_workspace)
if [[ $input_mtime -gt $output_mtime ]] ; then
echo "❌ $input_workspace has changed since $output_workspace was last generated"
dirty_workspaces+=($input_workspace)
fi
done
if [[ ${#dirty_workspaces[@]} -gt 0 ]] ; then
echo
echo '💡 Re-run `npm run bundle` on the following workspaces before committing:'
for workspace in ${dirty_workspaces[*]} ; do
echo " • $workspace"
done
exit 1
fi
run: ./test/lint/check-bundles.sh
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved the listing logic into a separate shell script file.


integration:
name: Integration Tests
needs: [bundles]
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Dependencies
shell: bash
run: npm ci --verbose
- name: Build
uses: neon-actions/[email protected]
with:
working-directory: ./pkgs/cargo-messages
target: linux-x64-gnu
node-version: ${{ env.NODE_VERSION }}
use-cross: false
npm-publish: false
github-release: false
- name: Start npm Proxy
shell: bash
working-directory: ./test/integration/proxy
timeout-minutes: 3
run: ./ci-proxy.sh
- name: Publish to npm Proxy
shell: bash
working-directory: ./test/integration/proxy
timeout-minutes: 3
run: ./publish.sh
# Since package integrity checksums may vary depending on what versions
# are available in the proxy registry, we don't put the lockfile for this
# test in source control. This means we have to use `npm i`, not `npm ci`.
- name: Setup test-sniff-bytes Integration Test
shell: bash
working-directory: test/integration/test-sniff-bytes
run: npm i || (cat ../proxy/proxy.log && exit 1)
- name: Run test-sniff-bytes Integration Test
shell: bash
working-directory: test/integration/test-sniff-bytes
run: npm test
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
members = [
"pkgs/cargo-messages"
]
exclude = [
"test/integration/sniff-bytes"
Copy link
Collaborator Author

@dherman dherman Oct 30, 2023

Choose a reason for hiding this comment

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

This is needed so the root cargo workspace doesn't get confused by the Rust code inside the integration tests.

]
147 changes: 28 additions & 119 deletions pkgs/package-lock.json

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

4 changes: 4 additions & 0 deletions test/integration/proxy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
htpasswd
storage
proxy.log
nohup.out
11 changes: 11 additions & 0 deletions test/integration/proxy/ci-proxy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

CIPROXY=http://127.0.0.1:4873

# Boot the server in a background process.
nohup npx verdaccio --config ./config.yml --listen $CIPROXY &

# Wait for the server to begin listening for connections
( tail -F -n10 proxy.log & ) | fgrep -q $CIPROXY

cat proxy.log
15 changes: 15 additions & 0 deletions test/integration/proxy/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
storage: ./storage
auth:
htpasswd:
file: ./htpasswd
packages:
'@neon-rs/*':
access: $all
publish: $all
'@sniff-bytes/*':
access: $all
publish: $all
'@neon-integration-tests/*':
access: $all
publish: $all
log: { type: file, path: proxy.log, level: info }
49 changes: 49 additions & 0 deletions test/integration/proxy/local-proxy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

cd $(dirname $0)/../../..
ROOT_DIR=$(pwd)
PROXY_DIR=${ROOT_DIR}/test/integration/proxy
LOCAL_PROXY=http://127.0.0.1:4873

cd ${PROXY_DIR}

if ! which pm2 >/dev/null ; then
echo -e 'usage: local-proxy.sh'
echo -e
echo -e 'error: The required tool `pm2` was not found. Please install it first by running:'
echo -e
echo -e ' $ npm i -g pm2'
echo -e
exit 1
fi

if pm2 describe neon-test-proxy >/dev/null 2>&1 ; then
echo -e 'usage: local-proxy.sh'
echo -e
echo -e 'error: There is already a pm2 app named `neon-test-proxy`. Please remove it first by running:'
echo -e
echo -e ' $ pm2 stop neon-test-proxy'
echo -e ' $ pm2 delete neon-test-proxy'
echo -e
exit 1
fi

rm -rf ./storage ./proxy.log

# Boot the server in a background process.
pm2 start verdaccio --name neon-test-proxy --no-autorestart -- --config ./config.yml --listen ${LOCAL_PROXY}

# Wait for the server to begin listening for connections
( tail -F -n10 ./proxy.log & ) | fgrep -q "${LOCAL_PROXY}"

cat ./proxy.log

echo
echo 'Proxy `neon-test-proxy` started. You can now control it using pm2:'
echo
echo ' # Stop the proxy server:'
echo ' $ pm2 stop neon-test-proxy'
echo
echo ' # Restart the proxy server:'
echo ' $ pm2 restart neon-test-proxy'
echo
Loading
Loading