1
0
Fork 0
mirror of https://github.com/borgbase/vorta synced 2024-12-21 23:33:13 +00:00

Fix macOS tests (#2095)

This commit is contained in:
Manu 2024-10-18 15:17:34 +01:00 committed by GitHub
parent 85c30ca0c7
commit cf4370aa33
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 225 additions and 212 deletions

View file

@ -3,28 +3,28 @@ branch_name="$2"
if [[ "$event_name" == "workflow_dispatch" ]] || [[ "$branch_name" == "master" ]]; then if [[ "$event_name" == "workflow_dispatch" ]] || [[ "$branch_name" == "master" ]]; then
echo '{ echo '{
"python-version": ["3.8", "3.9", "3.10", "3.11"], "python-version": ["3.9", "3.10", "3.11"],
"os": ["ubuntu-22.04", "macos-12"], "os": ["ubuntu-22.04", "macos-14"],
"borg-version": ["1.2.4"] "borg-version": ["1.4.0"]
}' | jq -c . > matrix-unit.json }' | jq -c . > matrix-unit.json
echo '{ echo '{
"python-version": ["3.8", "3.9", "3.10", "3.11"], "python-version": ["3.9", "3.10", "3.11"],
"os": ["ubuntu-22.04", "macos-12"], "os": ["ubuntu-22.04", "macos-14"],
"borg-version": ["1.1.18", "1.2.2", "1.2.4", "2.0.0b5"], "borg-version": ["1.1.18", "1.2.8", "1.4.0", "2.0.0b12"],
"exclude": [{"borg-version": "2.0.0b5", "python-version": "3.8"}] "exclude": [{"borg-version": "2.0.0b12", "python-version": "3.8"}]
}' | jq -c . > matrix-integration.json }' | jq -c . > matrix-integration.json
elif [[ "$event_name" == "push" ]] || [[ "$event_name" == "pull_request" ]]; then elif [[ "$event_name" == "push" ]] || [[ "$event_name" == "pull_request" ]]; then
echo '{ echo '{
"python-version": ["3.8", "3.9", "3.10", "3.11"], "python-version": ["3.9", "3.11"],
"os": ["ubuntu-22.04", "macos-12"], "os": ["ubuntu-22.04", "macos-14"],
"borg-version": ["1.2.4"] "borg-version": ["1.2.8"]
}' | jq -c . > matrix-unit.json }' | jq -c . > matrix-unit.json
echo '{ echo '{
"python-version": ["3.10"], "python-version": ["3.11"],
"os": ["ubuntu-22.04"], "os": ["ubuntu-22.04"],
"borg-version": ["1.2.4"] "borg-version": ["1.2.8"]
}' | jq -c . > matrix-integration.json }' | jq -c . > matrix-integration.json
fi fi

View file

@ -31,12 +31,12 @@ jobs:
run: | run: |
brew install --cask sparkle brew install --cask sparkle
brew install create-dmg brew install create-dmg
pip3 install --upgrade pip pip3 install --break-system-packages --upgrade pip
pip3 install -r dev.txt pip3 install --break-system-packages -r dev.txt
working-directory: requirements.d working-directory: requirements.d
- name: Install Vorta - name: Install Vorta
run: | run: |
pip3 install . pip3 install --break-system-packages .
- name: Package with PyInstaller - name: Package with PyInstaller
run: | run: |
pyinstaller --clean --noconfirm package/vorta.spec pyinstaller --clean --noconfirm package/vorta.spec

View file

@ -51,7 +51,7 @@ jobs:
test-unit: test-unit:
needs: prepare-matrix needs: prepare-matrix
timeout-minutes: 20 timeout-minutes: 60 # macos tests are very slow
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
strategy: strategy:
fail-fast: false fail-fast: false
@ -137,10 +137,11 @@ jobs:
run: echo $PKG_CONFIG_PATH && make test-integration run: echo $PKG_CONFIG_PATH && make test-integration
- name: Upload coverage to Codecov - name: Upload coverage to Codecov
uses: codecov/codecov-action@v3 uses: codecov/codecov-action@v4
env: env:
OS: ${{ runner.os }} OS: ${{ runner.os }}
python: ${{ matrix.python-version }} python: ${{ matrix.python-version }}
with: with:
token: ${{ secrets.CODECOV_TOKEN }} token: ${{ secrets.CODECOV_TOKEN }}
env_vars: OS, python env_vars: OS, python
version: v0.7.3 # workaround on Intel macs (GH Actions)

View file

@ -18,335 +18,347 @@
@pytest.mark.parametrize( @pytest.mark.parametrize(
'archive_name_1, archive_name_2, expected', "archive_name_1, archive_name_2, expected",
[ [
( (
'test-archive1', "test-archive1",
'test-archive2', "test-archive2",
[ [
{ {
'subpath': 'dir', "subpath": "dir",
'data': { "data": {
'file_type': FileType.FILE, "file_type": FileType.FILE,
'change_type': ChangeType.MODIFIED, "change_type": ChangeType.MODIFIED,
'modified': None, "modified": None,
}, },
'min_version': '1.2.4', "min_version": "1.2.4",
'max_version': '1.2.4', "max_version": "1.2.8",
}, },
{ {
'subpath': 'file', "subpath": "file",
'data': { "data": {
'file_type': FileType.FILE, "file_type": FileType.FILE,
'change_type': ChangeType.MODIFIED, "change_type": ChangeType.MODIFIED,
'modified': (0, 0), "modified": (0, 0),
}, },
'min_version': '1.2.4', "min_version": "1.2.4",
'max_version': '1.2.4', "max_version": "1.2.8",
}, },
{ {
'subpath': 'chrdev', "subpath": "chrdev",
'data': { "data": {
'file_type': FileType.CHRDEV, "file_type": FileType.CHRDEV,
'change_type': ChangeType.ADDED, "change_type": ChangeType.ADDED,
'modified': None, "modified": None,
}, },
}, },
{ {
'subpath': 'fifo', "subpath": "fifo",
'data': { "data": {
'file_type': FileType.FIFO, "file_type": FileType.FIFO,
'change_type': ChangeType.ADDED, "change_type": ChangeType.ADDED,
'modified': None, "modified": None,
}, },
}, },
{ {
'subpath': 'hardlink', "subpath": "hardlink",
'data': { "data": {
'file_type': FileType.FILE, "file_type": FileType.FILE,
'change_type': ChangeType.ADDED, "change_type": ChangeType.ADDED,
'modified': None, "modified": None,
}, },
}, },
{ {
'subpath': 'symlink', "subpath": "symlink",
'data': { "data": {
'file_type': FileType.LINK, "file_type": FileType.LINK,
'change_type': ChangeType.ADDED, "change_type": ChangeType.ADDED,
'modified': None, "modified": None,
}, },
}, },
], ],
), ),
( (
'test-archive2', "test-archive2",
'test-archive3', "test-archive3",
[ [
{ {
'subpath': 'borg_src', "subpath": "borg_src",
'match_startsWith': True, "match_startsWith": True,
'data': { "data": {
'file_type': FileType.FILE, "file_type": FileType.FILE,
'change_type': ChangeType.MODIFIED, "change_type": ChangeType.MODIFIED,
'modified': None, "modified": None,
}, },
'min_version': '1.2.4', "min_version": "1.2.4",
'max_version': '1.2.4', "max_version": "1.2.8",
}, },
{ {
'subpath': 'dir', "subpath": "dir",
'data': { "data": {
'file_type': FileType.DIRECTORY, "file_type": FileType.DIRECTORY,
'change_type': ChangeType.REMOVED, "change_type": ChangeType.REMOVED,
'modified': None, "modified": None,
}, },
}, },
{ {
'subpath': 'chrdev', "subpath": "chrdev",
'data': { "data": {
'file_type': FileType.CHRDEV, "file_type": FileType.CHRDEV,
'change_type': ChangeType.REMOVED, "change_type": ChangeType.REMOVED,
}, },
}, },
{ {
'subpath': 'fifo', "subpath": "fifo",
'data': { "data": {
'file_type': FileType.FIFO, "file_type": FileType.FIFO,
'change_type': ChangeType.REMOVED, "change_type": ChangeType.REMOVED,
}, },
}, },
{ {
'subpath': 'file', "subpath": "file",
'data': { "data": {
'file_type': FileType.FILE, "file_type": FileType.FILE,
'change_type': ChangeType.REMOVED, "change_type": ChangeType.REMOVED,
}, },
}, },
{ {
'subpath': 'hardlink', "subpath": "hardlink",
'data': { "data": {
'file_type': FileType.FILE, "file_type": FileType.FILE,
'change_type': ChangeType.REMOVED, "change_type": ChangeType.REMOVED,
}, },
}, },
{ {
'subpath': 'symlink', "subpath": "symlink",
'data': { "data": {
'file_type': FileType.LINK, "file_type": FileType.LINK,
'change_type': ChangeType.REMOVED, "change_type": ChangeType.REMOVED,
}, },
}, },
{ {
'subpath': 'dir1', "subpath": "dir1",
'data': { "data": {
'file_type': FileType.DIRECTORY, "file_type": FileType.DIRECTORY,
'change_type': ChangeType.ADDED, "change_type": ChangeType.ADDED,
}, },
}, },
{ {
'subpath': 'chrdev', "subpath": "chrdev",
'data': { "data": {
'file_type': FileType.CHRDEV, "file_type": FileType.CHRDEV,
'change_type': ChangeType.ADDED, "change_type": ChangeType.ADDED,
}, },
}, },
{ {
'subpath': 'fifo', "subpath": "fifo",
'data': { "data": {
'file_type': FileType.FIFO, "file_type": FileType.FIFO,
'change_type': ChangeType.ADDED, "change_type": ChangeType.ADDED,
}, },
}, },
{ {
'subpath': 'file', "subpath": "file",
'data': { "data": {
'file_type': FileType.FILE, "file_type": FileType.FILE,
'change_type': ChangeType.ADDED, "change_type": ChangeType.ADDED,
}, },
}, },
{ {
'subpath': 'hardlink', "subpath": "hardlink",
'data': { "data": {
'file_type': FileType.FILE, "file_type": FileType.FILE,
'change_type': ChangeType.ADDED, "change_type": ChangeType.ADDED,
}, },
}, },
{ {
'subpath': 'symlink', "subpath": "symlink",
'data': { "data": {
'file_type': FileType.LINK, "file_type": FileType.LINK,
'change_type': ChangeType.ADDED, "change_type": ChangeType.ADDED,
}, },
}, },
], ],
), ),
( (
'test-archive3', "test-archive3",
'test-archive4', "test-archive4",
[ [
{ {
'subpath': 'dir1', "subpath": "dir1",
'data': { "data": {
'file_type': FileType.FILE, "file_type": FileType.FILE,
'change_type': ChangeType.MODIFIED, "change_type": ChangeType.MODIFIED,
}, },
'min_version': '1.2.4', "min_version": "1.2.4",
'max_version': '1.2.4', "max_version": "1.2.8",
}, },
{ {
'subpath': 'chrdev', "subpath": "chrdev",
'data': { "data": {
'file_type': FileType.CHRDEV, "file_type": FileType.CHRDEV,
'change_type': ChangeType.REMOVED, "change_type": ChangeType.REMOVED,
}, },
}, },
{ {
'subpath': 'chrdev1', "subpath": "chrdev1",
'data': { "data": {
'file_type': FileType.CHRDEV, "file_type": FileType.CHRDEV,
'change_type': ChangeType.ADDED, "change_type": ChangeType.ADDED,
}, },
}, },
{ {
'subpath': 'fifo', "subpath": "fifo",
'data': { "data": {
'file_type': FileType.FIFO, "file_type": FileType.FIFO,
'change_type': ChangeType.REMOVED, "change_type": ChangeType.REMOVED,
}, },
}, },
{ {
'subpath': 'fifo1', "subpath": "fifo1",
'data': { "data": {
'file_type': FileType.FIFO, "file_type": FileType.FIFO,
'change_type': ChangeType.ADDED, "change_type": ChangeType.ADDED,
}, },
}, },
{ {
'subpath': 'file', "subpath": "file",
'data': { "data": {
'file_type': FileType.FILE, "file_type": FileType.FILE,
'change_type': ChangeType.REMOVED, "change_type": ChangeType.REMOVED,
}, },
}, },
{ {
'subpath': 'file1', "subpath": "file1",
'data': { "data": {
'file_type': FileType.FILE, "file_type": FileType.FILE,
'change_type': ChangeType.ADDED, "change_type": ChangeType.ADDED,
}, },
}, },
{ {
'subpath': 'hardlink', "subpath": "hardlink",
'data': { "data": {
'file_type': FileType.FILE, "file_type": FileType.FILE,
'change_type': ChangeType.REMOVED, "change_type": ChangeType.REMOVED,
}, },
}, },
{ {
'subpath': 'hardlink1', "subpath": "hardlink1",
'data': { "data": {
'file_type': FileType.FILE, "file_type": FileType.FILE,
'change_type': ChangeType.ADDED, "change_type": ChangeType.ADDED,
}, },
}, },
{ {
'subpath': 'symlink', "subpath": "symlink",
'data': { "data": {
'file_type': FileType.LINK, "file_type": FileType.LINK,
'change_type': ChangeType.REMOVED, "change_type": ChangeType.REMOVED,
}, },
}, },
{ {
'subpath': 'symlink1', "subpath": "symlink1",
'data': { "data": {
'file_type': FileType.LINK, "file_type": FileType.LINK,
'change_type': ChangeType.ADDED, "change_type": ChangeType.ADDED,
}, },
}, },
], ],
), ),
( (
'test-archive4', "test-archive4",
'test-archive5', "test-archive5",
[ [
{ {
'subpath': 'dir1', "subpath": "dir1",
'data': { "data": {
'file_type': FileType.FILE, "file_type": FileType.FILE,
'change_type': ChangeType.MODIFIED, "change_type": ChangeType.MODIFIED,
}, },
'min_version': '1.2.4', "min_version": "1.2.4",
'max_version': '1.2.4', "max_version": "1.2.8",
}, },
{ {
'subpath': 'chrdev1', "subpath": "chrdev1",
'data': { "data": {
'file_type': FileType.CHRDEV, "file_type": FileType.CHRDEV,
'change_type': ChangeType.REMOVED, "change_type": ChangeType.REMOVED,
}, },
}, },
{ {
'subpath': 'fifo1', "subpath": "fifo1",
'data': { "data": {
'file_type': FileType.FIFO, "file_type": FileType.FIFO,
'change_type': ChangeType.REMOVED, "change_type": ChangeType.REMOVED,
}, },
}, },
{ {
'subpath': 'file1', "subpath": "file1",
'data': { "data": {
'file_type': FileType.FILE, "file_type": FileType.FILE,
'change_type': ChangeType.REMOVED, "change_type": ChangeType.REMOVED,
}, },
}, },
{ {
'subpath': 'hardlink1', "subpath": "hardlink1",
'data': { "data": {
'file_type': FileType.FILE, "file_type": FileType.FILE,
'change_type': ChangeType.REMOVED, "change_type": ChangeType.REMOVED,
}, },
}, },
{ {
'subpath': 'symlink1', "subpath": "symlink1",
'data': { "data": {
'file_type': FileType.LINK, "file_type": FileType.LINK,
'change_type': ChangeType.REMOVED, "change_type": ChangeType.REMOVED,
}, },
}, },
], ],
), ),
( (
'test-archive5', "test-archive5",
'test-archive6', "test-archive6",
[ [
{ {
'subpath': 'dir1', "subpath": "dir1",
'data': { "data": {
'file_type': FileType.FILE, "file_type": FileType.FILE,
'change_type': ChangeType.MODIFIED, "change_type": ChangeType.MODIFIED,
}, },
'min_version': '1.2.4', "min_version": "1.2.4",
'max_version': '1.2.4', "max_version": "1.2.8",
}, },
], ],
), ),
], ],
) )
def test_archive_diff_lines(qapp, qtbot, borg_version, create_test_repo, archive_name_1, archive_name_2, expected): def test_archive_diff_lines(
qapp,
qtbot,
borg_version,
create_test_repo,
archive_name_1,
archive_name_2,
expected,
):
"""Test that the diff lines are parsed correctly for supported borg versions""" """Test that the diff lines are parsed correctly for supported borg versions"""
parsed_borg_version = borg_version[1] parsed_borg_version = borg_version[1]
supports_fifo = parsed_borg_version > parse_version('1.1.18') supports_fifo = parsed_borg_version > parse_version("1.1.18")
supports_chrdev = create_test_repo[2] supports_chrdev = create_test_repo[2]
params = BorgDiffJob.prepare(vorta.store.models.BackupProfileModel.select().first(), archive_name_1, archive_name_2) params = BorgDiffJob.prepare(
thread = BorgDiffJob(params['cmd'], params, qapp) vorta.store.models.BackupProfileModel.select().first(),
archive_name_1,
archive_name_2,
)
thread = BorgDiffJob(params["cmd"], params, qapp)
with qtbot.waitSignal(thread.result, **pytest._wait_defaults) as blocker: with qtbot.waitSignal(thread.result, **pytest._wait_defaults) as blocker:
blocker.connect(thread.updated) blocker.connect(thread.updated)
thread.run() thread.run()
diff_lines = blocker.args[0]['data'] diff_lines = blocker.args[0]["data"]
json_lines = blocker.args[0]['params']['json_lines'] json_lines = blocker.args[0]["params"]["json_lines"]
model = DiffTree() model = DiffTree()
model.setMode(model.DisplayMode.FLAT) model.setMode(model.DisplayMode.FLAT)
@ -360,15 +372,15 @@ def test_archive_diff_lines(qapp, qtbot, borg_version, create_test_repo, archive
item item
for item in expected for item in expected
if ( if (
('min_version' not in item or parse_version(item['min_version']) <= parsed_borg_version) ("min_version" not in item or parse_version(item["min_version"]) <= parsed_borg_version)
and ('max_version' not in item or parse_version(item['max_version']) >= parsed_borg_version) and ("max_version" not in item or parse_version(item["max_version"]) >= parsed_borg_version)
and (item['data']['file_type'] != FileType.FIFO or supports_fifo) and (item["data"]["file_type"] != FileType.FIFO or supports_fifo)
and (item['data']['file_type'] != FileType.CHRDEV or supports_chrdev) and (item["data"]["file_type"] != FileType.CHRDEV or supports_chrdev)
) )
] ]
# diff versions of borg produce inconsistent ordering of diff lines so we sort the expected and model # diff versions of borg produce inconsistent ordering of diff lines so we sort the expected and model
expected = sorted(expected, key=lambda item: item['subpath']) expected = sorted(expected, key=lambda item: item["subpath"])
sorted_model = sorted( sorted_model = sorted(
[model.index(index, 0).internalPointer() for index in range(model.rowCount())], [model.index(index, 0).internalPointer() for index in range(model.rowCount())],
key=lambda item: item.subpath, key=lambda item: item.subpath,
@ -377,10 +389,10 @@ def test_archive_diff_lines(qapp, qtbot, borg_version, create_test_repo, archive
assert len(sorted_model) == len(expected) assert len(sorted_model) == len(expected)
for index, item in enumerate(expected): for index, item in enumerate(expected):
if 'match_startsWith' in item and item['match_startsWith']: if "match_startsWith" in item and item["match_startsWith"]:
assert sorted_model[index].subpath.startswith(item['subpath']) assert sorted_model[index].subpath.startswith(item["subpath"])
else: else:
assert sorted_model[index].subpath == item['subpath'] assert sorted_model[index].subpath == item["subpath"]
for key, value in item['data'].items(): for key, value in item["data"].items():
assert getattr(sorted_model[index].data, key) == value assert getattr(sorted_model[index].data, key) == value