Skip to content

test: add binary to run btcd and lnd #148

test: add binary to run btcd and lnd

test: add binary to run btcd and lnd #148

Workflow file for this run

name: Continuous Integration
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
name: Build and test
runs-on: ubuntu-latest
services:
postgres:
image: postgres:13
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: "1.17.2"
otp-version: "26"
- name: Restore dependencies cache
uses: actions/cache@v3
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-
- name: Install dependencies
run: mix deps.get
- name: Run tests
run: mix test
env:
MIX_ENV: test
- name: Run test coverage
run: mix coveralls.json
env:
MIX_ENV: test
- name: Upload coverage report
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: cover/excoveralls.json
- name: Check formatting
run: mix format --check-formatted
- name: Run Credo
run: mix credo --ignore todo,aliasusage
- name: Check for security vulnerabilities
run: mix sobelow --config
- name: Install rust
uses: Swatinem/rust-cache@v2
with:
shared-key: "cache"
save-if: false
- name: Setup db
run: mix ecto.setup
- name: Integration tests
run: |-
cd integration-tests
cargo run &
BTCD_AND_LND_SERVERS_PID=$!
# Wait until the nodes are running by checking if the the env var are exported
while [[ -z "${LND_URL}" ]] do sleep 1 && source .env; done
source .env
cd ..
# mix doesn't behave when run in background, so we use `erlang -detached` instead
# but the `$!` thing won't work coz the app is run in another thread,
# so we write the actual pid in a file and later read it to kill it
elixir --erl "-detached" -e "File.write! 'pid', :os.getpid" -S mix phx.server
cd integration-tests
cargo test
cat ../pid | xargs kill
kill $BTCD_AND_LND_SERVERS_PID