Files
pubky-core/.github/workflows/pr-check.yml
Severin Alexander Bühler a485d8c2f4 feat(client): Set Relays in the JS Client Config (#139)
* added js pubky client constructor config

* fixed bugs

* fmt and cargotoml

* moved wasm constructor order

* removed pubky-common reexport of client
2025-05-23 18:32:37 +03:00

139 lines
3.7 KiB
YAML

name: PR Check
on:
pull_request:
push:
branches: [main]
jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: rustfmt
override: true
- name: Check formatting
run: cargo fmt --check
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: clippy
override: true
- name: Cache
uses: Swatinem/rust-cache@v2
- name: Lint with Clippy
run: cargo clippy --workspace --all-features -- -D warnings -A clippy::needless_lifetimes
test:
strategy:
matrix:
crate:
[pubky, pubky-common, pubky-homeserver, pubky-testnet, http-relay, pkarr-republisher, e2e]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Install Nextest
uses: taiki-e/install-action@nextest
- name: Cache
uses: Swatinem/rust-cache@v2
- name: Run doctests and nextest
run: |
set -e
# nextest does not support doctests yet.
cargo test --doc -p ${{ matrix.crate }} --all-features
if cargo nextest run \
-p ${{ matrix.crate }} \
--all-features \
--test-threads num-cpus \
--retries 2 \
--no-fail-fast \
--verbose; then
echo "Tests passed for ${{ matrix.crate }}"
else
if [ $? -eq 4 ]; then
echo "No tests found for ${{ matrix.crate }}"
exit 0
else
echo "Tests failed for ${{ matrix.crate }}"
exit 1
fi
fi
wasm-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: wasm32-unknown-unknown
override: true
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Cache
uses: Swatinem/rust-cache@v2
- name: Build WASM
working-directory: pubky-client/pkg
run: |
npm install
npm run build
- name: Run the testnet
working-directory: pubky-client/pkg
run: npm run testnet > testnet.log 2>&1 &
- name: Wait for testnet homeserver
run: |
timeout=180
count=0
until nc -zv 127.0.0.1 6288; do
if [ $count -ge $timeout ]; then
echo "Timeout: Testnet homeserver did not start within 3 minutes."
exit 1
fi
echo "Waiting for testnet homeserver to be ready... ($count/$timeout)"
sleep 1
count=$((count + 1))
done
echo "Testnet homeserver is ready."
- name: Run Tests (only node-js)
working-directory: pubky-client/pkg
# runing only `test-nodjs` and not browser because of weird `exit` behavior
run: npm run test-nodejs
- name: Show testnet logs if tests fail
working-directory: pubky-client/pkg
if: failure()
run: cat testnet.log