|
| 1 | +name: "ci" |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [main] |
| 6 | + push: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +jobs: |
| 10 | + test: |
| 11 | + name: run sdk tests |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + strategy: |
| 15 | + matrix: |
| 16 | + python-version: ["3.10", "3.11", "3.12"] |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: checkout code |
| 20 | + uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - name: setup python ${{ matrix.python-version }} |
| 23 | + uses: actions/setup-python@v5 |
| 24 | + with: |
| 25 | + python-version: ${{ matrix.python-version }} |
| 26 | + |
| 27 | + - name: install poetry |
| 28 | + uses: snok/install-poetry@v1 |
| 29 | + with: |
| 30 | + version: latest |
| 31 | + virtualenvs-create: true |
| 32 | + virtualenvs-in-project: true |
| 33 | + |
| 34 | + - name: load cached venv |
| 35 | + id: cached-poetry-dependencies |
| 36 | + uses: actions/cache@v4 |
| 37 | + with: |
| 38 | + path: .venv |
| 39 | + key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }} |
| 40 | + |
| 41 | + - name: install dependencies |
| 42 | + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' |
| 43 | + run: poetry install --no-interaction --no-root |
| 44 | + |
| 45 | + - name: install project |
| 46 | + run: poetry install --no-interaction |
| 47 | + |
| 48 | + - name: create test .env file (on push) |
| 49 | + if: github.event_name == 'push' |
| 50 | + run: | |
| 51 | + cat > tests/.env << EOF |
| 52 | + WHITELISTED_WALLET_PRIVATE_KEY=${{ secrets.WHITELISTED_WALLET_PRIVATE_KEY }} |
| 53 | + SELLER_ENTITY_ID=${{ secrets.SELLER_ENTITY_ID }} |
| 54 | + SELLER_AGENT_WALLET_ADDRESS=${{ secrets.SELLER_AGENT_WALLET_ADDRESS }} |
| 55 | + BUYER_ENTITY_ID=${{ secrets.BUYER_ENTITY_ID }} |
| 56 | + BUYER_AGENT_WALLET_ADDRESS=${{ secrets.BUYER_AGENT_WALLET_ADDRESS }} |
| 57 | + EOF |
| 58 | +
|
| 59 | + - name: run unit tests (on pr) |
| 60 | + if: github.event_name == 'pull_request' |
| 61 | + run: poetry run pytest tests/unit -v --junitxml=junit.xml |
| 62 | + |
| 63 | + - name: run all tests (on push) |
| 64 | + if: github.event_name == 'push' |
| 65 | + run: poetry run pytest -v --junitxml=junit.xml |
| 66 | + |
| 67 | + - name: upload test results |
| 68 | + uses: actions/upload-artifact@v4 |
| 69 | + if: ${{ !cancelled() }} |
| 70 | + with: |
| 71 | + name: test-results-${{ matrix.python-version }} |
| 72 | + path: junit.xml |
0 commit comments