Skip to content

Commit 2273116

Browse files
committed
[MNT] move doctests + add dependency
1 parent f6ec88d commit 2273116

File tree

4 files changed

+306
-127
lines changed

4 files changed

+306
-127
lines changed

.github/docker/Dockerfile

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Hyperactive CI Docker Image
2+
# Pre-installs all dependencies to speed up CI runs
3+
#
4+
# Build with: docker build --build-arg PYTHON_VERSION=3.11 -t ghcr.io/simonblanke/hyperactive-ci:py3.11 .
5+
# Push with: docker push ghcr.io/simonblanke/hyperactive-ci:py3.11
6+
7+
ARG PYTHON_VERSION=3.11
8+
9+
FROM python:${PYTHON_VERSION}-slim
10+
11+
ARG PYTHON_VERSION
12+
13+
LABEL org.opencontainers.image.source="https://github.com/SimonBlanke/Hyperactive"
14+
LABEL org.opencontainers.image.description="Hyperactive CI image with pre-installed dependencies (Python ${PYTHON_VERSION})"
15+
LABEL org.opencontainers.image.licenses="MIT"
16+
17+
# Install system dependencies
18+
RUN apt-get update && apt-get install -y --no-install-recommends \
19+
git \
20+
build-essential \
21+
&& rm -rf /var/lib/apt/lists/*
22+
23+
# Upgrade pip
24+
RUN pip install --no-cache-dir --upgrade pip
25+
26+
# Copy only dependency files first (for better layer caching)
27+
WORKDIR /deps
28+
COPY pyproject.toml ./
29+
COPY docs/requirements.txt ./docs-requirements.txt
30+
31+
# Install all dependencies without the package itself
32+
# We install extras separately to handle optional dependencies gracefully
33+
RUN pip install --no-cache-dir \
34+
# Core test dependencies
35+
pytest==9.0.1 \
36+
flake8 \
37+
pytest-cov \
38+
pathos \
39+
# Build dependencies
40+
setuptools \
41+
build \
42+
wheel \
43+
# Docs dependencies
44+
sphinx>=7.0.0 \
45+
sphinx-autobuild \
46+
sphinx-copybutton \
47+
sphinx-design \
48+
sphinx-issues \
49+
myst-parser \
50+
numpydoc \
51+
pydata-sphinx-theme \
52+
# Core package dependencies
53+
"numpy>=1.18.1,<3.0.0" \
54+
"tqdm>=4.48.0,<5.0.0" \
55+
"pandas<3.0.0" \
56+
"gradient-free-optimizers>=1.2.4,<2.0.0" \
57+
"scikit-base<1.0.0" \
58+
"scikit-learn<1.8.0" \
59+
# all_extras dependencies
60+
"optuna<5" \
61+
cmaes \
62+
# test_parallel_backends (skip ray for now - complex deps)
63+
dask \
64+
joblib \
65+
# Pre-commit for code quality
66+
pre-commit
67+
68+
# Install torch CPU-only (much smaller than full torch)
69+
# Skip for Python 3.14 as torch may not be available
70+
RUN if [ "${PYTHON_VERSION}" != "3.14" ]; then \
71+
pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu; \
72+
fi
73+
74+
# Install lightning (depends on torch)
75+
RUN if [ "${PYTHON_VERSION}" != "3.14" ]; then \
76+
pip install --no-cache-dir lightning; \
77+
fi
78+
79+
# Install tf_keras
80+
RUN pip install --no-cache-dir tf_keras || true
81+
82+
# Install sktime/skpro (skip for Python 3.14)
83+
RUN if [ "${PYTHON_VERSION}" != "3.14" ]; then \
84+
pip install --no-cache-dir sktime skpro || true; \
85+
fi
86+
87+
# Clean up
88+
RUN rm -rf /deps
89+
90+
# Set working directory for CI
91+
WORKDIR /workspace
92+
93+
# Default command
94+
CMD ["python", "--version"]
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
name: Build CI Images
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- dev
8+
paths:
9+
- 'pyproject.toml'
10+
- 'docs/requirements.txt'
11+
- '.github/docker/Dockerfile'
12+
- '.github/workflows/build-ci-image.yml'
13+
workflow_dispatch:
14+
inputs:
15+
python_versions:
16+
description: 'Python versions to build (comma-separated, e.g., "3.11,3.12" or "all")'
17+
required: false
18+
default: 'all'
19+
20+
env:
21+
REGISTRY: ghcr.io
22+
IMAGE_NAME: simonblanke/hyperactive-ci
23+
24+
jobs:
25+
build-and-push:
26+
name: Build Python ${{ matrix.python-version }}
27+
runs-on: ubuntu-latest
28+
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
33+
34+
permissions:
35+
contents: read
36+
packages: write
37+
38+
steps:
39+
- name: Checkout repository
40+
uses: actions/checkout@v4
41+
42+
- name: Check if version should be built
43+
id: should-build
44+
run: |
45+
INPUT="${{ github.event.inputs.python_versions }}"
46+
VERSION="${{ matrix.python-version }}"
47+
48+
if [ -z "$INPUT" ] || [ "$INPUT" = "all" ]; then
49+
echo "build=true" >> $GITHUB_OUTPUT
50+
elif echo "$INPUT" | grep -q "$VERSION"; then
51+
echo "build=true" >> $GITHUB_OUTPUT
52+
else
53+
echo "build=false" >> $GITHUB_OUTPUT
54+
fi
55+
56+
- name: Set up Docker Buildx
57+
if: steps.should-build.outputs.build == 'true'
58+
uses: docker/setup-buildx-action@v3
59+
60+
- name: Log in to Container Registry
61+
if: steps.should-build.outputs.build == 'true'
62+
uses: docker/login-action@v3
63+
with:
64+
registry: ${{ env.REGISTRY }}
65+
username: ${{ github.actor }}
66+
password: ${{ secrets.GITHUB_TOKEN }}
67+
68+
- name: Extract metadata
69+
if: steps.should-build.outputs.build == 'true'
70+
id: meta
71+
uses: docker/metadata-action@v5
72+
with:
73+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
74+
tags: |
75+
type=raw,value=py${{ matrix.python-version }}
76+
type=raw,value=py${{ matrix.python-version }}-{{date 'YYYYMMDD'}}
77+
78+
- name: Build and push Docker image
79+
if: steps.should-build.outputs.build == 'true'
80+
uses: docker/build-push-action@v5
81+
with:
82+
context: .
83+
file: .github/docker/Dockerfile
84+
push: true
85+
tags: ${{ steps.meta.outputs.tags }}
86+
labels: ${{ steps.meta.outputs.labels }}
87+
build-args: |
88+
PYTHON_VERSION=${{ matrix.python-version }}
89+
cache-from: type=gha
90+
cache-to: type=gha,mode=max
91+
92+
- name: Skip message
93+
if: steps.should-build.outputs.build != 'true'
94+
run: echo "Skipping Python ${{ matrix.python-version }} (not in requested versions)"
95+
96+
summary:
97+
name: Build Summary
98+
needs: build-and-push
99+
runs-on: ubuntu-latest
100+
if: always()
101+
102+
steps:
103+
- name: Summary
104+
run: |
105+
echo "## CI Image Build Summary" >> $GITHUB_STEP_SUMMARY
106+
echo "" >> $GITHUB_STEP_SUMMARY
107+
echo "Images pushed to: \`${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}\`" >> $GITHUB_STEP_SUMMARY
108+
echo "" >> $GITHUB_STEP_SUMMARY
109+
echo "Available tags:" >> $GITHUB_STEP_SUMMARY
110+
echo "- \`py3.10\`, \`py3.11\`, \`py3.12\`, \`py3.13\`, \`py3.14\`" >> $GITHUB_STEP_SUMMARY
111+
echo "" >> $GITHUB_STEP_SUMMARY
112+
echo "Usage in workflows:" >> $GITHUB_STEP_SUMMARY
113+
echo "\`\`\`yaml" >> $GITHUB_STEP_SUMMARY
114+
echo "jobs:" >> $GITHUB_STEP_SUMMARY
115+
echo " test:" >> $GITHUB_STEP_SUMMARY
116+
echo " runs-on: ubuntu-latest" >> $GITHUB_STEP_SUMMARY
117+
echo " container:" >> $GITHUB_STEP_SUMMARY
118+
echo " image: ghcr.io/simonblanke/hyperactive-ci:py3.11" >> $GITHUB_STEP_SUMMARY
119+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY

.github/workflows/docs.yml

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ jobs:
2626
test-snippets:
2727
name: test-doc-snippets
2828
runs-on: ubuntu-latest
29+
container:
30+
image: ghcr.io/simonblanke/hyperactive-ci:py${{ matrix.python-version }}
2931
strategy:
3032
matrix:
3133
python-version: ['3.10', '3.11', '3.12']
@@ -34,16 +36,10 @@ jobs:
3436
steps:
3537
- uses: actions/checkout@v4
3638

37-
- name: Set up Python ${{ matrix.python-version }}
38-
uses: actions/setup-python@v5
39-
with:
40-
python-version: ${{ matrix.python-version }}
41-
42-
- name: Install dependencies
39+
- name: Install package and docs requirements
4340
run: |
44-
python -m pip install --no-cache-dir --upgrade pip
45-
python -m pip install --no-cache-dir -e ".[all_extras,test]"
46-
python -m pip install --no-cache-dir -r docs/requirements.txt
41+
pip install --no-cache-dir -e ".[all_extras,test]"
42+
pip install --no-cache-dir -r docs/requirements.txt
4743
4844
- name: Show dependencies
4945
run: python -m pip list
@@ -55,21 +51,17 @@ jobs:
5551
build-docs:
5652
name: build-docs
5753
runs-on: ubuntu-latest
54+
container:
55+
image: ghcr.io/simonblanke/hyperactive-ci:py3.12
5856
needs: test-snippets
5957

6058
steps:
6159
- uses: actions/checkout@v4
6260

63-
- name: Set up Python
64-
uses: actions/setup-python@v5
65-
with:
66-
python-version: '3.12'
67-
68-
- name: Install dependencies
61+
- name: Install package and docs requirements
6962
run: |
70-
python -m pip install --no-cache-dir --upgrade pip
71-
python -m pip install --no-cache-dir -e ".[all_extras]"
72-
python -m pip install --no-cache-dir -r docs/requirements.txt
63+
pip install --no-cache-dir -e ".[all_extras]"
64+
pip install --no-cache-dir -r docs/requirements.txt
7365
7466
- name: Show dependencies
7567
run: python -m pip list

0 commit comments

Comments
 (0)