-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from dherman/integration-tests
Basic integration tests
- Loading branch information
Showing
33 changed files
with
674 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
@@ -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 | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,6 @@ | |
members = [ | ||
"pkgs/cargo-messages" | ||
] | ||
exclude = [ | ||
"test/integration/sniff-bytes" | ||
] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
htpasswd | ||
storage | ||
proxy.log | ||
nohup.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
# This script is used by CI to start up the npm proxy. | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/bash | ||
|
||
# This script can be used for running the integration tests in local development. | ||
# It starts up the npm proxy and manages it with the pm2 process manager. | ||
|
||
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 |
Oops, something went wrong.