Skip to content

Commit b96d0c3

Browse files
authored
CI + linting + fixes #1
fixes + CI improvements + linting #patch
2 parents 5b4e5bf + 99e75a5 commit b96d0c3

15 files changed

+463
-191
lines changed

.github/workflows/lint.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: lint
2+
on: [ pull_request ]
3+
jobs:
4+
ruff:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@v4
8+
- uses: astral-sh/ruff-action@v3

.github/workflows/python-publish.yml

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,21 @@
11
# This workflow will upload a Python Package
2-
# using Twine when a release is created
3-
42
name: publish
5-
63
on:
4+
push:
5+
tags: ['v*.*.*']
76
release:
87
types: [created]
9-
108
jobs:
119
deploy:
12-
1310
runs-on: ubuntu-latest
14-
1511
steps:
16-
- uses: actions/checkout@v2
17-
18-
- name: Set up Python
19-
uses: actions/setup-python@v2
12+
- uses: actions/checkout@v4
13+
- uses: astral-sh/setup-uv@v5
2014
with:
21-
python-version: '3.x'
22-
23-
- name: Install dependencies
24-
run: |
25-
python3 -m pip install --upgrade pip
26-
python3 -m pip install setuptools wheel twine
15+
version: "latest"
16+
python-version: '3.9'
2717

