Add Github Actions for building and testing #3
Workflow file for this run
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: Basic build and test workflow | |
on: | |
push: | |
branches: [ "main", "dev" ] | |
pull_request: | |
branches: [ "main", "dev" ] | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
build_and_test: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:latest | |
env: | |
POSTGRES_DB: clementine | |
POSTGRES_USER: clementine | |
POSTGRES_PASSWORD: clementine | |
ports: | |
- 5432:5432 | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 50 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Download Bitcoin | |
run: wget https://bitcoin.org/bin/bitcoin-core-27.0/bitcoin-27.0-x86_64-linux-gnu.tar.gz | |
- name: Unpack Bitcoin | |
run: tar -xzvf bitcoin-27.0-x86_64-linux-gnu.tar.gz | |
- name: Start Bitcoind | |
run: bitcoin-27.0/bin/bitcoind -regtest -rpcuser=admin -rpcpassword=admin -rpcport=18443 -fallbackfee=0.00001 -wallet=admin -txindex=1 & | |
- name: Create wallet for Bitcoin regtest | |
run: bitcoin-27.0/bin/bitcoin-cli -regtest -rpcuser=admin -rpcpassword=admin -rpcport=18443 createwallet "admin" | |
- name: Create funds in Bitcoin regtest | |
run: bitcoin-27.0/bin/bitcoin-cli -regtest -rpcuser=admin -rpcpassword=admin -rpcport=18443 generatetoaddress 101 $(bitcoin-27.0/bin/bitcoin-cli -regtest -rpcuser=admin -rpcpassword=admin -rpcport=18443 getnewaddress) | |
- name: Build | |
run: RISC0_DEV_MODE=1 cargo build --verbose | |
- name: Create config overwrite file | |
run: | | |
echo tracing_debug = \"debug,bitcoincore_rpc=info,hyper=error\" > /home/runner/overwrite.toml | |
echo host = \"127.0.0.1\" >> /home/runner/overwrite.toml | |
echo port = 3000 >> /home/runner/overwrite.toml | |
echo secret_key = \"5555555555555555555555555555555555555555555555555555555555555555\" >> /home/runner/overwrite.toml | |
echo verifiers_public_keys = [ >> /home/runner/overwrite.toml | |
echo \"4f355bdcb7cc0af728ef3cceb9615d90684bb5b2ca5f859ab0f0b704075871aa\", >> /home/runner/overwrite.toml | |
echo \"466d7fcae563e5cb09a0d1870bb580344804617879a14949cf22285f1bae3f27\", >> /home/runner/overwrite.toml | |
echo \"3c72addb4fdf09af94f0c94d7fe92a386a7e70cf8a1d85916386bb2535c7b1b1\", >> /home/runner/overwrite.toml | |
echo \"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991\", >> /home/runner/overwrite.toml | |
echo \"9ac20335eb38768d2052be1dbbc3c8f6178407458e51e6b4ad22f1d91758895b\", >> /home/runner/overwrite.toml | |
echo ]\ >> /home/runner/overwrite.toml | |
echo db_file_path = \"database\" >> /home/runner/overwrite.toml | |
echo num_verifiers = 4 >> /home/runner/overwrite.toml | |
echo min_relay_fee = 305 >> /home/runner/overwrite.toml | |
echo user_takes_after = 200 >> /home/runner/overwrite.toml | |
echo confirmation_treshold = 1 >> /home/runner/overwrite.toml | |
echo network = \"regtest\" >> /home/runner/overwrite.toml | |
echo bitcoin_rpc_url = \"http://127.0.0.1:18443\" >> /home/runner/overwrite.toml | |
echo bitcoin_rpc_user = \"admin\" >> /home/runner/overwrite.toml | |
echo bitcoin_rpc_password = \"admin\" >> /home/runner/overwrite.toml | |
echo all_secret_keys = [ >> /home/runner/overwrite.toml | |
echo \"1111111111111111111111111111111111111111111111111111111111111111\", >> /home/runner/overwrite.toml | |
echo \"2222222222222222222222222222222222222222222222222222222222222222\", >> /home/runner/overwrite.toml | |
echo \"3333333333333333333333333333333333333333333333333333333333333333\", >> /home/runner/overwrite.toml | |
echo \"4444444444444444444444444444444444444444444444444444444444444444\", >> /home/runner/overwrite.toml | |
echo \"5555555555555555555555555555555555555555555555555555555555555555\", >> /home/runner/overwrite.toml | |
echo ] >> /home/runner/overwrite.toml | |
echo db_host = \"127.0.0.1\" >> /home/runner/overwrite.toml | |
echo db_port = 5432 >> /home/runner/overwrite.toml | |
echo db_user = \"clementine\" >> /home/runner/overwrite.toml | |
echo db_password = \"clementine\" >> /home/runner/overwrite.toml | |
echo db_name = \"clementine\" >> /home/runner/overwrite.toml | |
echo citrea_rpc_url = \"http://159.89.214.47/\" >> /home/runner/overwrite.toml | |
echo bridge_contract_address = \"3100000000000000000000000000000000000002\" >> /home/runner/overwrite.toml | |
- name: Run tests on Bitcoin regtest | |
run: RISC0_DEV_MODE=1 TEST_CONFIG=/home/runner/overwrite.toml cargo test --verbose --jobs 1 | |
- name: Run tests on mock RPC | |
run: RISC0_DEV_MODE=1 TEST_CONFIG=/home/runner/overwrite.toml cargo test --verbose --features mock_rpc |