wrolpi/.circleci/config.yml
Roland a9a460c54c
Creating browser extension to facilitate starting downloads. Chrome/Brave and Firefox supported.
The extension is hosted in a sibling repo and
is distributed off-store. Each WROLPi release ships the prebuilt artifacts
under wrolpi/static/extensions/ and serves them at /api/extensions/<file>:

  - wrolpi-chrome.zip       Load-Unpacked sideload for Chrome / Brave / Edge
  - wrolpi-firefox.xpi      Mozilla-signed (unlisted self-distribution),
                            one-click install in any Firefox
  - versions.json           Per-browser version metadata for the install page

Backend (modules/archive/api.py, wrolpi/root_api.py):

  - POST /api/archive/upload accepts an optional repeated `tagNames`
    multipart form field; the upload switch handler applies tags to the
    new FileGroup via FileGroup.set_tags(). Unknown tag names are auto-
    created inside a per-name SAVEPOINT so concurrent inserts on the same
    novel name don't abort the transaction (Tag.name has unique=True).
  - GET /api/extensions returns metadata (per-file availability + size +
    versions.json contents) for the install page.
  - GET /api/extensions/<filename> serves the binary, whitelisted by
    filename. Firefox .xpi is served as application/x-xpinstall WITHOUT a
    Content-Disposition: attachment header, so Firefox triggers its
    add-on install handler instead of saving the file.

Frontend (app/src/):

  - New /admin/extension page (linked from AdminRoute) detects the user's
    browser via navigator.userAgent and renders an install card per
    Firefox / Chromium / Other. Pulls metadata from /api/extensions to
    show file size and version, and gracefully reports 'Not yet
    available' when binaries are missing.
  - Dashboard's Getters component supports a deep link from the
    extension's 'Configure Download' button:
      /?downloader=<archive|video|...>&download_url=<u1>&download_url=<u2>
    On mount, the matching downloader form auto-opens with URLs pre-
    filled. Query params are cleared on close so a refresh doesn't
    re-open the modal.
  - DownloadMenu and the per-downloader forms accept an `initialUrls`
    seed via the existing `download` prop pattern, joined with newlines
    for the `urls` textarea (and first URL for single-URL forms).

Behavior is fully backwards compatible: pre-existing API callers can
still POST to /api/archive/upload without `tagNames`, and the
DashboardPage modal continues to open via the existing button click
when no deep-link query params are present.
2026-05-03 11:48:50 -06:00

205 lines
6.2 KiB
YAML

