Skip to content

Commit

Permalink
Merge pull request #364 from MarcCote/add_github_actions
Browse files Browse the repository at this point in the history
Add GitHub actions
  • Loading branch information
MarcCote authored Jan 22, 2025
2 parents 57cc67f + 74e8669 commit 2d17ef1
Show file tree
Hide file tree
Showing 14 changed files with 229 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .azure/pipelines/linux-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
displayName: 'Install dependencies'
- script: |
pip install "textworld[full]>=.dev"
pip install --pre "textworld[full]"
condition: eq(variables.installFromSource, false)
displayName: 'Install a prerelease of TextWorld from PyPi'
Expand Down
2 changes: 1 addition & 1 deletion .azure/pipelines/macos-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
displayName: 'Install dependencies'
- script: |
pip install --use-pep517 "textworld[full]>=.dev"
pip install --pre --use-pep517 textworld[full]
condition: eq(variables.installFromSource, false)
displayName: 'Install a prerelease of TextWorld from PyPi'
Expand Down
12 changes: 5 additions & 7 deletions .azure/pipelines/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ stages:

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.7'
displayName: 'Use Python 3.7'
displayName: 'Use Python'

- script: |
pip install twine
Expand Down Expand Up @@ -39,16 +37,16 @@ stages:
- template: linux-template.yml
parameters:
vmImages: [ 'ubuntu-20.04' ]
pythonVersions: [ '3.7' ]
pythonVersions: [ '3.9' ]
- template: linux-template.yml
parameters:
vmImages: [ 'ubuntu-latest' ]
pythonVersions: [ '3.9' ]
pythonVersions: [ '3.12' ]
- template: macos-template.yml
parameters:
vmImages: [ 'macOS-11' ]
pythonVersions: [ '3.7' ]
pythonVersions: [ '3.9' ]
- template: macos-template.yml
parameters:
vmImages: [ 'macOS-latest' ]
pythonVersions: [ '3.9' ]
pythonVersions: [ '3.12' ]
4 changes: 1 addition & 3 deletions .azure/pipelines/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ jobs:

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.7'
displayName: 'Use Python 3.7'
displayName: 'Use Python'

- script: |
pip install twine
Expand Down
2 changes: 1 addition & 1 deletion .azure/pipelines/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ stages:
- template: macos-template.yml
parameters:
vmImages: [ 'macOS-latest' ]
pythonVersions: [ '3.10' ]
pythonVersions: [ '3.12' ]
30 changes: 0 additions & 30 deletions .github/workflows/prerelease.yml

This file was deleted.

170 changes: 170 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
name: Build and upload to PyPI

on:
workflow_dispatch:
pull_request:
push:
branches:
- main
release:
types:
- published

jobs:
build_wheels:
name: Build wheel for cp${{ matrix.cp }}-${{ matrix.platform_id }}-${{ matrix.manylinux_image }}
runs-on: ${{ matrix.os }}
strategy:
# Ensure that a wheel builder finishes even if another fails
fail-fast: false
matrix:
include:
# Linux 64 bit manylinux2014
- os: ubuntu-latest
python: '3.9'
cp: '39'
platform_id: manylinux_x86_64
manylinux_image: manylinux2014
- os: ubuntu-latest
python: '3.10'
cp: '310'
platform_id: manylinux_x86_64
manylinux_image: manylinux2014
- os: ubuntu-latest
python: '3.11'
cp: '311'
platform_id: manylinux_x86_64
manylinux_image: manylinux2014
- os: ubuntu-latest
python: '3.12'
cp: '312'
platform_id: manylinux_x86_64
manylinux_image: manylinux2014

# MacOS x86_64
- os: macos-13
python: '3.9'
cp: '39'
platform_id: macosx_x86_64
- os: macos-13
python: '3.10'
cp: '310'
platform_id: macosx_x86_64
- os: macos-13
python: '3.11'
cp: '311'
platform_id: macosx_x86_64
- os: macos-13
python: '3.12'
cp: '312'
platform_id: macosx_x86_64

# MacOS arm64
- os: macos-14
python: '3.9'
cp: '39'
platform_id: macosx_arm64
- os: macos-14
python: '3.10'
cp: '310'
platform_id: macosx_arm64
- os: macos-14
python: '3.11'
cp: '311'
platform_id: macosx_arm64
- os: macos-14
python: '3.12'
cp: '312'
platform_id: macosx_arm64

steps:
- name: Checkout TextWorld
uses: actions/checkout@v4

- name: Build Wheel
uses: pypa/[email protected]
env:
CIBW_BUILD: cp${{ matrix.cp }}-${{ matrix.platform_id }}
CIBW_ARCHS: all
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.manylinux_image }}
CIBW_MANYLINUX_I686_IMAGE: ${{ matrix.manylinux_image }}
CIBW_BUILD_VERBOSITY: 1
with:
output-dir: wheelhouse

- name: Install dependencies (Linux)
run: sudo apt update && sudo apt install -y --no-install-recommends graphviz
if: startsWith(matrix.os, 'ubuntu')

