From 435e74f83ab450ed26b37b8124d63125b3bd2334 Mon Sep 17 00:00:00 2001 From: tecnovert Date: Thu, 28 Nov 2024 21:57:40 +0200 Subject: [PATCH] ci: Add test to github actions. --- .github/workflows/ci.yml | 58 +++++++++++++++++++ .github/workflows/lint.yml | 26 --------- .../extended/test_encrypted_xmr_reload.py | 5 +- 3 files changed, 61 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c8dee10 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,58 @@ +name: ci + +on: [push, pull_request] + +env: + BIN_DIR: /tmp/cached_bin + TEST_RELOAD_PATH: /tmp/test_basicswap1 + +jobs: + ci: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.12"] + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 codespell pytest + pip install -r requirements.txt --require-hashes + - name: Install + run: | + pip install . + - name: Running flake8 + run: | + flake8 --ignore=E203,E501,W503 --exclude=basicswap/contrib,basicswap/interface/contrib,.eggs,.tox,bin/install_certifi.py + - name: Running codespell + run: | + codespell --check-filenames --disable-colors --quiet-level=7 --ignore-words=tests/lint/spelling.ignore-words.txt -S .git,.eggs,.tox,pgp,*.pyc,*basicswap/contrib,*basicswap/interface/contrib,*mnemonics.py,bin/install_certifi.py,*basicswap/static + - name: Running test_other + run: | + pytest tests/basicswap/test_other.py + - name: Cache coin cores + id: cache-cores + uses: actions/cache@v3 + env: + cache-name: cache-cores + with: + path: "$BIN_DIR" + key: python bin/basicswap-prepare.py --version --withcoins=bitcoin,monero + + - if: ${{ steps.cache-yarn.outputs.cache-hit != 'true' }} + name: Running basicswap-prepare + run: | + basicswap-prepare --bindir="$BIN_DIR" --preparebinonly --withcoins=particl,bitcoin,monero + - name: Running test_encrypted_xmr_reload + run: | + export PYTHONPATH=$(pwd) + export TEST_PATH=${TEST_RELOAD_PATH} + mkdir -p ${TEST_RELOAD_PATH}/bin + cp -r $BIN_DIR/* ${TEST_RELOAD_PATH}/bin/ + pytest tests/basicswap/extended/test_encrypted_xmr_reload.py + diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 6e559a3..0000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: lint - -on: [push, pull_request] - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ["3.12"] - steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 codespell - - name: Running flake8 - run: | - flake8 --ignore=E203,E501,W503 --exclude=basicswap/contrib,basicswap/interface/contrib,.eggs,.tox,bin/install_certifi.py - - name: Running codespell - run: | - codespell --check-filenames --disable-colors --quiet-level=7 --ignore-words=tests/lint/spelling.ignore-words.txt -S .git,.eggs,.tox,pgp,*.pyc,*basicswap/contrib,*basicswap/interface/contrib,*mnemonics.py,bin/install_certifi.py,*basicswap/static diff --git a/tests/basicswap/extended/test_encrypted_xmr_reload.py b/tests/basicswap/extended/test_encrypted_xmr_reload.py index 8e3e79d..03f3715 100644 --- a/tests/basicswap/extended/test_encrypted_xmr_reload.py +++ b/tests/basicswap/extended/test_encrypted_xmr_reload.py @@ -103,12 +103,13 @@ class Test(XmrTestBase): waitForNumBids(self.delay_event, 12700, 1) - for i in range(10): + for i in range(16): bids = read_json_api(12700, "bids") bid = bids[0] if bid["bid_state"] == "Received": break - self.delay_event.wait(1) + self.delay_event.wait(2) + assert bid["bid_state"] == "Received" assert bid["expire_at"] == bid["created_at"] + data["validmins"] * 60 data = {"accept": True}