Skip to content

Commit 696cc9c

Browse files
authored
Merge pull request #42 from cfe-lab/small-improvements-0001
Small improvements
2 parents 3b979d3 + 02fe430 commit 696cc9c

4 files changed

Lines changed: 126 additions & 17 deletions

File tree

.github/workflows/main.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: main tests
2+
3+
on:
4+
push:
5+
workflow_dispatch:
6+
7+
jobs:
8+
build-and-test:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v4
14+
with:
15+
submodules: recursive
16+
fetch-depth: 0
17+
18+
- name: Set up Docker Buildx
19+
uses: docker/setup-buildx-action@v3
20+
21+
- name: Build Docker image
22+
uses: docker/build-push-action@v5
23+
with:
24+
context: .
25+
file: ./bblab.dockerfile
26+
target: bblab-site
27+
push: false
28+
tags: cfe-lab/bblab-site
29+
load: true
30+
cache-from: type=gha
31+
cache-to: type=gha,mode=max
32+
33+
- name: Run pytest tests
34+
run: |
35+
docker run --rm \
36+
-w /alldata/bblab_site \
37+
cfe-lab/bblab-site \
38+
uv run pytest -v
39+
40+
- name: Run Django tests
41+
run: |
42+
docker run --rm \
43+
--env-file ./compose-template.env \
44+
-w /alldata/bblab_site \
45+
cfe-lab/bblab-site \
46+
uv run python manage.py test --noinput

alldata/bblab_site/pyproject.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,29 @@ include = [
9393

9494
[tool.hatch.metadata]
9595
allow-direct-references = true
96+
97+
[tool.pytest.ini_options]
98+
testpaths = [
99+
".",
100+
]
101+
# Exclude vendor/dependency directories and submodule repos that have their own test suites
102+
norecursedirs = [
103+
"depend",
104+
".venv",
105+
"build",
106+
"dist",
107+
"*.egg",
108+
".git",
109+
"git",
110+
".tox",
111+
"repo", # Excludes submodule repos like tools/phage_i_expanded/repo/
112+
"blind_dating",
113+
"phylodating",
114+
"translate_DNA",
115+
"tests/phylodating", # Exclude the test submodule copy
116+
"tools", # Skip the empty Django test stubs
117+
]
118+
# Only collect test files from our actual project, not vendored dependencies
119+
python_files = ["test_*.py"]
120+
python_classes = ["Test*"]
121+
python_functions = ["test_*"]

alldata/bblab_site/test_smoke.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"""
2+
Smoke tests to verify the Docker container build is working correctly.
3+
"""
4+
5+
6+
def test_imports():
7+
"""Test that core dependencies can be imported."""
8+
import django
9+
import numpy
10+
import scipy
11+
import yaml
12+
assert django.VERSION is not None
13+
assert numpy.__version__ is not None
14+
15+
16+
def test_django_setup():
17+
"""Test that Django can be set up (even without database)."""
18+
import os
19+
import django
20+
21+
# Set minimal Django settings for testing
22+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'bblab_site.settings')
23+
24+
# We expect this to fail without proper environment variables,
25+
# but it should fail gracefully, not with import errors
26+
try:
27+
django.setup()
28+
except KeyError:
29+
# Expected - missing environment variables like BBLAB_WEB_ADDRESS
30+
pass
31+
32+
33+
def test_python_version():
34+
"""Test that we're running the expected Python version."""
35+
import sys
36+
assert sys.version_info >= (3, 12)
37+
assert sys.version_info < (3, 13)

bblab.dockerfile

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,23 @@ RUN wget https://github.com/cfe-lab/bblab-server/releases/download/v0.1.0-alpha/
114114
tar -xzf blast-2.2.16-x64-linux.tar.gz && \
115115
tar -xzf tcrdist_extras_v2.tgz
116116

117+
# load configuration for Apache server
118+
COPY conf/apache2.conf /etc/apache2/
119+
COPY conf/tools-*.conf /etc/apache2/mods-available/
120+
COPY conf/php.conf /etc/apache2/mods-available
121+
RUN ln -sf /etc/apache2/mods-available/tools-gld.conf /etc/apache2/mods-enabled/tools-gld.conf && \
122+
ln -sf /etc/apache2/mods-available/tools-pld.conf /etc/apache2/mods-enabled/tools-pld.conf && \
123+
ln -sf /etc/apache2/mods-available/tools-hla.conf /etc/apache2/mods-enabled/tools-hla.conf && \
124+
ln -sf /etc/apache2/mods-available/php.conf /etc/apache2/mods-enabled/php.conf && \
125+
ln -sf /var/log/apache2/access.log /dev/stdout && \
126+
ln -sf /var/log/apache2/error.log /dev/stderr && \
127+
chmod 766 -R /var/log/apache2/ && \
128+
a2dissite 000-default.conf && a2dissite default-ssl.conf
129+
130+
# Copy shell scripts for Phylodating
131+
COPY phylodating_setup/clean.sh /var/www/phylodating/clean.sh
132+
COPY phylodating_setup/logwatcher.sh /var/www/phylodating/logwatcher.sh
133+
117134
# copy source code
118135
COPY alldata /alldata
119136

@@ -148,23 +165,6 @@ RUN mv ./tcrdist_extras_v2/external/ /alldata/bblab_site/depend/apps/tcr-dist/ &
148165

149166
USER root
150167

151-
# load configuration for Apache server
152-
COPY conf/apache2.conf /etc/apache2/
153-
COPY conf/tools-*.conf /etc/apache2/mods-available/
154-
COPY conf/php.conf /etc/apache2/mods-available
155-
RUN ln -sf /etc/apache2/mods-available/tools-gld.conf /etc/apache2/mods-enabled/tools-gld.conf && \
156-
ln -sf /etc/apache2/mods-available/tools-pld.conf /etc/apache2/mods-enabled/tools-pld.conf && \
157-
ln -sf /etc/apache2/mods-available/tools-hla.conf /etc/apache2/mods-enabled/tools-hla.conf && \
158-
ln -sf /etc/apache2/mods-available/php.conf /etc/apache2/mods-enabled/php.conf && \
159-
ln -sf /var/log/apache2/access.log /dev/stdout && \
160-
ln -sf /var/log/apache2/error.log /dev/stderr && \
161-
chmod 766 -R /var/log/apache2/ && \
162-
a2dissite 000-default.conf && a2dissite default-ssl.conf
163-
164-
# Copy shell scripts for Phylodating
165-
COPY phylodating_setup/clean.sh /var/www/phylodating/clean.sh
166-
COPY phylodating_setup/logwatcher.sh /var/www/phylodating/logwatcher.sh
167-
168168
# Set permissions and ownership for WSGI user/group (www-data:varwwwusers)
169169
RUN mkdir -p /alldata/bblab_site/tools/sequencing_layout/output && \
170170
mkdir /alldata/bblab_site/tools/sequencing_layout/output/archived_layouts && \

0 commit comments

Comments
 (0)