Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workflow improvements #251

Merged
merged 7 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
232 changes: 232 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
name: Build And Test

on: [push]

env:
CARGO_TERM_COLOR: always
CARGO_TERM_VERBOSE: true
CARGOFLAGS: --workspace --all-targets
RUST_LOG: trace

jobs:
debug_mode_build:
name: Compile code in debug mode
runs-on: ubicloud-standard-4

steps:
- uses: actions/checkout@v4

- name: Compile in debug mode
run: cargo build $CARGOFLAGS

- name: Save build artifacts
uses: actions/cache/save@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-debug-${{ hashFiles('**/Cargo.lock') }}

release_mode_build:
name: Compile code in release mode
runs-on: ubicloud-standard-4

steps:
- uses: actions/checkout@v4

- name: Compile in release mode
run: cargo build $CARGOFLAGS --release

- name: Save build artifacts
uses: actions/cache/save@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}

debug_mode_test:
name: Test code in debug mode
runs-on: ubicloud-standard-4
needs: debug_mode_build

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
ekrembal marked this conversation as resolved.
Show resolved Hide resolved

steps:
- uses: actions/checkout@v4

- name: Restore cached build artifacts
uses: actions/cache/restore@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-debug-${{ 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: Create config overwrite file
run: |
cat << EOF > /home/runner/overwrite.toml
tracing_debug = "debug,bitcoincore_rpc=info,hyper=error"
host = "127.0.0.1"
port = 3000
secret_key = "5555555555555555555555555555555555555555555555555555555555555555"
verifiers_public_keys = [
"4f355bdcb7cc0af728ef3cceb9615d90684bb5b2ca5f859ab0f0b704075871aa",
"466d7fcae563e5cb09a0d1870bb580344804617879a14949cf22285f1bae3f27",
"3c72addb4fdf09af94f0c94d7fe92a386a7e70cf8a1d85916386bb2535c7b1b1",
"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991",
"9ac20335eb38768d2052be1dbbc3c8f6178407458e51e6b4ad22f1d91758895b",
]
db_file_path = "database"
num_verifiers = 4
min_relay_fee = 305
user_takes_after = 200
confirmation_treshold = 1
network = "regtest"
bitcoin_rpc_url = "http://127.0.0.1:18443"
bitcoin_rpc_user = "admin"
bitcoin_rpc_password = "admin"
all_secret_keys = [
"1111111111111111111111111111111111111111111111111111111111111111",
"2222222222222222222222222222222222222222222222222222222222222222",
"3333333333333333333333333333333333333333333333333333333333333333",
"4444444444444444444444444444444444444444444444444444444444444444",
"5555555555555555555555555555555555555555555555555555555555555555",
]
db_host = "127.0.0.1"
db_port = 5432
db_user = "clementine"
db_password = "clementine"
db_name = "clementine"
citrea_rpc_url = "http://159.89.214.47/"
bridge_contract_address = "3100000000000000000000000000000000000002"
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

release_mode_test:
name: Test code in release mode
runs-on: ubicloud-standard-4
needs: release_mode_build

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

- name: Restore cached build artifacts
uses: actions/cache/restore@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-release-${{ 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: Create config overwrite file
run: |
cat << EOF > /home/runner/overwrite.toml
tracing_debug = "debug,bitcoincore_rpc=info,hyper=error"
host = "127.0.0.1"
port = 3000
secret_key = "5555555555555555555555555555555555555555555555555555555555555555"
verifiers_public_keys = [
"4f355bdcb7cc0af728ef3cceb9615d90684bb5b2ca5f859ab0f0b704075871aa",
"466d7fcae563e5cb09a0d1870bb580344804617879a14949cf22285f1bae3f27",
"3c72addb4fdf09af94f0c94d7fe92a386a7e70cf8a1d85916386bb2535c7b1b1",
"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991",
"9ac20335eb38768d2052be1dbbc3c8f6178407458e51e6b4ad22f1d91758895b",
]
db_file_path = "database"
num_verifiers = 4
min_relay_fee = 305
user_takes_after = 200
confirmation_treshold = 1
network = "regtest"
bitcoin_rpc_url = "http://127.0.0.1:18443"
bitcoin_rpc_user = "admin"
bitcoin_rpc_password = "admin"
all_secret_keys = [
"1111111111111111111111111111111111111111111111111111111111111111",
"2222222222222222222222222222222222222222222222222222222222222222",
"3333333333333333333333333333333333333333333333333333333333333333",
"4444444444444444444444444444444444444444444444444444444444444444",
"5555555555555555555555555555555555555555555555555555555555555555",
]
db_host = "127.0.0.1"
db_port = 5432
db_user = "clementine"
db_password = "clementine"
db_name = "clementine"
citrea_rpc_url = "http://159.89.214.47/"
bridge_contract_address = "3100000000000000000000000000000000000002"
EOF

- name: Run tests on Bitcoin regtest with release build
run: RISC0_DEV_MODE=1 TEST_CONFIG=/home/runner/overwrite.toml cargo test --verbose --jobs 1 --release
- name: Run tests on mock RPC with release build
run: RISC0_DEV_MODE=1 TEST_CONFIG=/home/runner/overwrite.toml cargo test --verbose --features mock_rpc --release
2 changes: 1 addition & 1 deletion .github/workflows/code_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Run Cargo clippy
run: cargo clippy --no-deps -- -Dwarnings
run: cargo clippy --no-deps --all-targets -- -Dwarnings
Loading