diff --git a/.github/workflows/basic.yml b/.github/workflows/basic.yml new file mode 100644 index 00000000..3656d3cc --- /dev/null +++ b/.github/workflows/basic.yml @@ -0,0 +1,103 @@ +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: + name: Compile and test + + runs-on: ubicloud-standard-4 + + 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 a wallet in 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: | + cat << EOF > /home/runner/overwrite.toml + tracing_debug = \"debug,bitcoincore_rpc=info,hyper=error\" > /home/runner/overwrite.toml + host = \"127.0.0.1\" >> /home/runner/overwrite.toml + port = 3000 >> /home/runner/overwrite.toml + secret_key = \"5555555555555555555555555555555555555555555555555555555555555555\" >> /home/runner/overwrite.toml + verifiers_public_keys = [ >> /home/runner/overwrite.toml + \"4f355bdcb7cc0af728ef3cceb9615d90684bb5b2ca5f859ab0f0b704075871aa\", >> /home/runner/overwrite.toml + \"466d7fcae563e5cb09a0d1870bb580344804617879a14949cf22285f1bae3f27\", >> /home/runner/overwrite.toml + \"3c72addb4fdf09af94f0c94d7fe92a386a7e70cf8a1d85916386bb2535c7b1b1\", >> /home/runner/overwrite.toml + \"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991\", >> /home/runner/overwrite.toml + \"9ac20335eb38768d2052be1dbbc3c8f6178407458e51e6b4ad22f1d91758895b\", >> /home/runner/overwrite.toml + ]\ >> /home/runner/overwrite.toml + db_file_path = \"database\" >> /home/runner/overwrite.toml + num_verifiers = 4 >> /home/runner/overwrite.toml + min_relay_fee = 305 >> /home/runner/overwrite.toml + user_takes_after = 200 >> /home/runner/overwrite.toml + confirmation_treshold = 1 >> /home/runner/overwrite.toml + network = \"regtest\" >> /home/runner/overwrite.toml + bitcoin_rpc_url = \"http://127.0.0.1:18443\" >> /home/runner/overwrite.toml + bitcoin_rpc_user = \"admin\" >> /home/runner/overwrite.toml + bitcoin_rpc_password = \"admin\" >> /home/runner/overwrite.toml + all_secret_keys = [ >> /home/runner/overwrite.toml + \"1111111111111111111111111111111111111111111111111111111111111111\", >> /home/runner/overwrite.toml + \"2222222222222222222222222222222222222222222222222222222222222222\", >> /home/runner/overwrite.toml + \"3333333333333333333333333333333333333333333333333333333333333333\", >> /home/runner/overwrite.toml + \"4444444444444444444444444444444444444444444444444444444444444444\", >> /home/runner/overwrite.toml + \"5555555555555555555555555555555555555555555555555555555555555555\", >> /home/runner/overwrite.toml + ] >> /home/runner/overwrite.toml + db_host = \"127.0.0.1\" >> /home/runner/overwrite.toml + db_port = 5432 >> /home/runner/overwrite.toml + db_user = \"clementine\" >> /home/runner/overwrite.toml + db_password = \"clementine\" >> /home/runner/overwrite.toml + db_name = \"clementine\" >> /home/runner/overwrite.toml + citrea_rpc_url = \"http://159.89.214.47/\" >> /home/runner/overwrite.toml + bridge_contract_address = \"3100000000000000000000000000000000000002\" >> /home/runner/overwrite.toml + EOF + + - 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