Skip to content

Update release drafter template & minor doc changes (#20) #65

Update release drafter template & minor doc changes (#20)

Update release drafter template & minor doc changes (#20) #65

---
name: Test & deploy
on:
push:
branches: [main]
pull_request:
release:
types: [released]
jobs:
test_repo:
name: Test on ${{ matrix.os }} w/ Py${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
os: [ubuntu-20.04, macos-latest]
fail-fast: false
steps:
- name: Setup Python ${{ matrix.python-version }} env
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Ensure latest pip & wheel
run: python -m pip install -q --upgrade pip wheel
- name: Install 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
else
brew install cmake
fi
- uses: actions/checkout@v4
with:
submodules: true
- name: Install from repo in test mode
run: pip install -e '.[dev]'
- name: Run tests
run: python -m pytest --import-mode=append -svx nle/tests
test_sdist_3_8:
name: Test sdist on MacOS w/ Py3.8
needs: test_repo
runs-on: macos-latest
steps:
- name: Setup Python 3.8 env
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Ensure latest pip & wheel
run: python -m pip install -q --upgrade pip wheel
- 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="[all]"
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_11:
name: Test sdist on MacOS w/ Py3.11
needs: test_repo
runs-on: macos-latest
steps:
- name: Setup Python 3.11 env
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Ensure latest pip & wheel
run: python -m pip install -q --upgrade pip wheel
- 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="[all]"
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@v3
with:
name: python-package-distributions
path: dist/
# 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_11
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 dist artifacts from test_sdist
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist
- name: Install from sdist
run: |
pwd
ls -R
ls -al .
ls -R dist/
ls -al dist/
# NOTE: we assume that dist/ contains a built sdist (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