Commit c821fa00 authored by Yamada Hiroyuki's avatar Yamada Hiroyuki
Browse files

Merge branch 'Feature_GitHubActions'

parents d49255d3 078780c7
Loading
Loading
Loading
Loading
Loading
+21 −40
Original line number Diff line number Diff line
@@ -20,37 +20,24 @@ jobs:
    strategy:
      matrix:
        runs-on: [ubuntu-latest, macos-13, macos-14, windows-latest]
        python: ['3.8', '3.9', '3.10', '3.11', '3.12']
        numpy: ["numpy<2.0.0", "numpy>=2.0.0rc2"]
        gym: ['gym', 'gymnasium']
        exclude:
          - python: "3.8"
            numpy: "numpy>=2.0.0rc2"
      fail-fast: false
    runs-on: ${{ matrix.runs-on }}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python }}
      - name: Get pip cache dir
        id: pip-cache
        run: echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
      - name: Install Hatch
        uses: pypa/hatch@install
      - name: Run Test
        run: |
          hatch run test:install
          hatch run test-38:install
          hatch run test:run-cov
          hatch run test-38:run-cov
          hatch run cov:combine
          echo '## Test Coverage on ${{ matrix.runs-on }}' >> $GITHUB_STEP_SUMMARY
          echo '```' >> $GITHUB_STEP_SUMMARY
          hatch -q run cov:report >> $GITHUB_STEP_SUMMARY
          echo '```' >> $GITHUB_STEP_SUMMARY
        shell: bash
      - name: pip cache
        uses: actions/cache@v4
        with:
          path: ${{ steps.pip-cache.outputs.dir }}
          key: ${{ runner.os }}-pip${{ matrix.python }}
          restore-keys: ${{ runner.os }}-pip${{ matrix.python }}
      - name: Install NumPy
        run: pip install '${{ matrix.numpy }}'
      - name: Install cpprb
        run: pip install '.[all]'
      - name: Install Gym(nasium)
        run: pip install ${{ matrix.gym }}
      - run: python -m unittest discover . '*.py'
        working-directory: './test'
  build_winmac:
    needs: readme
    strategy:
@@ -68,16 +55,7 @@ jobs:
            3.10
            3.11
            3.12
      - name: Get pip cache dir
        id: pip-cache
        run: echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
        shell: bash
      - name: pip cache
        uses: actions/cache@v4
        with:
          path: ${{ steps.pip-cache.outputs.dir }}
          key: ${{ runner.os }}-pip
          restore-keys: ${{ runner.os }}-pip
          cache: 'pip'
      - uses: actions/download-artifact@v4
        with:
          name: README
@@ -93,9 +71,10 @@ jobs:
          name: dist-${{ matrix.runs-on }}
          path: dist
      - name: Upload to PyPI
        run: python -m twine upload -u __token__ -p ${{ secrets.pypi_password }} --skip-existing dist/cpprb-*
        run: |
          pip install twine
          python -m twine upload -u __token__ -p ${{ secrets.pypi_password }} --skip-existing dist/cpprb-*
        if: github.event_name == 'push' && startsWith(github.event.ref,'refs/tags/v')
        continue-on-error: true
  build_targz:
    needs: readme
    runs-on: ubuntu-latest
@@ -104,6 +83,7 @@ jobs:
      - uses: actions/setup-python@v5
        with:
          python-version: '3.8'
          cache: 'pip'
      - uses: actions/download-artifact@v4
        with:
          name: README
@@ -114,7 +94,7 @@ jobs:
        with:
          name: dist-sdist
          path: dist
      - run: pip install twine
      - run: pip --disable-pip-version-check install twine
      - name: Upload to PyPI
        run: python -m twine upload -u __token__ -p ${{ secrets.pypi_password }} --skip-existing dist/cpprb-*tar.gz
        if: github.event_name == 'push' && startsWith(github.event.ref,'refs/tags/v')
@@ -128,6 +108,7 @@ jobs:
      - uses: actions/setup-python@v5
        with:
          python-version: '3'
          cache: 'pip'
      - uses: docker/setup-qemu-action@v3
        if: ${{ matrix.arch }} == "aarch64"
        with:
