Skip to content

Commit 8e23297

Browse files
authored
Merge pull request #27 from tlambert03/dockerfile
Add CI workflow, Dockerfile, and update README for testing instructions
2 parents 8e4bfeb + dae444e commit 8e23297

4 files changed

Lines changed: 61 additions & 1 deletion

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,15 @@ jobs:
7474
with:
7575
generate_release_notes: true
7676
files: "./dist/*"
77+
78+
docker-test:
79+
runs-on: ubuntu-latest
80+
81+
steps:
82+
- name: Checkout code
83+
uses: actions/checkout@v4
84+
85+
- name: Build and test Docker image
86+
run: |
87+
docker build -t spatial_graph .
88+
docker run --rm spatial_graph

Dockerfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
FROM ubuntu:24.04
2+
3+
ENV DEBIAN_FRONTEND=noninteractive \
4+
MAMBA_ROOT_PREFIX=/opt/conda \
5+
PATH=/opt/conda/bin:$PATH
6+
7+
RUN apt-get update && \
8+
apt-get install -y --no-install-recommends \
9+
git curl tar bzip2 ca-certificates && \
10+
rm -rf /var/lib/apt/lists/*
11+
12+
# auto-detect arch and grab the matching micromamba binary
13+
RUN set -eux; \
14+
arch="$(uname -m)"; \
15+
case "$arch" in \
16+
x86_64) url_arch=linux-64 ;; \
17+
aarch64|arm64) url_arch=linux-aarch64 ;; \
18+
ppc64le) url_arch=linux-ppc64le ;; \
19+
*) echo "Unsupported arch: $arch"; exit 1 ;; \
20+
esac; \
21+
curl -Ls "https://micro.mamba.pm/api/micromamba/$url_arch/latest" \
22+
| tar -xvj -C /usr/local/bin bin/micromamba; \
23+
chmod +x /usr/local/bin/bin/micromamba; \
24+
mv /usr/local/bin/bin/micromamba /usr/local/bin/micromamba; \
25+
rmdir /usr/local/bin/bin
26+
27+
28+
WORKDIR /app
29+
COPY . /app
30+
31+
RUN micromamba create -y -n test-env -c conda-forge python=3.12 pip compilers
32+
RUN micromamba run -n test-env pip install -e . --group test
33+
34+
SHELL ["micromamba", "run", "-n", "test-env", "/bin/bash", "-o", "pipefail", "-c"]
35+
36+
37+
# when you docker run, this will invoke pytest from inside test-env
38+
CMD ["micromamba", "run", "-n", "test-env", "pytest", "-q", "-x"]

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,14 @@ git push upstream --follow-tags
149149
```
150150

151151
This will trigger the CI workflow, which will build the package and upload it to PyPI.
152+
153+
### Testing in a conda environment
154+
155+
To simulate a naive user environment, with *no* assumptions made about the
156+
availability of a C/C++ compiler, you can run the included Dockerfile
157+
(where the key part of the conda env is the `compilers` package):
158+
159+
```bash
160+
docker build -t spatial_graph .
161+
docker run --rm spatial_graph
162+
```

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ build-backend = "hatchling.build"
55
[tool.hatch.version]
66
source = "vcs"
77

8-
98
[project]
109
name = "spatial-graph"
1110
dynamic = ["version"]

0 commit comments

Comments
 (0)