Skip to content

Commit 5fa786f

Browse files
committed
ruff things up; github actions; updated deps
1 parent b868e42 commit 5fa786f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+4655
-2139
lines changed

.github/workflows/ci.yml

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master, python314 ]
6+
pull_request:
7+
branches: [ master ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
test:
12+
name: Test Python ${{ matrix.python-version }} on ${{ matrix.os }}
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
os: [ubuntu-latest, macos-latest, windows-latest]
18+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
allow-prereleases: true
28+
29+
- name: Install uv
30+
uses: astral-sh/setup-uv@v4
31+
with:
32+
enable-cache: true
33+
34+
- name: Install dependencies
35+
run: |
36+
uv pip install --system -e ".[hdf5,dev]"
37+
38+
- name: Run tests
39+
run: |
40+
pytest -v tests --tb=short
41+
42+
- name: Test worldengine command
43+
run: |
44+
worldengine --help
45+
worldengine world -s 42 -n test_world -x 512 -y 512
46+
47+
lint:
48+
name: Lint and Type Check
49+
runs-on: ubuntu-latest
50+
51+
steps:
52+
- uses: actions/checkout@v4
53+
54+
- name: Set up Python
55+
uses: actions/setup-python@v5
56+
with:
57+
python-version: '3.11'
58+
59+
- name: Install uv
60+
uses: astral-sh/setup-uv@v4
61+
62+
- name: Install dependencies
63+
run: |
64+
uv pip install --system -e ".[dev]"
65+
66+
- name: Run pre-commit
67+
run: |
68+
pre-commit run --all-files
69+
70+
- name: Run ruff check
71+
run: |
72+
ruff check worldengine/
73+
74+
- name: Run mypy
75+
run: |
76+
mypy worldengine/ --ignore-missing-imports
77+
continue-on-error: true
78+
79+
build-wheels:
80+
name: Build wheels on ${{ matrix.os }}
81+
runs-on: ${{ matrix.os }}
82+
strategy:
83+
matrix:
84+
os: [ubuntu-latest, macos-latest, windows-latest]
85+
86+
steps:
87+
- uses: actions/checkout@v4
88+
89+
- name: Set up Python
90+
uses: actions/setup-python@v5
91+
with:
92+
python-version: '3.11'
93+
94+
- name: Install build tools
95+
run: |
96+
python -m pip install --upgrade pip build
97+
98+
- name: Build sdist (Ubuntu only)
99+
if: matrix.os == 'ubuntu-latest'
100+
run: |
101+
python -m build --sdist
102+
103+
- name: Build wheel
104+
run: |
105+
python -m build --wheel
106+
107+
- name: Upload artifacts
108+
uses: actions/upload-artifact@v4
109+
with:
110+
name: wheels-${{ matrix.os }}
111+
path: dist/*
112+
113+
docker:
114+
name: Test Docker build
115+
runs-on: ubuntu-latest
116+
117+
steps:
118+
- uses: actions/checkout@v4
119+
120+
- name: Set up Docker Buildx
121+
uses: docker/setup-buildx-action@v3
122+
123+
- name: Build Docker image
124+
uses: docker/build-push-action@v6
125+
with:
126+
context: .
127+
push: false
128+
tags: worldengine:test
129+
cache-from: type=gha
130+
cache-to: type=gha,mode=max
131+
132+
- name: Test Docker image
133+
run: |
134+
docker run worldengine:test worldengine --help
135+
docker run worldengine:test worldengine world -s 123 -n docker_test -x 256 -y 256

.github/workflows/release.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Build and Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
jobs:
9+
build-sdist:
10+
name: Build source distribution
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: '3.11'
20+
21+
- name: Install build tools
22+
run: |
23+
python -m pip install --upgrade pip build
24+
25+
- name: Build sdist
26+
run: |
27+
python -m build --sdist
28+
29+
- name: Upload sdist
30+
uses: actions/upload-artifact@v4
31+
with:
32+
name: sdist
33+
path: dist/*.tar.gz
34+
35+
build-wheels:
36+
name: Build wheels on ${{ matrix.os }}
37+
runs-on: ${{ matrix.os }}
38+
strategy:
39+
matrix:
40+
os: [ubuntu-latest, macos-latest, windows-latest]
41+
42+
steps:
43+
- uses: actions/checkout@v4
44+
45+
- name: Set up Python
46+
uses: actions/setup-python@v5
47+
with:
48+
python-version: '3.11'
49+
50+
- name: Install build tools
51+
run: |
52+
python -m pip install --upgrade pip build
53+
54+
- name: Build wheel
55+
run: |
56+
python -m build --wheel
57+
58+
- name: Upload wheels
59+
uses: actions/upload-artifact@v4
60+
with:
61+
name: wheels-${{ matrix.os }}
62+
path: dist/*.whl
63+
64+
publish:
65+
name: Publish to PyPI
66+
needs: [build-sdist, build-wheels]
67+
runs-on: ubuntu-latest
68+
if: github.event_name == 'release' && github.event.action == 'published'
69+
environment:
70+
name: pypi
71+
url: https://pypi.org/p/worldengine
72+
permissions:
73+
id-token: write
74+
75+
steps:
76+
- name: Download all artifacts
77+
uses: actions/download-artifact@v4
78+
with:
79+
path: dist
80+
merge-multiple: true
81+
82+
- name: List distributions
83+
run: ls -lh dist/
84+
85+
- name: Publish to PyPI
86+
uses: pypa/gh-action-pypi-publish@release/v1
87+
with:
88+
skip-existing: true
89+
90+
create-github-release-assets:
91+
name: Upload release assets
92+
needs: [build-sdist, build-wheels]
93+
runs-on: ubuntu-latest
94+
if: github.event_name == 'release' && github.event.action == 'published'
95+
permissions:
96+
contents: write
97+
98+
steps:
99+
- name: Download all artifacts
100+
uses: actions/download-artifact@v4
101+
with:
102+
path: dist
103+
merge-multiple: true
104+
105+
- name: Upload to GitHub Release
106+
uses: softprops/action-gh-release@v2
107+
with:
108+
files: dist/*

.pre-commit-config.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v5.0.0
6+
hooks:
7+
- id: trailing-whitespace
8+
- id: end-of-file-fixer
9+
- id: check-yaml
10+
- id: check-added-large-files
11+
- id: check-merge-conflict
12+
- id: check-toml
13+
- id: check-json
14+
- id: mixed-line-ending
15+
16+
- repo: https://github.com/astral-sh/ruff-pre-commit
17+
rev: v0.8.4
18+
hooks:
19+
# Run the linter
20+
- id: ruff
21+
args: [--fix, --exit-non-zero-on-fix]
22+
# Run the formatter
23+
- id: ruff-format

.travis.yml

Lines changed: 0 additions & 52 deletions
This file was deleted.

Dockerfile

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1-
FROM debian:stretch
1+
FROM python:3.11-slim
22

3+
# Install system dependencies for PyPlatec and h5py
34
RUN apt-get update && \
4-
apt-get -y install git \
5-
procps \
6-
python-dev \
7-
python-pip \
8-
curl \
9-
vim
10-
11-
RUN pip install --upgrade pip setuptools
5+
apt-get -y install --no-install-recommends \
6+
gcc \
7+
g++ \
8+
libhdf5-dev \
9+
pkg-config && \
10+
rm -rf /var/lib/apt/lists/*
1211

1312
WORKDIR /app
14-
ADD . /app
1513

16-
RUN pip install -r /app/requirements-dev.txt
14+
# Copy all project files
15+
COPY . /app/
1716

17+
# Install worldengine with dependencies
18+
RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \
19+
pip install --no-cache-dir -e ".[hdf5,dev]"
1820

21+
# Default command
22+
CMD ["worldengine", "--help"]

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
21+
SOFTWARE.

0 commit comments

Comments
 (0)