Skip to content

Commit

Permalink
Improve build process (#2)
Browse files Browse the repository at this point in the history
* Try matrix build

* Remove windows

* Do not execute benchmarks by default
  • Loading branch information
alesanfra authored Feb 26, 2022
1 parent 6f97a7e commit 61834cc
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 32 deletions.
37 changes: 6 additions & 31 deletions .github/workflows/build_and_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ on:
pull_request:

jobs:
macos:
runs-on: macos-latest
build:
strategy:
matrix:
python-version: [ "3.6", "3.7", "3.8", "3.9", "3.10" ]
os: [ ubuntu-latest, macos-latest]
name: Build on ${{ matrix.os }} - python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Setup python
Expand All @@ -25,35 +27,8 @@ jobs:
- name: Build wheels
uses: messense/maturin-action@v1
with:
args: --release --strip --universal2 --out dist --no-sdist
- name: Install built wheel
run: |
pip install lychrel --no-index --find-links dist --force-reinstall
python -I -c "import lychrel"
- name: Run tests
run: |
pip install -r requirements-dev.txt
pytest
- name: Upload wheels
uses: actions/upload-artifact@v2
with:
name: wheels
path: dist
linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: "3.10"
architecture: x64
- name: Build Wheels
uses: messense/maturin-action@v1
with:
target: x86_64
manylinux: auto
args: --release --strip --out dist --no-sdist
args: -i python${{ matrix.python-version }} --release --strip --universal2 --out dist --no-sdist
- name: Install built wheel
run: |
pip install lychrel --no-index --find-links dist --force-reinstall
Expand All @@ -71,7 +46,7 @@ jobs:
release:
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: [ macos, linux ]
needs: [ build ]
steps:
- uses: actions/download-artifact@v2
with:
Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@ line_length = 79

[tool.pytest.ini_options]
minversion = "6.0"
addopts = "-v"
addopts = "-v -m \"not benchmark\""
testpaths = ["tests"]
markers = [
"benchmark: perform benchmarks against an equivalent python implementation",
]
1 change: 1 addition & 0 deletions tests/test_collatz.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def test_collatz_zero():
lychrel.collatz(0)


@pytest.mark.benchmark
def test_benchmark_collatz():
n = 123456789
start_rs = time.time()
Expand Down
1 change: 1 addition & 0 deletions tests/test_fibonacci.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def test_fibonacci(p, q):
assert lychrel.fibonacci(1000, p, q) == lychrel.py.fibonacci(1000, p, q)


@pytest.mark.benchmark
def test_benchmark_fibonacci():
start_rs = time.time()

Expand Down
1 change: 1 addition & 0 deletions tests/test_lychrel_numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def test_is_lychrel_candidate(number, expected_result):
assert lychrel.is_lychrel_candidate(number) is expected_result


@pytest.mark.benchmark
@pytest.mark.parametrize("number", LYCHREL_NUMBERS)
def test_benchmark_lychrel_implementation(number):
start_rs = time.time()
Expand Down

0 comments on commit 61834cc

Please sign in to comment.