diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c5abcf23..569f58de 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,20 +21,18 @@ jobs: uses: ./.github/workflows/tests.yml with: python-version: ${{ matrix.python-version }} + db-url: ${{ matrix.db-url }} secrets: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - migrations: + migration: needs: [ lint ] strategy: matrix: - python-version: ["3.9"] - uses: ./.github/workflows/tests.yml + python-version: ["3.9", "3.10"] + uses: ./.github/workflows/migration.yml with: - make: test-migration - db-name: migration - secrets: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + python-version: ${{ matrix.python-version }} openapi: needs: [ lint ] diff --git a/.github/workflows/jmeter.yml b/.github/workflows/jmeter.yml index a4ec082f..d46b483e 100644 --- a/.github/workflows/jmeter.yml +++ b/.github/workflows/jmeter.yml @@ -49,5 +49,5 @@ jobs: with: name: jmeter-extension-test-results path: | - reports/ - logs/ + lnbits-extensions/reports/ + lnbits-extensions/logs/ diff --git a/.github/workflows/migration.yml b/.github/workflows/migration.yml new file mode 100644 index 00000000..9edb62e3 --- /dev/null +++ b/.github/workflows/migration.yml @@ -0,0 +1,37 @@ +name: migration + +on: + workflow_call: + inputs: + python-version: + description: "python version" + type: string + default: "3.10" + +jobs: + make: + name: migration (${{ inputs.python-version }}) + strategy: + matrix: + os-version: ["ubuntu-latest"] + runs-on: ${{ matrix.os-version }} + services: + postgres: + image: postgres:latest + env: + POSTGRES_USER: lnbits + POSTGRES_PASSWORD: lnbits + POSTGRES_DB: migration + ports: + - 5432:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/prepare + with: + python-version: ${{ inputs.python-version }} + - run: make test-migration diff --git a/.github/workflows/regtest.yml b/.github/workflows/regtest.yml index a51f681e..87deff7d 100644 --- a/.github/workflows/regtest.yml +++ b/.github/workflows/regtest.yml @@ -56,7 +56,8 @@ jobs: if: ${{ inputs.backend-wallet-class == 'LNbitsWallet' }} run: docker exec lnbits-lnbits-1 poetry run python tools/create_fake_admin.py - - name: Run Tests + - name: Run pytest + uses: pavelzw/pytest-action@v2 env: LNBITS_DATABASE_URL: ${{ inputs.db-url }} LNBITS_BACKEND_WALLET_CLASS: ${{ inputs.backend-wallet-class }} @@ -75,7 +76,16 @@ jobs: LNBITS_KEY: "d08a3313322a4514af75d488bcc27eee" ECLAIR_URL: http://127.0.0.1:8082 ECLAIR_PASS: lnbits - run: make test-real-wallet + LNBITS_DATA_FOLDER: "./tests/data" + PYTHONUNBUFFERED: 1 + DEBUG: true + with: + verbose: false + job-summary: true + emoji: false + click-to-expand: false + custom-pytest: poetry run pytest + report-title: "regtest (${{ inputs.python-version }}, ${{ inputs.backend-wallet-class }}" - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1b7c0ebb..00c50ce7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -3,9 +3,6 @@ name: tests on: workflow_call: inputs: - make: - default: test - type: string python-version: default: "3.9" type: string @@ -48,15 +45,26 @@ jobs: with: python-version: ${{ inputs.python-version }} - - name: Run Tests + - name: Run pytest + uses: pavelzw/pytest-action@v2 env: LNBITS_DATABASE_URL: ${{ inputs.db-url }} LNBITS_BACKEND_WALLET_CLASS: FakeWallet - run: make ${{ inputs.make }} + FAKE_WALLET_SECRET: "ToTheMoon1" + LNBITS_DATA_FOLDER: "./tests/data" + PYTHONUNBUFFERED: 1 + DEBUG: true + with: + verbose: false + job-summary: true + emoji: false + click-to-expand: false + custom-pytest: poetry run pytest + report-title: "test (${{ inputs.python-version }}, ${{ inputs.db-url }})" - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 with: file: ./coverage.xml token: ${{ secrets.CODECOV_TOKEN }} - verbose: true + verbose: false diff --git a/flake.nix b/flake.nix index a0ba9419..a6a0c45f 100644 --- a/flake.nix +++ b/flake.nix @@ -37,6 +37,9 @@ asgi-lifespan = prev.asgi-lifespan.overridePythonAttrs ( old: { buildInputs = (old.buildInputs or []) ++ [ prev.setuptools ]; } ); + pytest-md = prev.pytest-md.overridePythonAttrs ( + old: { buildInputs = (old.buildInputs or []) ++ [ prev.setuptools ]; } + ); }); }; }); diff --git a/poetry.lock b/poetry.lock index c9dea51e..178c71b3 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1958,6 +1958,20 @@ pytest = ">=4.6" [package.extras] testing = ["fields", "hunter", "process-tests", "pytest-xdist", "six", "virtualenv"] +[[package]] +name = "pytest-md" +version = "0.2.0" +description = "Plugin for generating Markdown reports for pytest results" +optional = false +python-versions = ">=3.6" +files = [ + {file = "pytest-md-0.2.0.tar.gz", hash = "sha256:3b248d5b360ea5198e05b4f49c7442234812809a63137ec6cdd3643a40cf0112"}, + {file = "pytest_md-0.2.0-py3-none-any.whl", hash = "sha256:4c4cd16fea6d1485e87ee254558712c804a96d2aa9674b780e7eb8fb6526e1d1"}, +] + +[package.dependencies] +pytest = ">=4.2.1" + [[package]] name = "python-crontab" version = "3.0.0" @@ -2948,4 +2962,4 @@ liquid = ["wallycore"] [metadata] lock-version = "2.0" python-versions = "^3.10 | ^3.9" -content-hash = "cbe93bb8afbda1cddb4e30721fb15a016b8fb1250d07ee06ff9365b8757c1710" +content-hash = "a58655feabd699c4f4dd8ad67989f09dbc1385e6e62c46364bb3a7df4f254e8c" diff --git a/pyproject.toml b/pyproject.toml index 0e86b7ea..1d444ac2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,6 +72,7 @@ types-python-jose = "^3.3.4.8" openai = "^1.12.0" json5 = "^0.9.17" asgi-lifespan = "^2.1.0" +pytest-md = "^0.2.0" [build-system] requires = ["poetry-core>=1.0.0"]