Feature/1018 tests #82
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: Rust CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install Rust toolchain | |
uses: dsherret/rust-toolchain-file@v1 | |
- name: Install Dependencies and Set up PostgreSQL | |
run: | | |
sudo apt-get update -y && sudo apt-get install -y libssl-dev ca-certificates libudev-dev libusb-1.0-0-dev pkg-config libudev-dev build-essential | |
sudo service postgresql start | |
sudo su - postgres -c " | |
psql -c \"CREATE DATABASE devhub_cache_api_rs\" | |
psql -c \"CREATE ROLE devhub_cache_api_rs WITH LOGIN PASSWORD 'password';\" | |
psql -c \"ALTER ROLE devhub_cache_api_rs CREATEDB;\" | |
psql -c \"GRANT ALL PRIVILEGES ON DATABASE devhub_cache_api_rs TO devhub_cache_api_rs;\" | |
" | |
- name: Install SQlx and cargo audit | |
run: cargo install sqlx-cli cargo-audit | |
- name: Create database and Run migrations | |
run: | | |
cargo sqlx database create | |
cargo sqlx migrate run | |
env: | |
DATABASE_URL: postgres://devhub_cache_api_rs:password@127.0.0.1:5432/devhub_cache_api_rs | |
- name: Build and test the project | |
run: | | |
cargo build --verbose | |
cargo test --verbose | |
env: | |
SQLX_OFFLINE: true | |
CONTRACT: devhub.near | |
DATABASE_URL: postgres://devhub_cache_api_rs:password@127.0.0.1:5432/devhub_cache_api_rs | |
NEARBLOCKS_API_KEY: ${{ secrets.NEARBLOCKS_API_KEY }} | |
ENV: GH_ACTION | |
- name: Run clippy and audit | |
run: | |
cargo clippy -- -D warnings | |
# cargo audit |