Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions .github/workflows/github-import.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: GitHub Import Test

on:
push:
pull_request:
workflow_dispatch:

jobs:
github-import:
name: Full GitHub import tree verification
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.24'
cache: true
cache-dependency-path: go.sum

- name: Set up Bun
uses: antongolub/action-setup-bun@v1
with:
bun-version: '1.2.4'

- name: Build frontend
working-directory: ./web
run: bun install && bun run build

# The server rebuilds the frontend on startup unless ./dist contains a
# .frontend-hash matching the current source. Stamp it here so the server
# skips the build (bun is not needed at runtime).
- name: Stamp frontend source hash
run: |
hash="$(
find web -type f \
! -path 'web/node_modules/*' \
! -path 'web/dist/*' \
! -name '.frontend-hash' \
-print0 |
LC_ALL=C sort -z |
while IFS= read -r -d '' file; do
printf '%s\0' "${file#web/}"
cat "$file"
printf '\0'
done |
sha256sum | cut -d ' ' -f1
)"
printf '%s' "$hash" > web/dist/.frontend-hash
rm -rf ./dist
mv web/dist ./dist

- name: Build server
run: go build -o ./angadrive-server .

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install test dependencies
run: pip install -r tests/requirements.txt

- name: Start Go server
env:
WEB_URL: localhost:8080
ASSETS_URL: localhost:8080
SAVE_DRIVE_RAM: 'true'
run: |
# Start from a clean runtime directory so the import is isolated.
rm -rf uploaded_files
chmod +x ./angadrive-server
./angadrive-server > server.log 2>&1 &
SERVER_PID=$!
echo "SERVER_PID=$SERVER_PID" >> "$GITHUB_ENV"
# Wait up to 30s for the server to come up.
for i in $(seq 1 30); do
if curl -s -o /dev/null http://localhost:8080/; then
echo "Server is up."
break
fi
sleep 1
done
if ! curl -s -o /dev/null http://localhost:8080/; then
echo "Server failed to start."
echo '--- Go server log ---'
cat server.log || true
exit 1
fi

- name: Run full GitHub import test
env:
API_URL: localhost:8080
GITHUB_IMPORT_TEST: '1'
TEST_TIMEOUT: '900'
GITHUB_IMPORT_TIMEOUT: '600'
run: python -m tests.main --test test_github_import_full_tree

- name: Stop Go server
if: always()
run: |
if [ -n "$SERVER_PID" ]; then
kill "$SERVER_PID" || true
fi
if [ -f server.log ]; then
echo '--- Go server log ---'
cat server.log
fi
8 changes: 4 additions & 4 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ jobs:
python-version: '3.12'

- name: Install test dependencies
run: pip install -r tester/requirements.txt
run: pip install -r tests/requirements.txt

- name: Discover integration tests
id: tests
run: echo "tests=$(python -m tester.main --list --json)" >> "$GITHUB_OUTPUT"
run: echo "tests=$(python -m tests.main --list --json)" >> "$GITHUB_OUTPUT"

frontend:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -152,13 +152,13 @@ jobs:
python-version: '3.12'

- name: Install test dependencies
run: pip install -r tester/requirements.txt
run: pip install -r tests/requirements.txt

- name: Run ${{ matrix.test }}
env:
API_URL: localhost:8080
TEST_TIMEOUT: '180'
run: python -m tester.main --test "${{ matrix.test }}"
run: python -m tests.main --test "${{ matrix.test }}"

- name: Stop Go server
if: always()
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ main
docs/
*/__pycache__/*
*.pyc
*.yml
*.yml
# Workflow definitions must be tracked even though other YAML is ignored.
!.github/workflows/*.yml
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,5 +165,49 @@ go run main.go
</details>


## Integration Tests

The integration suite in `tests/` talks to a running server over websocket and
HTTP. Start the server first, then run the suite from the repository root:

```bash
pip install -r tests/requirements.txt
python -m tests.main
```

Run a single test, or list the available test names:

```bash
python -m tests.main --test test_upload_and_file_pulse
python -m tests.main --list
```

### Environment variables

| Variable | Default | Purpose |
|----------|---------|---------|
| `API_URL` | `localhost:8080` | Host:port of the running server. |
| `TEST_TIMEOUT` | `180` | Per-test timeout in seconds. |
| `GITHUB_IMPORT_TEST` | unset | Set to `1` to enable the full GitHub import test. |
| `GITHUB_IMPORT_REPO` | `https://github.com/Anga205/AngaDriveV3` | Repository imported by that test. |
| `GITHUB_IMPORT_TIMEOUT` | `600` | Seconds to wait for the import to finish. |

### Full GitHub import test

The `test_github_import_full_tree` test is opt-in because it needs network
access and `git`, and it clones a real repository. It clones the repository
locally, imports it through AngaDrive, then recursively verifies that every
folder became a collection, every file was added, and every file is
downloadable and byte-identical to the clone. It cleans up the imported files
and collections afterwards.

```bash
GITHUB_IMPORT_TEST=1 python -m tests.main --test test_github_import_full_tree
```

This test also runs in its own GitHub Actions workflow
(`.github/workflows/github-import.yml`).


## Links
- **Deployed URL: https://drive.anga.codes**
106 changes: 0 additions & 106 deletions tester/harness.py

This file was deleted.

3 changes: 2 additions & 1 deletion tester/__init__.py → tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
test_collections.py- collection tests (create/get/delete/folder/file ops)
test_homepage.py - homepage pulse tests
test_misc.py - misc tests (unknown type, github import)
test_github_import.py - opt-in full GitHub import verification
registry.py - automatic discovery of async test functions
main.py - entry point for full or single-test runs

Run from the repo root:
python -m tester.main
python -m tests.main
"""
7 changes: 6 additions & 1 deletion tester/config.py → tests/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,9 @@

# Upper bound for one selected test. Individual preview tests have their own
# 60-second polling window inside this budget.
TEST_TIMEOUT = float(os.getenv("TEST_TIMEOUT", "180"))
TEST_TIMEOUT = float(os.getenv("TEST_TIMEOUT", "180"))

# How long to wait for a GitHub repository import to finish. The server clones
# the repository and walks it synchronously, so this must exceed the clone time
# (the server itself gives up after 15 minutes).
GITHUB_IMPORT_TIMEOUT = float(os.getenv("GITHUB_IMPORT_TIMEOUT", "600"))
Loading
Loading