Skip to content

Modernize project for compatibility with uv #206

Modernize project for compatibility with uv

Modernize project for compatibility with uv #206

Workflow file for this run

---
name: Test & deploy
on:
push:
branches: [main]
pull_request:
release:
types: [prereleased, released]
jobs:
test_repo:
name: Test on ${{ matrix.os }} w/ Py${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ['3.10', '3.11', '3.12', '3.13']
os: [ubuntu-latest, macos-latest]
fail-fast: false
steps:
- name: Install the latest version of uv.
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install non-python build dependencies
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo apt-get update && sudo apt-get install -yq \
apt-transport-https \
bison \
build-essential \
cmake \
flex \
libbz2-dev \
ninja-build \
software-properties-common
fi
- uses: actions/checkout@v4
with:
submodules: true
- name: Install package using uv
run: uv sync
- name: Run tests using uv
run: uv run --no-sync pytest --import-mode=append -svx
# test_sdist_3_10:
# name: Test sdist on MacOS w/ Py3.10
# needs: test_repo
# runs-on: macos-latest
# steps:
# - name: Setup Python 3.10 env
# uses: actions/setup-python@v5
# with:
# python-version: '3.10'
# - name: Ensure latest pip, wheel & setuptools
# run: python -m pip install -q --upgrade pip wheel setuptools
# - name: Install dependencies
# run: |
# brew install cmake
# - uses: actions/checkout@v4
# with:
# submodules: true
# - name: Generate sdist
# run: |
# NLE_RELEASE_BUILD=1 python setup.py sdist
# - name: Install from sdist
# run: |
# SDISTNAME=$(ls dist/)
# MODE="[agent]"
# pip install "dist/$SDISTNAME$MODE"
# - name: Run tests outside repo dir
# run: |
# REPONAME=$(basename $PWD)
# pushd ..
# python -m pytest --import-mode=append -svx $REPONAME/nle/tests
# popd
# test_sdist_3_13:
# name: Test sdist on MacOS w/ Py3.13
# needs: test_repo
# runs-on: macos-latest
# steps:
# - name: Setup Python 3.13 env
# uses: actions/setup-python@v5
# with:
# python-version: 3.13
# - name: Ensure latest pip, wheel & setuptools
# run: python -m pip install -q --upgrade pip wheel setuptools
# - name: Install dependencies
# run: |
# brew install cmake
# - uses: actions/checkout@v4
# with:
# submodules: true
# - name: Generate sdist
# run: |
# NLE_RELEASE_BUILD=1 python setup.py sdist
# - name: Install from sdist
# run: |
# SDISTNAME=$(ls dist/)
# MODE="[agent]"
# pip install "dist/$SDISTNAME$MODE"
# - name: Run tests outside repo dir
# run: |
# REPONAME=$(basename $PWD)
# pushd ..
# python -m pytest --import-mode=append -svx $REPONAME/nle/tests
# popd
# - name: Save sdist
# if: ${{ always() }}
# uses: actions/upload-artifact@v4
# with:
# name: python-sdist
# path: dist/
# build_wheels:
# name: Build wheels on Ubuntu
# needs: test_repo
# runs-on: ${{ matrix.os }} # Can be also run for macOS
# strategy:
# matrix:
# os: [ubuntu-latest, ubuntu-24.04-arm]
# steps:
# - uses: actions/checkout@v4
# with:
# submodules: recursive
# - name: Build wheels
# if: github.event_name != 'release'
# uses: pypa/[email protected] # The main configuration is in pyproject.toml
# env:
# CIBW_BUILD: "cp313-manylinux*" # Build only python 3.13 wheels for testing
# # Increase verbosity to see what's going on in the build in case of failure
# CIBW_BUILD_VERBOSITY: 3
# CIBW_REPAIR_WHEEL_COMMAND_LINUX: >
# auditwheel show {wheel} && auditwheel repair -w {dest_dir} {wheel}
# - name: Build release wheels
# if: github.event_name == 'release' && (github.event.action == 'released' || github.event.action == 'prereleased')
# uses: pypa/[email protected] # The main configuration is in pyproject.toml
# env:
# # Set NLE_RELEASE_BUILD to 1 to build release wheels
# CIBW_ENVIRONMENT: "NLE_RELEASE_BUILD=1"
# - name: Save wheels
# uses: actions/upload-artifact@v4
# with:
# name: python-wheels-${{ matrix.os }}
# path: ./wheelhouse/*.whl
# test_manylinux_3_13:
# name: Test manylinux wheel on Ubuntu w/ Py3.13
# needs: build_wheels
# runs-on: ubuntu-latest
# steps:
# - name: Setup Python 3.13 env
# uses: actions/setup-python@v5
# with:
# python-version: 3.13
# - name: Ensure latest pip, wheel & setuptools
# run: python -m pip install -q --upgrade pip wheel tools
# - uses: actions/checkout@v4
# with:
# submodules: true
# - name: Get wheels artifacts
# uses: actions/download-artifact@v4
# with:
# name: python-wheels-ubuntu-latest
# path: dist
# - name: Install from wheel # Install wheel mathcing the Python version and architecture
# run: |
# WHEELNAME=$(ls dist/*313*manylinux*x86_64*.whl)
# MODE="[all]"
# pip install "$WHEELNAME$MODE"
# - name: Run tests outside repo dir
# run: |
# REPONAME=$(basename $PWD)
# pushd ..
# python -m pytest --import-mode=append -svx $REPONAME/nle/tests
# popd
# # Use prereleases to test publish the artefacts to testpypi
# test_deploy:
# name: Deploy artefacts to testpypi
# needs: [test_sdist_3_13, test_manylinux_3_13]
# if: github.event_name == 'release' && github.event.action == 'prereleased'
# runs-on: ubuntu-latest
# environment:
# name: prerelease
# url: https://testpypi.org/p/nle
# permissions:
# id-token: write
# steps:
# - uses: actions/checkout@v4
# - name: Check version matches release tag
# run: |
# echo "v$(cat version.txt)"
# echo "${{ github.event.release.tag_name }}"
# [[ "${{ github.event.release.tag_name }}" == "v$(cat version.txt)" ]]
# - name: Get sdist artifact # Get sdist artifact from the test_sdist job
# uses: actions/download-artifact@v4
# with:
# name: python-sdist
# path: dist
# - name: Get wheels artifacts # Get x86 wheels artifacts from the build_wheels job
# uses: actions/download-artifact@v4
# with:
# name: python-wheels-ubuntu-latest
# path: dist
# - name: Get wheels artifacts # Get aarch64 wheels artifacts from the build_wheels job
# uses: actions/download-artifact@v4
# with:
# name: python-wheels-ubuntu-24.04-arm
# path: dist
# - name: Report dist contents
# run: |
# pwd
# ls -R
# ls -al .
# ls -R dist/
# ls -al dist/
# - name: Publish package to TestPyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# repository-url: https://test.pypi.org/legacy/
# # TODO move this to separate workflow whenever github decides to provide basic
# # functionalities like workflow dependencies :|
# deploy_sdist:
# name: Deploy sdist to pypi
# needs: [test_sdist_3_13, test_manylinux_3_13]
# if: github.event_name == 'release' && github.event.action == 'released'
# runs-on: ubuntu-latest
# environment:
# name: release
# url: https://pypi.org/p/nle
# permissions:
# id-token: write
# steps:
# - uses: actions/checkout@v4
# - name: Check version matches release tag
# run: |
# echo "v$(cat version.txt)"
# echo "${{ github.event.release.tag_name }}"
# [[ "${{ github.event.release.tag_name }}" == "v$(cat version.txt)" ]]
# - name: Get sdist artifact # Get sdist artifact from the test_sdist job
# uses: actions/download-artifact@v4
# with:
# name: python-sdist
# path: dist
# - name: Get wheels artifacts # Get x86 wheels artifacts from the build_wheels job
# uses: actions/download-artifact@v4
# with:
# name: python-wheels-ubuntu-latest
# path: dist
# - name: Get wheels artifacts # Get aarch64 wheels artifacts from the build_wheels job
# uses: actions/download-artifact@v4
# with:
# name: python-wheels-ubuntu-24.04-arm
# path: dist
# - name: Report dist contents
# run: |
# pwd
# ls -R
# ls -al .
# ls -R dist/
# ls -al dist/
# # NOTE: we assume that dist/ contains a built sdist and wheels (and only that).
# # Yes, we could be more defensively, but What Could Go Wrong?™
# - name: Publish package to PyPI
# uses: pypa/gh-action-pypi-publish@release/v1