Skip to content

Commit

Permalink
Add dependabot automerge (#220)
Browse files Browse the repository at this point in the history
  • Loading branch information
btschwertfeger committed May 15, 2024
1 parent feaa5cd commit 7d9f571
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 8 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/dependabot_auto_approve.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2024 Benjamin Thomas Schwertfeger
# GitHub: https://github.com/btschwertfeger
#
# Workflow that approves and merges all pull requests from the dependabot[bot]
# author.
#
# Source (May, 2024):
# - https://blog.somewhatabstract.com/2021/10/11/setting-up-dependabot-with-github-actions-to-approve-and-merge/

name: Dependabot auto-merge
on: pull_request_target

permissions:
pull-requests: write
contents: write

jobs:
dependabot:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Dependabot metadata
id: dependabot-metadata
uses: dependabot/fetch-metadata@v1.1.1
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Approve a PR
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Enable auto-merge for Dependabot PRs
if: ${{ steps.dependabot-metadata.outputs.update-type != 'version-update:semver-major' }}
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 4 additions & 0 deletions kraken/nft/trade.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ def modify_auction(
"""
Modify an existing auction owned by the user
- https://docs.kraken.com/rest/#tag/NFT-Trading/operation/modifyAuction
:param auction_id: ID referencing the auction
:type auction_id: str
:param ask_price: New ask price (only for fixed price auction type),
Expand Down Expand Up @@ -183,6 +185,8 @@ def cancel_auction(
"""
Cancel an existing auction owned by the user
- https://docs.kraken.com/rest/#tag/NFT-Trading/operation/cancelAuction
:param auction_id: IDs referencing the auctions to cancel
:type auction_id: list[str]
:param otp: One time password, defaults to None
Expand Down
24 changes: 16 additions & 8 deletions tests/nft/test_nft_trade.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from datetime import datetime, timedelta

from kraken.exceptions import (
KrakenAuctionNotOwnedByUserError,
KrakenInvalidArgumentBelowMinError,
KrakenInvalidArgumentOfferNotFoundError,
KrakenNFTNotAvailableError,
Expand Down Expand Up @@ -59,15 +58,24 @@ def test_nft_trade_create_auction(nft_auth_trade: Trade) -> None:
@pytest.mark.nft_auth()
@pytest.mark.nft_trade()
def test_nft_trade_modify_auction(nft_auth_trade: Trade) -> None:
"""Checks the ``modify_auction`` endpoint."""
"""
Checks the ``modify_auction`` endpoint.
It is sufficient here to check that the request is valid, even if the
auction is not valid.
"""

with pytest.raises(KrakenAuctionNotOwnedByUserError):
nft_auth_trade.modify_auction(
auction_id="AT2POJ-4CH3O-4TH6JH",
ask_price="0.3",
)
response = nft_auth_trade.modify_auction(
auction_id="AT2POJ-4CH3O-4TH6JH",
ask_price="0.3",
)
assert isinstance(response, dict)
assert response.get(
"error",
[],
) == ["EAPI:Invalid arguments:No auction with the provided ID"]


@pytest.mark.wip()
@pytest.mark.nft()
@pytest.mark.nft_auth()
@pytest.mark.nft_trade()
Expand All @@ -83,7 +91,7 @@ def test_nft_trade_cancel_auction(nft_auth_trade: Trade) -> None:
assert isinstance(result["statuses"][0], dict)
assert result["statuses"][0].get("id") == "AT2POJ-4CH3O-4TH6JH"
assert result["statuses"][0].get("status") == "failed"
assert result["statuses"][0].get("reason") == "no permission"
assert result["statuses"][0].get("reason") == "not found"


@pytest.mark.nft()
Expand Down

0 comments on commit 7d9f571

Please sign in to comment.