Skip to content

Commit

Permalink
Update CI configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
SethMMorton committed Oct 23, 2024
1 parent eb854fe commit e8dce42
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 27 deletions.
46 changes: 36 additions & 10 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ jobs:
python-version: 3.8

- name: Install deps
run: |
pip install black clang-format
run: python -m pip install ruff clang-format

- name: Run formatting checks
run: python dev/formatting.py --check
Expand All @@ -41,11 +40,11 @@ jobs:
with:
python-version: 3.8

- name: Install Flake8
run: pip install flake8 flake8-import-order flake8-bugbear pep8-naming
- name: Install ruff
run: python -m pip install ruff

- name: Run Flake8
run: flake8
- name: Run ruff
run: ruff check

type-checking:
name: Type Checking
Expand All @@ -64,7 +63,7 @@ jobs:

- name: Run MyPy
run: |
python setup.py install
python -m pip install --editable .
mypy --strict tests
package-validation:
Expand All @@ -80,10 +79,37 @@ jobs:
python-version: 3.8

- name: Install Validators
run: pip install twine check-manifest
run: python -m pip install twine build

- name: Run Validation
run: |
check-manifest --ignore ".github*,*.md,.coveragerc"
python setup.py sdist
python -m build
twine check dist/*
warning-free-compilation:
name: Warning-free Compilation
runs-on: ${{ matrix.os }}
strategy:
matrix:
# Note, clang is used on macos, even though it says gcc
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: "3.12"

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build
- name: Set Environment
run: echo FN_WARNINGS_AS_ERRORS=1 >> $GITHUB_ENV

- name: Compile
run: python -m build --wheel
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Build Source Distribution
if: matrix.os == 'ubuntu-latest' && matrix.arch != 'aarch64'
run: python setup.py sdist --format=gztar
run: python -m build --sdist

- name: Build Wheel
run: python -m cibuildwheel --output-dir dist
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.7, 3.8, 3.9, "3.10", "3.11", "3.12"]
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]
# Note, clang is used on macos, even though it says gcc
os: [ubuntu-latest, windows-latest, macos-latest]

Expand All @@ -31,26 +31,26 @@ jobs:
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
python -m pip install setuptools
python -m pip install build setuptools setuptools_scm
python -m pip install pytest pytest-faulthandler hypothesis typing_extensions numpy
- name: Patch Doctests
run: python dev/patch_doctest.py

- name: Set CFLAGS
- name: Set Environment for Coverage
if: matrix.os == 'ubuntu-latest'
# Need no optimization for code coverage
run: echo CFLAGS="--coverage -Og" >> $GITHUB_ENV
# Set flags for coverage
run: echo FN_COV=1 >> $GITHUB_ENV

- name: Build and Install Using pip
- name: Build and Install
if: matrix.os != 'ubuntu-latest'
run: |
python setup.py build # to see compilation output
python -m pip install --editable .
- name: Build and Install Using setuptools
- name: Build and Install With Coverage
if: matrix.os == 'ubuntu-latest'
run: python setup.py install # to see the compilation output and get coverage
# We'll use this legacy method till coverage is supported with pip
run: python setup.py install

- name: Run Doctests
run: python -m doctest fastnumbers
Expand All @@ -69,7 +69,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9, "3.10", "3.11", "3.12"]
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]

steps:
- name: Checkout Code
Expand All @@ -92,7 +92,7 @@ jobs:
name: Tests on aarch64
strategy:
matrix:
pyver: [cp37-cp37m, cp38-cp38, cp39-cp39, cp310-cp310, cp311-cp311, cp312-cp312]
pyver: [cp38-cp38, cp39-cp39, cp310-cp310, cp311-cp311, cp312-cp312]
runs-on: ubuntu-latest
env:
py: /opt/python/${{ matrix.pyver }}/bin/python
Expand Down
14 changes: 9 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from setuptools import Extension, setup

# Compilation arguments are platform-dependent
link_args = ["-lm"]
if sys.platform == "win32":
compile_args = [
"/std:c++17",
Expand All @@ -19,7 +20,7 @@
if "FN_DEBUG" in os.environ or "FN_COV" in os.environ:
compile_args.append("/Od")
compile_args.append("/Z7")
if "FN_WARNINGS_AS_ERRORS":
if "FN_WARNINGS_AS_ERRORS" in os.environ:
compile_args.append("/WX")
else:
compile_args = [
Expand All @@ -33,17 +34,20 @@
if "FN_DEBUG" in os.environ or "FN_COV" in os.environ:
compile_args.append("-Og")
compile_args.append("-g")
if "FN_WARNINGS_AS_ERRORS":
if "FN_COV" in os.environ:
compile_args.append("--coverage")
link_args.append("--coverage")
if "FN_WARNINGS_AS_ERRORS" in os.environ:
compile_args.append("-Werror")


ext = [
Extension(
"fastnumbers.fastnumbers",
sorted(pathlib.Path("src/cpp").glob("*.cpp")),
include_dirs=[pathlib.Path("include").resolve()],
sorted(map(str, pathlib.Path("src/cpp").glob("*.cpp"))),
include_dirs=[str(pathlib.Path("include").resolve())],
extra_compile_args=compile_args,
extra_link_args=["-lm"],
extra_link_args=link_args,
)
]

Expand Down
3 changes: 3 additions & 0 deletions src/cpp/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,4 +460,7 @@ NumberFlags CharacterParser::get_number_type() const noexcept
case StringType::INTLIKE_FLOAT:
return flag_wrap(NumberType::Float | NumberType::IntLike);
}

/* Is not reachable, but silences compiler warnings. */
return NumberType::INVALID;
}
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ commands =

# Check code quality.
[testenv:lint]
setenv =
FN_WARNINGS_AS_ERRORS=1
deps =
ruff
clang-format
Expand Down

0 comments on commit e8dce42

Please sign in to comment.