28-
- name: Build and publish
29-
env:
30-
TWINE_USERNAME: __token__
31-
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
18+
- name: Build and Publish
3219
run: |
33-
python3 setup.py sdist bdist_wheel
34-
python3 -m twine upload dist/*
20+
uv build
21+
uv publish --username="__token__" --password="${{ secrets.PYPI_TOKEN }}"

.github/workflows/python-test.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# This workflow will install Python dependencies,
2+
# then run tests over a variety of Python versions.
3+
4+
# name: test
5+
#
6+
# on:
7+
# push:
8+
# tags: [ '*' ]
9+
# pull_request:
10+
# branches: [ "main", "dev*", "feature*", "fix*"]
11+
#
12+
# jobs:
13+
# build:
14+
# runs-on: ${{ matrix.os }}
15+
# strategy:
16+
# matrix:
17+
# os: [ubuntu-latest] # [ubuntu-latest, windows-latest, macos-latest]
18+
# python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
19+
#
20+
# steps:
21+
# - uses: actions/checkout@v4
22+
# - uses: astral-sh/setup-uv@v5
23+
# with:
24+
# version: "latest"
25+
# python-version: ${{ matrix.python-version }}
26+
#
27+
# - name: Install & Test Defaults
28+
# run: |
29+
# uv pip install ".[test]"
30+
# pytest --cov=doorway --color=yes --capture=no --verbose -m 'not extra_test' ./tests/
31+
#
32+
# - name: Install & Test Extras
33+
# run: |
34+
# uv pip install ".[extras]"
35+
# pytest --cov=doorway --color=yes --capture=no --verbose -m 'extra_test' ./tests/
36+
#
37+
# # codecov automatically merges all generated files
38+
# - uses: codecov/codecov-action@v1
39+
# with:
40+
# token: ${{ secrets.CODECOV_TOKEN }}
41+
# fail_ci_if_error: false
42+
43+
# # @pytest.mark.remote_test
44+
# # pytest --color=yes --capture=no --verbose -m 'not remote_test'
45+
# # * run pytest on non-remote tests
46+
# - id: pytest
47+
# run: pytest --color=yes --capture=no --verbose -m 'not remote_test'

.github/workflows/version-bump.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
name: version-bump
3+
on:
4+
pull_request: {types: [closed], branches: [main]}
5+
jobs:
6+
build:
7+
if: github.event.pull_request.merged == true
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
with:
12+
ref: ${{ github.event.pull_request.merge_commit_sha }}
13+
fetch-depth: "0"
14+
- uses: anothrNick/github-tag-action@v1
15+
env:
16+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17+
DEFAULT_BUMP: "patch"
18+
WITH_V: true

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,4 @@ data/
137137
.idea/
138138
/lightning_logs/
139139
*.zip
140-
*.db
140+
*.db

.pre-commit-config.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v2.3.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-added-large-files
9+
args: ["--maxkb=500"]
10+
- id: check-case-conflict
11+
- id: detect-private-key
12+
13+
# - repo: https://github.com/asottile/pyupgrade
14+
# rev: v3.19.1
15+
# hooks:
16+
# - id: pyupgrade
17+
# args: [--py39-plus]
18+
19+
- repo: https://github.com/astral-sh/ruff-pre-commit
20+
rev: v0.9.9
21+
hooks:
22+
- id: ruff
23+
args: [ --fix ]
24+
- id: ruff-format

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ the `mtgdata.scryfall_convert.generate_converted_dataset` function. Similar argu
129129
as that of the command line approach.
130130

131131
```python3
132-
from mtgdata import generate_converted_dataset
132+
from mtgdata import generate_converted_dataset
133133

134134
generate_converted_dataset(
135135
out_img_type='border_crop',

mtgdata/__init__.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
1+
__all__ = (
2+
"ScryfallDataset",
3+
"ScryfallCardFaceDatasetManager",
4+
"ScryfallImageType",
5+
"ScryfallBulkType",
6+
"Hdf5Dataset",
7+
"dataset_save_as_hdf5",
8+
"generate_converted_dataset",
9+
)
110

2-
from mtgdata.scryfall import ScryfallDataset, ScryfallCardFaceDatasetManager, ScryfallImageType, ScryfallBulkType
11+
from mtgdata.scryfall import (
12+
ScryfallDataset,
13+
ScryfallCardFaceDatasetManager,
14+
ScryfallImageType,
15+
ScryfallBulkType,
16+
)
317
from mtgdata.util.hdf5 import Hdf5Dataset
418

519
from mtgdata.scryfall_convert import dataset_save_as_hdf5
20+
621
# from mtgdata.scryfall_convert import dataset_save_meta
722
from mtgdata.scryfall_convert import generate_converted_dataset

mtgdata/__main__.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,37 @@
1-
2-
3-
if __name__ == '__main__':
1+
if __name__ == "__main__":
42
import argparse
53
import logging
64
from mtgdata.scryfall import _make_parser_scryfall_prepare, _run_scryfall_prepare
7-
from mtgdata.scryfall_convert import _make_parser_scryfall_convert, _run_scryfall_convert
5+
from mtgdata.scryfall_convert import (
6+
_make_parser_scryfall_convert,
7+
_run_scryfall_convert,
8+
)
89

910
# initialise logging
1011
logging.basicConfig(level=logging.INFO)
11-
YLW = '\033[93m'
12-
RST = '\033[0m'
12+
YLW = "\033[93m"
13+
RST = "\033[0m"
1314

1415
# subcommands
1516
cli = argparse.ArgumentParser()
1617
parsers = cli.add_subparsers()
1718
parsers.required = True
1819

1920
# subcommand: prepare -- add args from scryfall.py
20-
parser_prepare = parsers.add_parser('prepare')
21-
parser_prepare.set_defaults(_run_fn_=_run_scryfall_prepare, _run_msg_=f'{YLW}preparing...{RST}')
21+
parser_prepare = parsers.add_parser("prepare")
22+
parser_prepare.set_defaults(
23+
_run_fn_=_run_scryfall_prepare, _run_msg_=f"{YLW}preparing...{RST}"
24+
)
2225
_make_parser_scryfall_prepare(parser_prepare)
2326

2427
# subcommand: convert -- add args from scryfall_convert.py
25-
parser_convert = parsers.add_parser('convert')
26-
parser_convert.set_defaults(_run_fn_=_run_scryfall_convert, _run_msg_=f'{YLW}converting...{RST}')
28+
parser_convert = parsers.add_parser("convert")
29+
parser_convert.set_defaults(
30+
_run_fn_=_run_scryfall_convert, _run_msg_=f"{YLW}converting...{RST}"
31+
)
2732
_make_parser_scryfall_convert(parser_convert)
2833

2934
# run the specified subcommand!
3035
args = cli.parse_args()
31-
print(f'{args._run_msg_}')
36+
print(f"{args._run_msg_}")
3237
args._run_fn_(args)

0 commit comments

Comments
 (0)