Skip to content

Commit

Permalink
Modernize CI, add poetry, update beets
Browse files Browse the repository at this point in the history
  • Loading branch information
geigerzaehler committed Feb 12, 2024
1 parent 7ea11f8 commit b9634d3
Show file tree
Hide file tree
Showing 11 changed files with 523 additions and 74 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Check and test

on: [push, pull_request]

jobs:
build:
strategy:
matrix:
python-version:
- "3.8" # minimum required
- "3.12" # latest
- "3.13-dev" # next

runs-on: ubuntu-latest
continue-on-error: ${{ matrix.python-version == '3.13-dev' }}

steps:
- run: sudo apt-get install flac mp3val oggz-tools
- uses: actions/checkout@v3
- run: pip install poetry
- uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
cache: poetry
- run: poetry env use $(which python)
- run: poetry install
- run: poetry run flake8

build-beets-master:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- run: pip install poetry
- uses: actions/setup-python@v3
with:
python-version: 3.8
cache: poetry
- run: poetry env use $(which python)
- run: poetry install
# We cannot use `poetry add` because poetry does not install beets
# dependencies properly
- run: poetry run pip install "git+https://github.com/beetbox/beets#master"
- run: poetry run pytest
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.7.7
3.8
24 changes: 0 additions & 24 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ beets-check
and validates file checksums and uses third party tools to run custom
tests on files.

This plugin requires at least version 1.4.7 of beets and at least Python 3.7.
This plugin requires at least version 1.6.0 of beets and at least Python 3.8

```
pip install --upgrade beets>=1.4.7
pip install --upgrade beets>=1.6.0
pip install git+git://github.com/geigerzaehler/beets-check.git@master
```

Expand Down
428 changes: 428 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[tool.poetry]
name = "beets-check"
version = "0.13.0"
description = "beets plugin verifying file integrity with checksums"
authors = ["Thomas Scholtes <geigerzaehler@axiom.fm>"]
license = "MIT"
readme = "README.md"
repository = "http://www.github.com/geigerzaehler/beets-check"
classifiers = [
"Topic :: Multimedia :: Sound/Audio",
"Topic :: Multimedia :: Sound/Audio :: Players :: MP3",
"License :: OSI Approved :: MIT License",
"Environment :: Console",
"Environment :: Web Environment",
"Programming Language :: Python :: 3",
]
packages = [{ include = "beetsplug" }]

[tool.poetry.dependencies]
python = "^3.8, >=3.8.1"
beets = "^1.6.0"
mediafile = "^0.12.0"


[tool.poetry.group.dev.dependencies]
flake8 = "^7.0.0"
nose = "^1.3.7"
pytest = "^8.0.0"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
8 changes: 0 additions & 8 deletions setup.cfg

This file was deleted.

32 changes: 0 additions & 32 deletions setup.py

This file was deleted.

14 changes: 8 additions & 6 deletions test/cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_add_checksums(self):

beets.ui._raw_main(['check', '-a'])

item.load()
item = self.lib.items().get()
self.assertIn('checksum', item)

def test_dont_add_existing_checksums(self):
Expand All @@ -45,6 +45,7 @@ def test_dont_add_existing_checksums(self):
self.modifyFile(item.path)
beets.ui._raw_main(['check', '-a'])

item["checksum"] = ""
item.load()
self.assertEqual(item['checksum'], orig_checksum)

Expand Down Expand Up @@ -172,7 +173,7 @@ def test_force_all_update(self):

beets.ui._raw_main(['check', '--force', '--update'])

item.load()
item = self.lib.items().get()
self.assertNotEqual(item['checksum'], orig_checksum)
verify_checksum(item)

Expand All @@ -188,7 +189,7 @@ def test_update_all_confirmation(self):
self.assertIn('Do you want to overwrite all checksums',
stdout.getvalue())

item.load()
item = self.lib.items().get()
self.assertNotEqual(item['checksum'], orig_checksum)
verify_checksum(item)

Expand All @@ -201,7 +202,7 @@ def test_update_all_confirmation_no(self):
with controlStdin(u'n'):
beets.ui._raw_main(['check', '--update'])

item.load()
item = self.lib.items().get()
self.assertEqual(item['checksum'], orig_checksum)

def test_update_nonexistent(self):
Expand Down Expand Up @@ -258,8 +259,7 @@ def test_flac_integrity(self):
with self.assertRaises(SystemExit):
with captureLog() as logs:
beets.ui._raw_main(['check', '--external'])
print('\n'.join(logs))
self.assertIn(u'check: WARNING while decoding data: {}'
self.assertIn(u'check: WARNING during decoding: {}'
.format(item.path.decode('utf-8')), logs)

def test_ogg_vorbis_integrity(self):
Expand Down Expand Up @@ -335,6 +335,7 @@ def test_update_checksum(self):
old_checksum = item['checksum']
beets.ui._raw_main(['check', '--fix', '--force'])

item["checksum"] = ""
item.load()
verify_checksum(item)
self.assertNotEqual(old_checksum, item['checksum'])
Expand All @@ -348,6 +349,7 @@ def test_dont_fix_with_wrong_checksum(self):
beets.ui._raw_main(['check', '--fix', '--force'])
self.assertIn('FAILED checksum', '\n'.join(logs))

item["checksum"] = ""
item.load()
self.assertEqual(item['checksum'], 'this is wrong')

Expand Down
2 changes: 1 addition & 1 deletion test/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
AlbumMatch, TrackMatch, Recommendation, Proposal
from beets.autotag.hooks import Distance
from beets.library import Item
from beets.mediafile import MediaFile
from mediafile import MediaFile

from beetsplug import check

Expand Down
7 changes: 7 additions & 0 deletions test/integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import beets.ui
import beets.library
from beets.mediafile import MediaFile
import beets.plugins

from test.helper import TestHelper, captureLog, \
controlStdin, captureStdout, MockChecker
Expand Down Expand Up @@ -145,6 +146,7 @@ def test_write_on_integrity_error(self):
item.store()
beets.ui._raw_main(['write', item.title])

item["checksum"] = ""
item.load()
verify_checksum(item)
mediafile = MediaFile(item.path)
Expand All @@ -159,6 +161,7 @@ def test_update_checksum(self):
item.store()
beets.ui._raw_main(['write', item.title])

item["checksum"] = ""
item.load()
self.assertNotEqual(item['checksum'], orig_checksum)
verify_checksum(item)
Expand All @@ -173,6 +176,9 @@ def setUp(self):
super(ConvertTest, self).setUp()
self.setupBeets()
beets.config['plugins'] = ['convert']
beets.plugins._instances.clear()
beets.plugins.load_plugins(("convert", "check"))

beets.config['convert'] = {
'dest': os.path.join(self.temp_dir, 'convert'),
# Truncated copy to break checksum
Expand All @@ -182,6 +188,7 @@ def setUp(self):

def test_convert_command(self):
with controlStdin('y'):
print("GO")
beets.ui._raw_main(['convert', 'ok.ogg'])

def test_update_after_keep_new_convert(self):
Expand Down

0 comments on commit b9634d3

Please sign in to comment.