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 0a5926a
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 46 deletions.
62 changes: 44 additions & 18 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
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 @@ -34,28 +33,28 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
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
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.8

Expand All @@ -64,26 +63,53 @@ jobs:

- name: Run MyPy
run: |
python setup.py install
python -m pip install --editable .
mypy --strict tests
package-validation:
name: Package Validation
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
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@v4

- name: Set up Python 3.12
uses: actions/setup-python@v5
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
8 changes: 4 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

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

Expand All @@ -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 All @@ -62,7 +62,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Download artifacts
uses: actions/download-artifact@v3
Expand Down
40 changes: 21 additions & 19 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,43 @@ 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]

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

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
python -m pip install setuptools
python -m pip install pytest pytest-faulthandler hypothesis typing_extensions numpy
- name: Patch Doctests
run: python dev/patch_doctest.py
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 -m pip install "setuptools>=64" "setuptools-scm>=8.0"
python setup.py install
- name: Run Doctests
run: python -m doctest fastnumbers
Expand All @@ -60,23 +61,24 @@ jobs:

- name: Upload to CodeCov
if: matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
gcov: true
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true

test_no_numpy:
name: Try Without NumpPy
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
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -92,15 +94,15 @@ 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
img: quay.io/pypa/manylinux2014_aarch64

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

- name: Set up QEMU
id: qemu
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 0a5926a

Please sign in to comment.