Skip to content

Commit

Permalink
CI: Add testing for Musl Linux (pandas-dev#52953)
Browse files Browse the repository at this point in the history
* CI: Add testing for Musl Linux

* Install locale

* Add loc path

* set tz too

* Skip one test for musl, use more standard tz for musl

* Correct skips for MUSL

* Do less stuff during install

* syntax error
  • Loading branch information
mroeschke authored and topper-123 committed May 7, 2023
1 parent f5bb324 commit 2a0544e
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 2 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,49 @@ jobs:
group: ${{ github.event_name == 'push' && github.run_number || github.ref }}-32bit
cancel-in-progress: true

Linux-Musl:
runs-on: ubuntu-22.04
container:
image: quay.io/pypa/musllinux_1_1_x86_64
steps:
- name: Checkout pandas Repo
# actions/checkout does not work since it requires node
run: |
git config --global --add safe.directory $PWD
if [ $GITHUB_EVENT_NAME != pull_request ]; then
git clone --recursive --branch=$GITHUB_REF_NAME https://github.com/${GITHUB_REPOSITORY}.git $GITHUB_WORKSPACE
git reset --hard $GITHUB_SHA
else
git clone --recursive https://github.com/${GITHUB_REPOSITORY}.git $GITHUB_WORKSPACE
git fetch origin $GITHUB_REF:my_ref_name
git checkout $GITHUB_BASE_REF
git -c user.email="you@example.com" merge --no-commit my_ref_name
fi
- name: Configure System Packages
run: |
apk update
apk add musl-locales
- name: Build environment
run: |
/opt/python/cp39-cp39/bin/python -m venv ~/virtualenvs/pandas-dev
. ~/virtualenvs/pandas-dev/bin/activate
python -m pip install --no-cache-dir --no-deps -U pip wheel setuptools
python -m pip install --no-cache-dir versioneer[toml] cython numpy python-dateutil pytz pytest>=7.0.0 pytest-xdist>=2.2.0 pytest-asyncio>=0.17 hypothesis>=6.46.1
python setup.py build_ext -q -j$(nproc)
python -m pip install --no-cache-dir --no-build-isolation --no-use-pep517 -e .
python -m pip list --no-cache-dir
- name: Run Tests
run: |
. ~/virtualenvs/pandas-dev/bin/activate
export PANDAS_CI=1
python -m pytest -m 'not slow and not network and not clipboard and not single_cpu' pandas --junitxml=test-data.xml
concurrency:
# https://github.saobby.my.eu.orgmunity/t/concurrecy-not-work-for-push/183068/7
group: ${{ github.event_name == 'push' && github.run_number || github.ref }}-musl
cancel-in-progress: true

python-dev:
# This job may or may not run depending on the state of the next
# unreleased Python version. DO NOT DELETE IT.
Expand Down
2 changes: 2 additions & 0 deletions pandas/compat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from pandas.compat._constants import (
IS64,
ISMUSL,
PY310,
PY311,
PYPY,
Expand Down Expand Up @@ -160,6 +161,7 @@ def get_lzma_file() -> type[pandas.compat.compressors.LZMAFile]:
"pa_version_under9p0",
"pa_version_under11p0",
"IS64",
"ISMUSL",
"PY310",
"PY311",
"PYPY",
Expand Down
3 changes: 3 additions & 0 deletions pandas/compat/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@

import platform
import sys
import sysconfig

IS64 = sys.maxsize > 2**32

PY310 = sys.version_info >= (3, 10)
PY311 = sys.version_info >= (3, 11)
PYPY = platform.python_implementation() == "PyPy"
ISMUSL = "musl" in (sysconfig.get_config_var("HOST_GNU_TYPE") or "")


__all__ = [
"IS64",
"ISMUSL",
"PY310",
"PY311",
"PYPY",
Expand Down
16 changes: 15 additions & 1 deletion pandas/tests/config/test_localization.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
set_locale,
)

from pandas.compat import ISMUSL

import pandas as pd

_all_locales = get_locales()
Expand Down Expand Up @@ -46,7 +48,19 @@ def test_can_set_locale_valid_set(lc_var):
assert before_locale == after_locale


@pytest.mark.parametrize("lc_var", (locale.LC_ALL, locale.LC_CTYPE, locale.LC_TIME))
@pytest.mark.parametrize(
"lc_var",
(
locale.LC_ALL,
locale.LC_CTYPE,
pytest.param(
locale.LC_TIME,
marks=pytest.mark.skipif(
ISMUSL, reason="MUSL allows setting invalid LC_TIME."
),
),
),
)
def test_can_set_locale_invalid_set(lc_var):
# Cannot set an invalid locale.
before_locale = _get_current_locale(lc_var)
Expand Down
9 changes: 8 additions & 1 deletion pandas/tests/tslibs/test_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@
strptime,
)
from pandas._libs.tslibs.parsing import parse_datetime_string_with_reso
from pandas.compat import (
ISMUSL,
is_platform_windows,
)
import pandas.util._test_decorators as td

import pandas._testing as tm


@td.skip_if_windows
@pytest.mark.skipif(
is_platform_windows() or ISMUSL,
reason="TZ setting incorrect on Windows and MUSL Linux",
)
def test_parsing_tzlocal_deprecated():
# GH#50791
msg = "Pass the 'tz' keyword or call tz_localize after construction instead"
Expand Down

0 comments on commit 2a0544e

Please sign in to comment.