Skip to content

Commit c180d71

Browse files
authored
Test uploads (#52)
Possibly, premature merge, but need to add workflow file a step 0 Adding upload test for local version of ezBIDS w/ multi-modality mixed folder of dicoms merging and pushing so that test can be triggered in actions as it's not presently in workflows. Small changes to Makefile to ensure running of tests. * adding local upload test to CI * add create mixed dicom folder to makefile
1 parent b138968 commit c180d71

File tree

12 files changed

+1571
-5
lines changed

12 files changed

+1571
-5
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Collect Test Data
2+
3+
on:
4+
push:
5+
branches: [ '*' ]
6+
pull_request:
7+
branches: [ '*' ]
8+
workflow_dispatch: # Allow manual triggering
9+
10+
jobs:
11+
collect-data:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
cache-hit: ${{ steps.test-data-cache.outputs.cache-hit }}
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
submodules: true # Ensure we get the submodule info
20+
21+
- name: Cache test data
22+
uses: actions/cache@v4
23+
id: test-data-cache
24+
with:
25+
path: test/test_data
26+
key: test-data-${{ hashFiles('.gitmodules') }}
27+
restore-keys: |
28+
test-data-
29+
30+
- name: Get test data if not cached
31+
if: steps.test-data-cache.outputs.cache-hit != 'true'
32+
run: |
33+
make get-test-data
34+
35+
- name: Verify test data
36+
run: |
37+
if [ ! -d "test/test_data" ]; then
38+
echo "Test data directory not found"
39+
exit 1
40+
fi
41+
if [ ! -d "test/test_data/mixed_dicoms" ]; then
42+
echo "Mixed DICOM directory not found"
43+
exit 1
44+
fi
45+
46+
- name: Upload test data
47+
uses: actions/upload-artifact@v4
48+
with:
49+
name: test-data
50+
path: test/test_data
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Test Local Upload
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Docker Build (Local)"]
6+
types:
7+
- completed
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
13+
14+
env:
15+
COMPOSE_FILE: ./docker-compose.yml
16+
REGISTRY_PREFIX: docker.io/library
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
submodules: true # Ensure we get the submodule info
22+
23+
- name: Set repository name
24+
run: echo "REPO_NAME=$(basename $GITHUB_WORKSPACE)" >> $GITHUB_ENV
25+
26+
- name: Cache test data
27+
uses: actions/cache@v4
28+
id: test-data-cache
29+
with:
30+
path: test/test_data
31+
key: test-data-${{ hashFiles('.gitmodules') }}
32+
restore-keys: |
33+
test-data-
34+
35+
- name: Get test data if not cached
36+
if: steps.test-data-cache.outputs.cache-hit != 'true'
37+
run: |
38+
cd test
39+
make gettestdata
40+
41+
- name: Download images
42+
uses: actions/download-artifact@v4
43+
with:
44+
name: docker-images-local
45+
path: .
46+
47+
- name: Load images
48+
run: |
49+
docker load < mongo.tar
50+
docker load < api.tar
51+
docker load < handler.tar
52+
docker load < ui.tar
53+
54+
- name: Tag images
55+
run: |
56+
docker tag mongo:latest mongo:test
57+
docker tag ${REGISTRY_PREFIX}/${REPO_NAME}-api:latest ${REPO_NAME}-api:test
58+
docker tag ${REGISTRY_PREFIX}/${REPO_NAME}-handler:latest ${REPO_NAME}-handler:test
59+
docker tag ${REGISTRY_PREFIX}/${REPO_NAME}-ui:latest ${REPO_NAME}-ui:test
60+
61+
- name: Start services
62+
run: docker compose -f ${{ env.COMPOSE_FILE }} up -d
63+
64+
- name: Wait for services to be ready
65+
run: |
66+
# Wait for MongoDB
67+
timeout 60 bash -c 'until docker compose -f ${{ env.COMPOSE_FILE }} exec -T mongo mongosh --eval "db.adminCommand(\"ping\")" > /dev/null 2>&1; do sleep 2; done'
68+
69+
# Wait for API
70+
timeout 60 bash -c 'until curl -s http://localhost:8082/health > /dev/null; do sleep 2; done'
71+
72+
# Wait for UI
73+
timeout 60 bash -c 'until curl -s http://localhost:3000 > /dev/null; do sleep 2; done'
74+
75+
- name: Install uv
76+
run: |
77+
curl -LsSf https://astral.sh/uv/install.sh | sh
78+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
79+
80+
- name: Verify uv installation
81+
run: uv --version
82+
83+
- name: Setup test environment
84+
run: |
85+
cd test
86+
make setup-test
87+
88+
- name: Run upload test
89+
run: |
90+
cd test
91+
make test-upload
92+
93+
- name: Cleanup
94+
if: always()
95+
run: |
96+
docker compose -f ${{ env.COMPOSE_FILE }} down
97+
docker system prune -f

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,5 @@ nginx/ssl/*
4242
*__pycache__*
4343

4444
# Ignore test data submodules contents but not the submodule tracking
45-
# test/test_data/*/
46-
# !test/test_data/.gitkeep
45+
test/test_data/*/
46+
!test/test_data/.gitkeep

Makefile

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,29 @@
1-
.PHONY: gettestdata clean-testdata
1+
.PHONY: gettestdata clean-testdata setup-test test-upload clean-test
22

33
# Create test_data directory if it doesn't exist
44
test/test_data:
55
mkdir -p test/test_data
66

77
# Initialize and update submodules for test data
8-
gettestdata: test/test_data
8+
get-test-data: test/test_data
99
test/gettestdata
10+
test/createmixedfolder
1011

1112
# Clean test data (remove submodules and their directories)
1213
clean-testdata:
13-
test/cleantestdata
14+
test/cleantestdata
15+
16+
# Test environment setup
17+
setup-test:
18+
cd test && uv venv .venv
19+
cd test && uv pip install -e .
20+
21+
# Run upload test
22+
test-upload: setup-test
23+
cd test && uv run pytest upload_flat_folder_of_dicoms.py -v -s
24+
25+
# Clean test environment
26+
clean-test:
27+
rm -rf test/.venv
28+
rm -rf test/__pycache__
29+
rm -rf test/.pytest_cache

test/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)