- name: Install dependencies (MacOS)
run: brew install graphviz
if: startsWith(matrix.os, 'macos')

- name: Use Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}

- name: Install TextWorld from the wheel
run: |
python -m pip install --upgrade pip
pip install pytest
pip install `ls wheelhouse/*.whl`[full]
- name: Run tests
run: |
pytest --durations=10 tests/ textworld/
- uses: actions/upload-artifact@v4
with:
name: tw-wheels-cp${{ matrix.cp }}-${{ matrix.platform_id }}
path: wheelhouse/*.whl
if-no-files-found: error

# Build the source distribution under Linux
build_sdist:
name: Source distribution
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build --sdist
- name: Store artifacts
uses: actions/upload-artifact@v4
with:
name: tw-sdist
path: dist/*.tar.gz
if-no-files-found: error

upload_pypi:
name: >-
Publish TextWorld 📦 to PyPI
needs:
- build_wheels
- build_sdist
runs-on: ubuntu-latest
environment:
name: release
url: https://pypi.org/project/textworld/
permissions:
id-token: write # mandatory for trusted publishing
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
pattern: tw-*
path: dist
merge-multiple: true
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
43 changes: 43 additions & 0 deletions .github/workflows/test_pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: "Test from PyPi"

on:
workflow_dispatch:
# Schedule a workflow to run at 00:00 (UTC) on the first of every month
schedule:
- cron: "0 0 1 * *"

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-13, macos-14]
python: ['3.9', '3.10', '3.11', '3.12', '3.13']
steps:
- uses: actions/checkout@v4
- name: Use Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}

- name: Install dependencies (Linux)
run: sudo apt update && sudo apt install -y --no-install-recommends graphviz
if: startsWith(matrix.os, 'ubuntu')

- name: Install dependencies (MacOS)
run: brew install graphviz
if: startsWith(matrix.os, 'macos')

- name: Install TextWorld
run: |
python -m pip install --upgrade pip
pip install pytest pytest-azurepipelines pytest-cov
pip install --pre textworld[full]
- name: Run tests
run: |
pytest --durations=10 --junitxml=junit/test-results.xml --cov=textworld --cov-report=xml --cov-report=html tests/ textworld/
- uses: actions/upload-artifact@v4
with:
name: test-results
path: junit/test-results.xml
5 changes: 2 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ recursive-include textworld/render/tmpl *
recursive-include textworld/thirdparty/glulx *

recursive-include textworld/thirdparty/inform7 *
recursive-include textworld/thirdparty/inform7-6M62/bin *
recursive-include textworld/thirdparty/inform7-6M62/share/inform7/Compilers *
include textworld/thirdparty/inform7-6M62/share/inform7/Compilers/inform6
include textworld/thirdparty/inform7-6M62/share/inform7/Compilers/ni
recursive-include textworld/thirdparty/inform7-6M62/share/inform7/Internal *
recursive-include textworld/thirdparty/inform7-6M62/share/inform7/Interpreters *

global-exclude *.o *.a
global-exclude */__pycache__/*
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ build-backend = "setuptools.build_meta"
[project]
name = "textworld"
dynamic = ["version", "optional-dependencies", "dependencies", "readme"]
requires-python = ">=3.8"
requires-python = ">=3.9"
2 changes: 1 addition & 1 deletion requirements-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ selenium>=3.12.0,<4.3
greenlet>=0.4.13
gevent>=1.3.5
pillow>=5.1.0
plotly>=4.0.0
plotly>=4.0.0,<6.0.0
pydot>=1.2.4
psutil
matplotlib
Expand Down
2 changes: 1 addition & 1 deletion requirements-vis.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ selenium>=3.12.0,<4.3
greenlet>=0.4.13
gevent>=1.3.5
pillow>=5.1.0
plotly>=4.0.0
plotly>=4.0.0,<6.0.0
pydot>=1.2.4
psutil
matplotlib
5 changes: 1 addition & 4 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ if [ "${machine}" == 'Mac' ] && [ -e inform7-6M62 ]; then
current_dir="$(pwd)"
cd /Volumes/Inform/Inform.app/Contents/MacOS
mkdir -p "$current_dir/inform7-6M62/share/inform7/Compilers/"
mkdir -p "$current_dir/inform7-6M62/share/inform7/Interpreters/"
cp cBlorb inform6 Inform intest ni "$current_dir/inform7-6M62/share/inform7/Compilers/"
cp ./git* "$current_dir/inform7-6M62/share/inform7/Interpreters/dumb-git"
cp ./glulxe* "$current_dir/inform7-6M62/share/inform7/Interpreters/dumb-glulxe"
cp inform6 ni "$current_dir/inform7-6M62/share/inform7/Compilers/"

cd "$current_dir"

Expand Down
2 changes: 1 addition & 1 deletion textworld/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.6.2rc4'
__version__ = '1.6.2rc5'

0 comments on commit 2d17ef1

Please sign in to comment.