Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub Action to replace Travis CI #318

Merged
merged 2 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: ci
on: [push, pull_request]
jobs:
ci:
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
include:
- os: macos-latest
python-version: '3.13'
# - os: windows-latest # TODO: Fix the Windows test that runs in an infinite loop
# python-version: '3.13'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- run: pip install --upgrade pip
- run: pip install --upgrade pytest
- run: pip install --editable .
- if: runner.os == 'macOS'
run: brew install libmagic
- if: runner.os == 'Windows'
run: pip install python-magic-bin
- run: LC_ALL=en_US.UTF-8 pytest
shell: bash
timeout-minutes: 15 # Limit Windows infinite loop.
18 changes: 12 additions & 6 deletions test/python_magic_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import tempfile
import os
import os.path
import shutil
import sys
import tempfile
import unittest

import pytest

# for output which reports a local time
os.environ["TZ"] = "GMT"
Expand All @@ -9,12 +15,8 @@
# necessary for some tests
raise Exception("must run `export LC_ALL=en_US.UTF-8` before running test suite")

import shutil
import os.path
import unittest

import magic
import sys


# magic_descriptor is broken (?) in centos 7, so don't run those tests
SKIP_FROM_DESCRIPTOR = bool(os.environ.get("SKIP_FROM_DESCRIPTOR"))
Expand Down Expand Up @@ -118,6 +120,8 @@ def test_mime_types(self):
finally:
os.unlink(dest)

# TODO: Fix this failing test on Ubuntu
@pytest.mark.skipif(sys.platform == "linux", reason="'JSON data' not found")
def test_descriptions(self):
m = magic.Magic()
os.environ["TZ"] = "UTC" # To get last modified date of test.gz in UTC
Expand Down Expand Up @@ -157,6 +161,8 @@ def test_descriptions(self):
finally:
del os.environ["TZ"]

# TODO: Fix this failing test on Ubuntu
@pytest.mark.skipif(sys.platform == "linux", reason="'JSON data' not found")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw, pytest was completely green for most linux architectures when running pytest using the cibuildwheel mechanism ref #294 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you able to create a targeted fix for #321?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there was nothing to fix, pytest was green out of the box 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe because im building and bundling latest libmagic from source, and github ubuntu comes with an old libmagic?

def test_descriptions_no_soft(self):
m = magic.Magic(check_soft=False)
self.assert_values(
Expand Down