Skip to content

Merge pull request #44 from Donate4Fun/hotfix-a #179

Merge pull request #44 from Donate4Fun/hotfix-a

Merge pull request #44 from Donate4Fun/hotfix-a #179

Workflow file for this run

name: Test Backend
on: [push, pull_request]
env:
lnd_version: "v0.15.5-beta"
bitcoin_version: "22.0"
DEBIAN_FRONTEND: noninteractive
# Set empty to regenerate caches regardless of test results
run_test: 1
jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- run: apt-get update
if: ${{ env.ACT }}
- name: Load cached lncli
id: cached-lncli
uses: actions/cache@v3
with:
path: /usr/local/bin/lncli
key: lncli-${{ runner.os }}-${{ env.lnd_version }}
- if: steps.cached-lncli.outputs.cache-hit != 'true'
name: install-lncli
run: |
wget https://github.com/lightningnetwork/lnd/releases/download/${lnd_version}/lnd-linux-amd64-${lnd_version}.tar.gz -O - | tar -zxf - -C /usr/local/bin lnd-linux-amd64-${lnd_version}/lncli --strip-components 1
- name: Load cached bitcoin-cli
id: cached-bitcoin-cli
uses: actions/cache@v3
with:
path: /usr/local/bin/bitcoin-cli
key: bitcoin-cli-${{ runner.os }}-${{ env.bitcoin_version }}
- name: install-bitcoin-cli
if: steps.cached-bitcoin-cli.outputs.cache-hit != 'true'
run: |
wget https://bitcoin.org/bin/bitcoin-core-${bitcoin_version}/bitcoin-${bitcoin_version}-x86_64-linux-gnu.tar.gz -O - | tar -zxf - -C /usr/local/bin bitcoin-${bitcoin_version}/bin/bitcoin-cli --strip-components 2
- name: sshd
# This is for debug only. Use `ssh root@localhost -p 12345` to connect
# FIXME: use https://github.com/marketplace/actions/debugging-with-ssh instead?
if: false
run: |
apt-get install -y openssh-server
mkdir -p /run/sshd
ssh-keygen -A
passwd -d root
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config
sed -i 's/#PermitEmptyPasswords no/PermitEmptyPasswords yes/g' /etc/ssh/sshd_config
env | sed -r 's/=(.*)$/="\1"/' >> /root/.ssh/environment
/usr/sbin/sshd -p 12345 -D -o ListenAddress=0.0.0.0
- uses: awalsh128/cache-apt-pkgs-action@9b3b2b590c20bc969b78d74ec349254d1f24ee21
with:
version: 1.0
execute_install_scripts: true
packages: libnss3 libnspr4 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 libatspi2.0-0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 libxkbcommon0 libasound2
- uses: actions/checkout@v3
- name: copy-volumes
run: cp -rf polar/volumes-ref polar/volumes
- name: Fix docker-compose binary
# It's needed until https://github.com/isbang/compose-action/issues/20 is fixed
if: ${{ env.ACT }}
run: |
ln -s /usr/libexec/docker/cli-plugins/docker-compose /usr/local/bin/docker-compose
- uses: isbang/compose-action@v1.4.1
with:
compose-file: "polar/docker-compose.yml"
down-flags: "--volumes"
- name: init-polar
run: scripts/init-polar.sh
- name: Set up python
id: setup-python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
# --no-ansi because of https://github.com/python-poetry/poetry/issues/7184
run: poetry install --no-interaction --no-root --no-ansi
- name: Load cached Playwright
id: cached-playwright
uses: actions/cache@v3
with:
path: ~/.cache/ms-playwright
key: playwright-${{ runner.os }}
- name: Install Playwright
if: steps.cached-playwright.outputs.cache-hit != 'true'
run: |
source .venv/bin/activate
playwright install
- name: Run tests
if: ${{ env.run_test }}
run: |
source .venv/bin/activate
coverage run --source=donate4fun --concurrency greenlet,thread --branch -m pytest -sxv
env:
DONATE4FUN_TEST_DB_URL: "postgresql+asyncpg://postgres:postgres@localhost/postgres"
SQLALCHEMY_SILENCE_UBER_WARNING: "1"
- name: Generate coverage report
if: ${{ env.run_test }}
run: |
source .venv/bin/activate
coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
if: ${{ env.run_test }}
with:
files: coverage.xml