feat: add fuzzy search functionality, refactor word models and struct… #47
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
name: "Backend tests" | |
on: | |
push: | |
branches: | |
- "master" | |
- "dev" | |
workflow_dispatch: | |
jobs: | |
run-unit-tests: | |
runs-on: "self-hosted" | |
name: "Run doc and unit tests" | |
steps: | |
- name: "Set up required tools" | |
run: | | |
sudo apt-get update \ | |
&& sudo apt-get install -y --no-install-recommends build-essential libssl-dev pkg-config | |
- name: "Checkout repository" | |
uses: actions/checkout@v4.1.1 | |
- name: "Install stable Rust" | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: stable | |
- name: Cache | |
uses: Swatinem/rust-cache@v2 | |
- name: "Run unit tests" | |
# Excludes the end-to-end testing crate (tested separately). | |
# This one also doesn't execute doctests due to --all-targets. | |
run: cargo test --verbose --workspace --exclude kolomoni_test --all-features --all-targets | |
- name: "Run doctests" | |
# Excludes the end-to-end testing crate (tested separately). | |
run: cargo test --verbose --workspace --exclude kolomoni_test --all-features --doc | |
run-end-to-end-tests: | |
runs-on: "self-hosted" | |
name: "Run end-to-end tests" | |
steps: | |
- name: "Set up required tools" | |
run: | | |
sudo apt-get update \ | |
&& sudo apt-get install -y --no-install-recommends build-essential libssl-dev pkg-config | |
- name: "Checkout repository" | |
uses: actions/checkout@v4.1.1 | |
- name: "Install stable Rust" | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: stable | |
- name: Cache | |
uses: Swatinem/rust-cache@v2 | |
- name: "Initialize PostgreSQL database" | |
run: | | |
docker stop --time 30 kolomoni-e2e-test-database || true | |
docker rm --volumes kolomoni-e2e-test-database || true | |
docker run --name kolomoni-e2e-test-database \ | |
-p 127.0.0.1:5432:5432 \ | |
--env POSTGRES_PASSWORD=postgres --env POSTGRES_USER=postgres \ | |
--env POSTGRES_HOST_AUTH_METHOD=trust --env POSTGRES_DB=kolomoni \ | |
-v ./kolomoni_test/assets/postgres-initialization-script.sh:/docker-entrypoint-initdb.d/postgres-initialization-script.sh \ | |
--rm --detach postgres:16.2-alpine | |
- name: "Compile and start API server" | |
timeout-minutes: 60 | |
run: | | |
set -e | |
echo "Creating log directory." | |
mkdir -p logs | |
echo "Compiling and running server in the background." | |
nohup cargo run --verbose --release --features with_test_facilities \ | |
-- --configurationFilePath ./kolomoni_test/assets/configuration.TESTING.toml > logs/server.log 2>&1 & | |
SERVER_PID=$! | |
echo "Server compiling and starting with PID $SERVER_PID." | |
rm -f -- server.pid | |
echo $SERVER_PID > server.pid | |
echo "Waiting until ./logs/server.log exists..." | |
until [ -f ./logs/server.log ] | |
do | |
sleep 1 | |
done | |
echo "File ./logs/server.log exists, waiting until server is ready." | |
while true | |
do | |
if tail -n100 ./logs/server.log | grep -q "server initialized and running" | |
then | |
echo "Server is ready!" | |
break | |
fi | |
if ps -ef | grep "$SERVER_PID" | grep -v "grep" -q | |
then | |
: | |
else | |
echo "Server process exited without success." | |
exit 1 | |
fi | |
sleep 5 | |
done | |
- name: "Run end-to-end tests" | |
env: | |
TEST_API_SERVER_URL: "http://127.0.0.1:8866" | |
RUST_BACKTRACE: "1" | |
run: cd kolomoni_test && cargo test --verbose --test '*' -- --test-threads 1 | |
- name: "Stop API server" | |
if: ${{ always() }} | |
run: | | |
SERVER_PID=$(<server.pid) | |
echo "Killing API server with PID $SERVER_PID." | |
kill -s SIGTERM "$SERVER_PID" | |
echo "API server killed." | |
- name: "Output API server log" | |
if: ${{ always() }} | |
run: | | |
echo "-- SERVER LOG START --" | |
cat ./logs/server.log | |
echo "-- SERVER LOG END --" | |
- name: "Stop PostgreSQL database" | |
if: ${{ always() }} | |
run: | | |
echo "Stopping PostgreSQL database container." | |
docker stop --time 60 kolomoni-e2e-test-database | |
echo "PostgreSQL database container stopped." |