Skip to content

Commit

Permalink
Merge pull request #5 from karlosss/improve-cicd
Browse files Browse the repository at this point in the history
improve cicd
  • Loading branch information
karlosss authored Oct 20, 2024
2 parents 6b5e014 + fca2f15 commit 94fe81a
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ jobs:
path: dist/*.tar.gz

build_wheels:
name: Build wheels on ${{ matrix.os }}
name: Build wheels (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# os: [ubuntu-latest, macos-13, macos-14] currently only works on Linux
os: [ubuntu-latest]
os: [ ubuntu-latest ]

steps:
- name: Checkout the repository
Expand All @@ -60,11 +60,6 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: Download artifacts
uses: actions/download-artifact@v4
with:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
name: Build
name: Check PR

on:
pull_request:
branches:
- "**"
- master

jobs:
build_wheels:
name: Build wheels
runs-on: ubuntu-latest
name: Build wheels (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]

steps:
- name: Checkout the repository
Expand All @@ -22,13 +26,19 @@ jobs:
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: cibw-wheels-ubuntu-latest
name: cibw-wheels-${{ matrix.os }}
path: wheelhouse/*.whl

run_tests:
name: Run tests locally
runs-on: ubuntu-latest
name: Run tests locally (${{ matrix.os }}, ${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
needs: build_wheels
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- name: Checkout the repository
uses: actions/checkout@v4
Expand All @@ -38,7 +48,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version: ${{ matrix.python-version }}

- name: Download artifacts
uses: actions/download-artifact@v4
Expand All @@ -51,7 +61,7 @@ jobs:
run: pip install wheel

- name: Install locally
run: pip install "$(echo dist/swisspair*cp312*manylinux*x86_64*.whl)"[test]
run: pip install "$(echo dist/swisspair*cp"$(tr -d . <<< "${{ matrix.python-version }}")"*manylinux*x86_64*.whl)"[test]

- name: Run tests
run: pytest
Original file line number Diff line number Diff line change
Expand Up @@ -50,29 +50,20 @@ jobs:
path: dist/*.tar.gz

build_wheels:
name: Build wheels on ${{ matrix.os }}
name: Build wheels (${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: generate_version
strategy:
fail-fast: false
matrix:
# os: [ubuntu-latest, macos-13, macos-14] currently only works on Linux
os: [ubuntu-latest]
os: [ ubuntu-latest ]

steps:
- name: Checkout the repository
uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Download version
uses: actions/download-artifact@v4
with:
name: VERSION
path: .

- name: Update version
run: sed -i "s/^version.*\$/version = \"$(cat VERSION)\"/g" pyproject.toml

- name: Build wheels
uses: pypa/[email protected]

Expand Down Expand Up @@ -108,9 +99,14 @@ jobs:
password: ${{ secrets.TESTPYPI_TOKEN }}

install_and_run_tests:
name: Install package from Test PyPI and run tests
name: Install package from Test PyPI and run tests (${{ matrix.os }}, ${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
needs: publish_test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]

steps:
- name: Checkout the tests
Expand All @@ -119,7 +115,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
python-version: ${{ matrix.python-version }}

- name: Download version
uses: actions/download-artifact@v4
Expand All @@ -128,7 +124,7 @@ jobs:
path: .

- name: Wait for package and install it
run: while ! pip install --extra-index-url https://test.pypi.org/simple/ --no-cache-dir swisspair[test]==$(cat VERSION); do sleep 5; done
run: cnt=0; while ! pip install --extra-index-url https://test.pypi.org/simple/ --no-cache-dir swisspair[test]==$(cat VERSION); if [[ $cnt -eq 10 ]]; then echo "Package unavailable"; exit 1; fi; do sleep 5; cnt=$((cnt+1)); done

- name: Run tests
run: pytest
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ build-backend = "scikit_build_core.build"

[project]
name = "swisspair"
# version is only for local development, it gets set automatically in CI/CD
version = "0.0.13"
author = "Karel Jilek"
author_email = "[email protected]"
Expand Down
3 changes: 2 additions & 1 deletion src/swisspair/interface.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from dataclasses import dataclass, field
from typing import Optional

from ._swisspair import Player as _Player, Match as _Match, create_matches as _create_matches

Expand Down Expand Up @@ -26,7 +27,7 @@ def decompile(player: _Player) -> "Player":
@dataclass
class Match:
p1: Player
p2: Player | None
p2: Optional[Player]

@staticmethod
def decompile(match: _Match) -> "Match":
Expand Down

0 comments on commit 94fe81a

Please sign in to comment.