Fix syncing when network latency is present #4
6 changed files with 13 additions and 11 deletions
Add scritps folder
commit
993515ea12
6
.github/workflows/e2e.yml
vendored
6
.github/workflows/e2e.yml
vendored
|
|
@ -32,7 +32,5 @@ jobs:
|
||||||
- name: E2E tests
|
- name: E2E tests
|
||||||
run: |
|
run: |
|
||||||
UST_BACKTRACE=1 cargo run -p sync_server &
|
UST_BACKTRACE=1 cargo run -p sync_server &
|
||||||
cd ../frontend
|
cd ..
|
||||||
|
scripts/e2e.sh 32
|
||||||
npm run build
|
|
||||||
test-client/run.sh 32
|
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,6 @@
|
||||||
## Set up Rust
|
## Set up Rust
|
||||||
|
|
||||||
- Install [`rustup`](https://rustup.rs): `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`
|
- Install [`rustup`](https://rustup.rs): `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`
|
||||||
- `sudo apt install llvm -y`
|
|
||||||
- `rustup component add llvm-tools-preview`
|
|
||||||
- `cargo install cargo-generate cargo-fuzz cargo-insta rustfilt cargo-binutils`
|
|
||||||
- Install [`wasm-pack`](https://rustwasm.github.io/wasm-pack/installer): `curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh`
|
- Install [`wasm-pack`](https://rustwasm.github.io/wasm-pack/installer): `curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh`
|
||||||
- `cargo install cargo-insta sqlx-cli cargo-edit`
|
- `cargo install cargo-insta sqlx-cli cargo-edit`
|
||||||
|
|
||||||
|
|
@ -33,8 +30,7 @@
|
||||||
## Update HTTP API TS bindings
|
## Update HTTP API TS bindings
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
npm install -g openapi-typescript
|
./update-api-types.sh
|
||||||
openapi-typescript http://localhost:3030/api.json --output frontend/sync-client/src/services/types.ts
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
|
||||||
52
scripts/bump-version.sh
Executable file
52
scripts/bump-version.sh
Executable file
|
|
@ -0,0 +1,52 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [[ -z $1 ]]; then
|
||||||
|
echo "Usage: $0 {patch|minor|major}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $1 =~ ^(patch|minor|major)$ ]]; then
|
||||||
|
echo "Creating a new '$1' version"
|
||||||
|
else
|
||||||
|
echo "Invalid argument: $1"
|
||||||
|
echo "Usage: $0 {patch|minor|major}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n $(git status --porcelain) ]]; then
|
||||||
|
echo "Your working directory is not clean. Please commit or stash your changes before proceeding."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Your working directory is clean."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Bumping backend versions"
|
||||||
|
cd backend
|
||||||
|
cargo set-version --bump patch
|
||||||
|
|
||||||
|
echo "Bumping frontend versions"
|
||||||
|
cd ../plugin
|
||||||
|
npm version patch
|
||||||
|
|
||||||
|
echo "Updating frontend dependencies to match the new backend versions"
|
||||||
|
cd ../backend/sync_lib
|
||||||
|
wasm-pack build --target web --features console_error_panic_hook
|
||||||
|
|
||||||
|
cd ../../plugin
|
||||||
|
npm install
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
cp plugin/manifest.json manifest.json # for BRAT, otherwise it wouldn't update
|
||||||
|
|
||||||
|
# Commit and tag
|
||||||
|
git add .
|
||||||
|
TAG=$(node -p "require('./plugin/package.json').version")
|
||||||
|
git commit -m "Bump versions to $TAG"
|
||||||
|
|
||||||
|
git push
|
||||||
|
echo "Tagging $TAG"
|
||||||
|
git tag -a $TAG -m "Release $TAG"
|
||||||
|
git push origin $TAG
|
||||||
|
echo "Done"
|
||||||
4
scripts/clean-up.sh
Executable file
4
scripts/clean-up.sh
Executable file
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
rm -rf backend/databases
|
||||||
|
rm -rf frontend/test-client/logs
|
||||||
79
scripts/e2e.sh
Executable file
79
scripts/e2e.sh
Executable file
|
|
@ -0,0 +1,79 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
# Check if the argument is provided
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
echo "Usage: $0 <number_of_processes>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get the number of processes from the first argument
|
||||||
|
process_count=$1
|
||||||
|
|
||||||
|
cd frontend
|
||||||
|
npm run build
|
||||||
|
|
||||||
|
mkdir -p logs
|
||||||
|
|
||||||
|
pids=()
|
||||||
|
for i in $(seq 1 $process_count); do
|
||||||
|
node test-client/dist/cli.js > "logs/log_${i}.log" 2>&1 &
|
||||||
|
pids+=($!)
|
||||||
|
done
|
||||||
|
|
||||||
|
cd -
|
||||||
|
|
||||||
|
print_failed_log() {
|
||||||
|
for i in $(seq 1 $process_count); do
|
||||||
|
if [ -n "${pids[$i-1]}" ] && ! kill -0 ${pids[$i-1]} 2>/dev/null; then
|
||||||
|
# Get the exit code of the process
|
||||||
|
wait ${pids[$i-1]}
|
||||||
|
exit_code=$?
|
||||||
|
|
||||||
|
# Only consider non-zero exit codes as failures
|
||||||
|
if [ $exit_code -ne 0 ]; then
|
||||||
|
echo "Process ${pids[$i-1]} failed with exit code $exit_code. Log file: $(pwd)/logs/log_${i}.log"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
echo "Process ${pids[$i-1]} completed successfully with exit code 0"
|
||||||
|
# Mark this PID as processed by setting it to empty
|
||||||
|
pids[$i-1]=""
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "Monitoring $process_count processes"
|
||||||
|
|
||||||
|
# Monitor processes
|
||||||
|
while true; do
|
||||||
|
if print_failed_log; then
|
||||||
|
# Kill remaining processes
|
||||||
|
for pid in "${pids[@]}"; do
|
||||||
|
if [ -n "$pid" ]; then
|
||||||
|
kill $pid 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if all processes have completed
|
||||||
|
all_done=true
|
||||||
|
for pid in "${pids[@]}"; do
|
||||||
|
if [ -n "$pid" ] && kill -0 $pid 2>/dev/null; then
|
||||||
|
all_done=false
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if $all_done; then
|
||||||
|
echo "All processes completed successfully"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
sleep 0.2
|
||||||
|
done
|
||||||
|
|
||||||
4
scripts/update-api-types.sh
Executable file
4
scripts/update-api-types.sh
Executable file
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
npm install -g openapi-typescript
|
||||||
|
openapi-typescript http://localhost:3030/api.json --output frontend/sync-client/src/services/types.ts
|
||||||
Loading…
Reference in a new issue