# Use the latest 2.1 version of CircleCI pipeline process engine.
# See: https://circleci.com/docs/2.0/configuration-reference
version: 2.1
# Define a job to be invoked later in a workflow.
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
jobs:
api-tests-3-11:
docker:
- image: cimg/python:3.11
- image: cimg/postgres:15.6
environment:
POSTGRES_USER: postgres
POSTGRES_DB: wrolpi
POSTGRES_PASSWORD: "wrolpi"
# `large` (4 vCPU, 8 GB) so pytest-xdist's `-nauto` has room to scale.
resource_class: large
steps:
- checkout
- run: sudo apt-get update
- run: sudo apt-get install -y ffmpeg catdoc
- restore_cache:
key: deps-3.11-{{ checksum "requirements.txt" }}-5
- run:
name: Install Requirements
command: |
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
- save_cache:
key: deps-3.11-{{ checksum "requirements.txt" }}-5
paths:
- "venv"
# `-nauto` parallelizes across all available cores via pytest-xdist.
# `-svv` was dumping the full test stdout to CircleCI logs on every run,
# which inflated wall time and produced multi-MB log artifacts; dropped.
- run:
command: './venv/bin/pytest -nauto --junitxml=test-results.xml'
- store_test_results:
path: test-results.xml
api-alembic-migrations:
docker:
- image: cimg/python:3.11
- image: cimg/postgres:15.6
environment:
POSTGRES_USER: wrolpi
POSTGRES_DB: wrolpi
POSTGRES_PASSWORD: "wrolpi"
resource_class: medium
steps:
- checkout
- restore_cache:
key: deps-3.11-{{ checksum "requirements.txt" }}-5
- run:
name: Install Requirements
command: |
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
- save_cache:
key: deps-3.11-{{ checksum "requirements.txt" }}-5
paths:
- "venv"
- run:
name: Run Alembic Migrations
command: ./venv/bin/python ./main.py db upgrade
- run:
name: Check for Missing Migrations
command: ./venv/bin/python ./main.py db check
api-tests-3-12:
docker:
- image: cimg/python:3.12
- image: cimg/postgres:15.6
environment:
POSTGRES_USER: postgres
POSTGRES_DB: wrolpi
POSTGRES_PASSWORD: "wrolpi"
resource_class: large
steps:
- checkout
- run: sudo apt-get update
- run: sudo apt-get install -y ffmpeg catdoc
- restore_cache:
key: deps-3.12-{{ checksum "requirements.txt" }}-5
- run:
name: Install Requirements
command: |
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
- save_cache:
key: deps-3.12-{{ checksum "requirements.txt" }}-5
paths:
- "venv"
- run:
command: './venv/bin/pytest -nauto'
sanic-api-start:
docker:
- image: cimg/python:3.11
steps:
- checkout
- restore_cache:
key: deps-3.11-{{ checksum "requirements.txt" }}-5
- run:
name: Install dependencies
command: |
python -m venv venv
. venv/bin/activate
pip install -r requirements.txt
sudo mkdir -p /media/wrolpi
- run:
name: Start Sanic API
command: |
. venv/bin/activate
sanic main:api_app -H 0.0.0.0 -p 8081
background: true
- run:
name: Test Sanic API
command: |
sleep 20
curl http://0.0.0.0:8081/api/echo
- run:
name: Stop Sanic API
command: pkill -f sanic
react-app-start:
docker:
- image: cimg/node:20.13
resource_class: large
steps:
- checkout
- restore_cache:
key: app-{{ checksum "app/package-lock.json" }}
- run: cd app && npm install --legacy-peer-deps
- save_cache:
key: app-{{ checksum "app/package-lock.json" }}
paths:
- ./app/node_modules
- run:
name: Build React App
command: cd app && DISABLE_ESLINT_PLUGIN=true npm run build
- run:
name: Start React App
command: cd app && DISABLE_ESLINT_PLUGIN=true npm run start
background: true
- run:
name: Test React App
command: |
sleep 20
curl http://0.0.0.0:3000/manifest.json
- run:
name: Stop React App
command: pkill -f npm
# Jest tests moved to GitHub Actions (.github/workflows/jest-tests.yml)
cypress-e2e-tests:
docker:
- image: cimg/node:20.18-browsers
resource_class: large
steps:
- checkout
- restore_cache:
key: app-browsers-{{ checksum "app/package-lock.json" }}
- run:
name: Install Dependencies
command: cd app && npm install --legacy-peer-deps
- save_cache:
key: app-browsers-{{ checksum "app/package-lock.json" }}
paths:
- ./app/node_modules
- run:
name: Start React App in Background
command: cd app && DISABLE_ESLINT_PLUGIN=true npm start
background: true
- run:
name: Wait for React App
command: |
for i in {1..60}; do
if curl -s http://localhost:3000 > /dev/null; then
echo "React app is ready!"
exit 0
fi
echo "Waiting for React app... ($i/60)"
sleep 2
done
echo "React app failed to start"
exit 1
- run:
name: Run Cypress Tests
command: cd app && CI=true npx cypress run
- store_artifacts:
path: app/cypress/videos
- store_artifacts:
path: app/cypress/screenshots
workflows:
wrolpi-api-tests:
jobs:
- sanic-api-start
- api-tests-3-11
- api-alembic-migrations
# - api-tests-3-12 Sanic does not yet support 3.12.
wrolpi-app-test:
jobs:
- react-app-start
# jest-tests moved to GitHub Actions
- cypress-e2e-tests