@@ -151,7 +132,7 @@ jobs:
        with:
          name: dist-manylinux-${{ matrix.arch }}
          path: dist
      - run: pip install twine
      - run: pip --disable-pip-version-check install twine
      - name: Upload to PyPI
        run: python -m twine upload -u __token__ -p ${{ secrets.pypi_password }} --skip-existing dist/cpprb-*
        if: github.event_name == 'push' && startsWith(github.event.ref,'refs/tags/v')
+2 −4
Original line number Diff line number Diff line
@@ -6,10 +6,8 @@ dist
*.c
*.html
*.md
cpprb/PyReplayBuffer.cpp
cpprb/PySegmentTree.cpp
cpprb/VectorWrapper.cpp
cpprb/experimental/*.cpp
src/cpprb/PyReplayBuffer.cpp
src/cpprb/VectorWrapper.cpp
test/ReplayBuffer
test/SegmentTree
public
+2 −2
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ FROM quay.io/pypa/manylinux2014_${arch} AS manylinux
WORKDIR /work
COPY --from=README /work/README.md /work/README.md
COPY pyproject.toml setup.py LICENSE MANIFEST.in .
COPY cpprb cpprb/
COPY src src/
ARG ON_CI
RUN ON_CI=${ON_CI} /opt/python/cp38-cp38/bin/pip wheel . -w /work/wheel --no-deps && \
    ON_CI=${ON_CI} /opt/python/cp39-cp39/bin/pip wheel . -w /work/wheel --no-deps && \
@@ -25,7 +25,7 @@ WORKDIR /work
RUN --mount=type=cache,target=/root/.cache/pip \
    pip install hatch
COPY pyproject.tom setup.py LICENSE MANIFEST.in .
COPY cpprb cpprb/
COPY src src/
RUN hatch env create test
COPY test test/
RUN hatch run test:run-cov && \
+6 −2
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ dependencies = [
DEBUG_CPPRB = "1"

[tool.hatch.envs.test.scripts]
install = "pip install -e ."
install = "pip install . {args}"
run = "python -m unittest discover test"
run-cov = "coverage run -m unittest discover test"

@@ -84,9 +84,13 @@ plugins = ["Cython.Coverage"]
parallel = true
relative_files = true
omit = ["test/test_*.py"]
source = ["cpprb"]

[tool.coverage.paths]
source = ["cpprb/"]
source = [
    "src/cpprb",
    "*/site-packages/cpprb",
]


[tool.coverage.report]
+4 −3
Original line number Diff line number Diff line
@@ -39,14 +39,14 @@ elif (sys.version_info < (3, 9)) and not arm_mac:
else:
    setup_requires.append("numpy")

rb_source = "cpprb/PyReplayBuffer"
rb_source = "src/cpprb/PyReplayBuffer"
cpp_ext = ".cpp"
pyx_ext = ".pyx"

extras = {
    "gym": ["matplotlib", "pyvirtualdisplay"],
    "api": ["sphinx", "sphinx_rtd_theme", "sphinx-automodapi"],
    "dev": ["coverage", "cython", "scipy", "twine", "unittest-xml-reporting"],
    "dev": ["coverage[toml]", "cython", "scipy", "twine", "unittest-xml-reporting"],
}

if sys.version_info < (3, 12):
@@ -100,7 +100,7 @@ ext = [["cpprb", "PyReplayBuffer"], ["cpprb", "VectorWrapper"]]
ext_modules = [
    Extension(
        ".".join(e),
        sources=["/".join(e) + suffix],
        sources=["src/" + "/".join(e) + suffix],
        extra_compile_args=extra_compile_args,
        extra_link_args=extra_link_args,
        language="c++",
@@ -160,6 +160,7 @@ setup(
        "Change Log": "https://ymd_h.gitlab.io/cpprb/changelog/",
        "Bug Report & QA": "https://github.com/ymd-h/cpprb/discussions",
    },
    package_dir={"": "src"},
    ext_modules=ext_modules,
    include_dirs=["cpprb"],
    packages=["cpprb"],
Loading