Skip to content

Implementation of std in lending #226

Implementation of std in lending

Implementation of std in lending #226

Workflow file for this run

name: Tests
on:
push:
branches:
- main
paths-ignore:
- 'web/**'
pull_request:
paths-ignore:
- 'web/**'
workflow_call:
env:
CARGO_TERM_COLOR: always
SQLX_VERSION: 0.8.0
SQLX_FEATURES: "rustls,postgres"
SQLX_FEATURES_KEY: "rustls-postgres"
SIMPLEX_COMMIT: 1945d11b47fff8838c3e99c210133519a9522324
APP_USER: app
APP_USER_PWD: secret
APP_DB_NAME: lending-indexer
permissions:
contents: read
jobs:
test:
name: Build and test (matrix)
runs-on: ubuntu-latest
services:
postgres:
image: postgres:14
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: postgres
ports:
- 5432:5432
strategy:
fail-fast: false
matrix:
toolchain: ["1.91.0", "stable"]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust ${{ matrix.toolchain }}
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Cache sqlx-cli
uses: actions/cache@v4
with:
path: ${{ runner.temp }}/sqlx-cli-cache
key: sqlx-cli-${{ runner.os }}-${{ env.SQLX_VERSION }}-${{ env.SQLX_FEATURES_KEY }}-${{ matrix.toolchain }}
- name: Install sqlx-cli
run: |
SQLX_CLI_ROOT="$RUNNER_TEMP/sqlx-cli-cache"
if [ ! -f "$SQLX_CLI_ROOT/bin/sqlx" ]; then
cargo install sqlx-cli \
--root "$SQLX_CLI_ROOT" \
--version=${{ env.SQLX_VERSION }} \
--features ${{ env.SQLX_FEATURES }} \
--no-default-features \
--locked
fi
echo "$SQLX_CLI_ROOT/bin" >> $GITHUB_PATH
- name: Install simplex-cli via simplexup
shell: bash
run: |
set -euo pipefail
curl -fsSL --retry 5 --retry-all-errors --retry-delay 2 https://smplx.simplicity-lang.org | bash
BASE_DIR="${XDG_CONFIG_HOME:-$HOME}"
SIMPLEX_DIR="${SIMPLEX_DIR:-$BASE_DIR/.simplex}"
SIMPLEX_BIN_DIR="$SIMPLEX_DIR/bin"
"$SIMPLEX_BIN_DIR/simplexup" --commit "$SIMPLEX_COMMIT"
echo "$SIMPLEX_BIN_DIR" >> "$GITHUB_PATH"
"$SIMPLEX_BIN_DIR/simplex" --version
- name: Generate contract artifacts
shell: bash
run: |
cd crates/contracts
simplex build
test -f src/artifacts/mod.rs
- name: Create app user in Postgres
run: |
sudo apt-get install postgresql-client
# Create the application user
CREATE_QUERY="CREATE USER ${APP_USER} WITH PASSWORD '${APP_USER_PWD}';"
PGPASSWORD="password" psql -U "postgres" -h "localhost" -c "${CREATE_QUERY}"
# Grant create db privileges to the app user
GRANT_QUERY="ALTER USER ${APP_USER} CREATEDB;"
PGPASSWORD="password" psql -U "postgres" -h "localhost" -c "${GRANT_QUERY}"
- name: Migrate database
run: |
cd crates/indexer
SKIP_DOCKER=true ./scripts/init_db.sh
- name: Run indexer tests
env:
DATABASE_URL: postgres://${{ env.APP_USER }}:${{ env.APP_USER_PWD }}@localhost:5432/${{ env.APP_DB_NAME }}
run: cargo test -p lending-indexer
- name: Run simplex tests
shell: bash
run: |
cd crates/contracts
simplex test
- name: Check that queries are fresh
run: cargo sqlx prepare --workspace --check -- --all-targets