Skip to content

feat(test): integration tests for nut04 (#42) #170

feat(test): integration tests for nut04 (#42)

feat(test): integration tests for nut04 (#42) #170

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
workspaces: integration-tests -> ./integration-tests
- name: Integration tests
run: |-
cd integration-tests
touch .env
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 5 && source .env; done
cd ..
# Setup db
mix ecto.setup
# 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
# Wait until the mix is finished compiling
until curl http://127.0.0.1:4000 > /dev/null; do sleep 5; done;
cd integration-tests
cargo test
# Cleanup
cat ../pid | xargs kill
kill $BTCD_AND_LND_SERVERS_PID
env:
MIX_ENV: dev