diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml index 95ae7fb3..27c7d509 100644 --- a/.github/workflows/cd.yaml +++ b/.github/workflows/cd.yaml @@ -8,109 +8,73 @@ on: - '*' workflow_dispatch: -permissions: - contents: write - jobs: - build: + build_wheels: + name: Build wheels strategy: + fail-fast: false matrix: - # this should be kept in sync with ci.yaml - python-version: ["3.8", "3.9", "3.10", "3.11"] - include: - - python-version: "3.8" - boost-version: "1.75.0" - platform-version: manylinux_2_27_x86_64 - image-version: conanio/gcc7:latest - - python-version: "3.9" - boost-version: "1.75.0" - platform-version: manylinux_2_27_x86_64 - image-version: conanio/gcc7:latest - - python-version: "3.10" - boost-version: "1.81.0" - platform-version: manylinux_2_31_x86_64 - image-version: conanio/gcc10:latest - - python-version: "3.11" - boost-version: "1.81.0" - platform-version: manylinux_2_31_x86_64 - image-version: conanio/gcc10:latest - runs-on: ubuntu-latest + os: [ ubuntu-latest, windows-latest, macos-latest ] + runs-on: ${{ matrix.os }} steps: - - name: Setup docker buildx - id: buildx - uses: docker/setup-buildx-action@v2 + - name: Checkout Code + uses: actions/checkout@v4 - - name: Create build container - uses: docker/build-push-action@v3 + - uses: actions/setup-python@v4 with: - builder: ${{ steps.buildx.outputs.name }} - file: .github/conan_dockerfile/Dockerfile - tags: lanelet2_conan_with_pip_wheel - load: true - target: lanelet2_conan_with_pip_wheel - build-args: | - FROM=${{ matrix.image-version }} - PY_VERSION=${{ matrix.python-version }} - PLATFORM=${{ matrix.platform-version }} - CONAN_ARGS=--require-override=boost/${{ matrix.boost-version }} + python-version: '3.10' - - name: Create output directory - run: mkdir -p ${{ github.workspace }}/output + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -r requirements.txt - - name: Package lanelet2 in build container - uses: addnab/docker-run-action@v3 - with: - image: lanelet2_conan_with_pip_wheel - shell: bash - options: -v ${{ github.workspace }}/dist:/dist - run: | - set -e - # set env variables - export HOME=/home/conan - - # copy wheel to dist directory - sudo cp -r $HOME/dist/* /dist + - name: Create Conan build + run: | + conan profile detect --force + conan install . --output-folder=build --build=missing - - name: Store wheel + - name: Install cibuildwheel + run: python -m pip install cibuildwheel==2.16.2 + + - name: Build wheels + run: python -m cibuildwheel --output-dir wheelhouse + + - name: Upload artifacts uses: actions/upload-artifact@v3 with: - name: dist - path: dist/ + path: ./wheelhouse/*.whl - test: - needs: build - strategy: - matrix: - # test only on currently supported version - python-version: ["3.8", "3.9", "3.10", "3.11"] - os: ["ubuntu-22.04", "ubuntu-20.04"] - runs-on: ${{ matrix.os }} + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest steps: - - name: Restore wheel - uses: actions/download-artifact@v3 - with: - name: dist - path: dist/ - - name: Setup Python - uses: actions/setup-python@v4 + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Build sdist + run: pipx run build --sdist + + - uses: actions/upload-artifact@v3 with: - python-version: ${{ matrix.python-version }} - - name: Install wheel - # use dist/ directory as package source instead of pypi.org - run: pip install lanelet2 --no-index --find-links dist/ - - name: Test wheel - run: python -c "import lanelet2; assert lanelet2.core.Point2d(0, 0, 0) is not None" + path: dist/*.tar.gz publish: + name: Publish if: contains(github.ref, 'refs/tags/') runs-on: ubuntu-latest - needs: [build, test] + needs: [ build_wheels, build_sdist ] + environment: pypi + permissions: + id-token: write + contents: write + steps: - - name: Restore wheel + - name: Restore artifacts uses: actions/download-artifact@v3 with: - name: dist - path: dist/ + name: artifact + path: dist - name: Release uses: softprops/action-gh-release@v1 @@ -118,7 +82,4 @@ jobs: files: dist/* - name: Publish package to PyPI - if: github.repository == 'fzi-forschungszentrum-informatik/Lanelet2' - uses: pypa/gh-action-pypi-publish@release/v1 - with: - password: ${{ secrets.PYPI_API_TOKEN }} + uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file diff --git a/conanfile.py b/conanfile.py index 7f2b5587..b8c194e4 100644 --- a/conanfile.py +++ b/conanfile.py @@ -24,6 +24,34 @@ class Lanelet2Conan(ConanFile): "boost/*:shared": True, "boost/*:without_python": False, } + without_boost_components = [ + "chrono", + "container", + "context", + "contract", + "coroutine", + "date_time", + "exception", + "fiber", + "graph", + "iostreams", + "json", + "locale", + "log", + "math", + "mpi", + "nowide", + "random", + "regex", + "stacktrace", + "test", + "thread", + "timer", + "type_erasure", + "url", + "wave", + ] + default_options.update((f"boost/*:without_{component}", True) for component in without_boost_components) proj_list = [ "lanelet2_core", diff --git a/pyproject.toml b/pyproject.toml index 2fee5005..70bc2f43 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,6 +30,9 @@ classifiers = [ "Operating System :: POSIX :: Linux", ] +[project.optional-dependencies] +pytest = ["pytest"] + [tool.scikit-build] build-dir = "build/{wheel_tag}" cmake.args = ["--preset conan-release"] @@ -44,4 +47,8 @@ input = "lanelet2_python/src/lanelet2/__init__.py" [[tool.scikit-build.overrides]] if.platform-system = "win32" -cmake.args = ["--preset conan-default"] \ No newline at end of file +cmake.args = ["--preset conan-default"] + +[tool.cibuildwheel] +test-requires = "pytest" +test-command = "pytest lanelet2_python/test" \ No newline at end of file