fix: make query on exceptions during timespan more inclusive #1286
Workflow file for this run
This file contains hidden or 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: JavaScript client tests | |
| env: | |
| RUST_VERSION: 1.89.0 | |
| RUST_BACKTRACE: 1 | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - master | |
| jobs: | |
| test: | |
| name: test | |
| runs-on: ${{matrix.os}} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-22.04, ubuntu-22.04-arm] | |
| node-version: [20] | |
| services: | |
| postgres: | |
| image: postgres:15.4-alpine | |
| env: | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_DB: nittei | |
| ports: | |
| - 5432:5432 | |
| env: | |
| # Needed for sqlx | |
| DATABASE_URL: postgresql://postgres:postgres@localhost/nittei | |
| NITTEI__HTTP_PORT: 5000 | |
| NITTEI__PG__DATABASE_URL: postgresql://postgres:postgres@localhost/nittei | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - uses: pnpm/action-setup@v4 | |
| # Setup Rust as we need to run the server | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: ${{ env.RUST_VERSION }} | |
| - name: Setup Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| - uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/bin/ | |
| ~/.cargo/registry/index/ | |
| ~/.cargo/registry/cache/ | |
| ~/.cargo/git/db/ | |
| target/ | |
| key: ${{ runner.os }}--${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Build server and run migrations | |
| run: | | |
| echo "Running migrations" | |
| cargo install sqlx-cli --no-default-features --features postgres || true | |
| (cd crates/infra && sqlx migrate run) | |
| echo "Building server" | |
| cargo build | |
| - name: Install JS modules | |
| run: | | |
| cd clients/javascript | |
| pnpm i | |
| - name: Check if generated types are up-to-date | |
| run: | | |
| # Copy the generated types to a temporary folder for comparison | |
| cd clients/javascript | |
| cp -r ./lib/gen_types ./lib/gen_types_copy | |
| cd ../.. | |
| bash ./scripts/generate_ts_types.sh | |
| # Compare the generated types with the copied ones | |
| cd clients/javascript | |
| diff -r ./lib/gen_types ./lib/gen_types_copy | |
| # Get the exit code of the diff command | |
| exit_code=$? | |
| if [ $exit_code -ne 0 ]; then | |
| echo "Generated types are not up-to-date" | |
| echo "Generate them with 'just generate-ts-types' and commit the changes" | |
| exit 1 | |
| fi | |
| # Remove the temporary folder | |
| rm -rf ./lib/gen_types_copy | |
| - name: Build JS | |
| run: | | |
| cd clients/javascript | |
| pnpm run build | |
| - name: Start server and run tests | |
| run: | | |
| echo "Starting server" | |
| ./target/debug/nittei &> output.log & | |
| echo "Started server in background" | |
| IS_READY=false | |
| # Wait for backend server to be ready | |
| RETRIES=20 | |
| PORT=${NITTEI__HTTP_PORT} | |
| until [ "$IS_READY" = true ] || [ $((RETRIES--)) -eq 0 ]; do | |
| if curl localhost:$PORT/api/v1/healthcheck >/dev/null 2>&1; then | |
| IS_READY=true | |
| break | |
| fi | |
| echo "Waiting for server to be ready" | |
| sleep 1 | |
| done | |
| if [ "$IS_READY" = false ]; then | |
| echo "Server did not start in time" | |
| exit 1 | |
| fi | |
| # Run tests | |
| cd clients/javascript | |
| pnpm run test | |
| - name: Run print output of server | |
| if: always() | |
| run: | | |
| cat output.log | |
| - name: Stop server | |
| if: always() | |
| run: | | |
| kill $(lsof -t -i:${NITTEI__HTTP_PORT}) || true | |
| echo "Stopped server" |