Add dynamic color theme system with preset themes and customization #13173
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test | |
| # newer commits in the same PR abort running ones for the same workflow | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| on: | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| branches: | |
| - master | |
| workflow_dispatch: | |
| inputs: | |
| debug_enabled: | |
| type: boolean | |
| description: "Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)" | |
| required: false | |
| default: false | |
| env: | |
| PGDATABASE: smc | |
| PGUSER: smc | |
| PGHOST: localhost | |
| COCALC_MODE: "single-user" | |
| jobs: | |
| doclinks: | |
| runs-on: ubuntu-latest | |
| # install python3, package requests, and run the script ./src/scripts/check_doc_links.py | |
| steps: | |
| - name: Setup tmate session | |
| uses: mxschmitt/action-tmate@v3 | |
| if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }} | |
| with: | |
| detached: true | |
| - uses: actions/checkout@v4 | |
| - name: Install python3 requests | |
| run: sudo apt-get install python3-requests | |
| - name: Check doc links | |
| run: cd src/scripts && python3 check_doc_urls.py | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ | |
| node-version: | |
| - "20" | |
| pg-version: | |
| - "13.12" | |
| - "16" | |
| steps: | |
| # Enable tmate debugging of manually-triggered workflows if the input option was provided | |
| - name: Setup tmate session | |
| uses: mxschmitt/action-tmate@v3 | |
| if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }} | |
| with: | |
| detached: true | |
| - uses: actions/checkout@v4 | |
| - name: Start optimized Postgres (RAM-disk & No Durability) | |
| run: | | |
| docker run -d \ | |
| --name postgres \ | |
| --tmpfs /var/lib/postgresql/data \ | |
| -p 5432:5432 \ | |
| -e POSTGRES_DB=smc \ | |
| -e POSTGRES_USER=smc \ | |
| -e POSTGRES_HOST_AUTH_METHOD=trust \ | |
| -e POSTGRES_INITDB_ARGS="--no-sync" \ | |
| postgres:${{ matrix.pg-version }} \ | |
| postgres -c fsync=off -c synchronous_commit=off -c full_page_writes=off | |
| - name: Wait for Postgres to be ready | |
| run: | | |
| if ! timeout 120s bash -c 'until docker exec postgres pg_isready -U smc -d smc; do sleep 1; done'; then | |
| docker logs postgres || true | |
| exit 1 | |
| fi | |
| - name: Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| # https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#caching-packages-data | |
| # caching, etc., doesn't work without using "uses: pnpm/action-setup@v2", and that | |
| # doesn't work, since it makes assumptions about the layout of the repo (e.g., where package.json is), | |
| # which aren't true. | |
| # cache: "pnpm" | |
| # cache-dependency-path: "src/packages/pnpm-lock.yaml" | |
| - name: Set up Python venv and Jupyter kernel | |
| run: | | |
| python3 -m pip install --upgrade pip virtualenv | |
| python3 -m virtualenv venv | |
| source venv/bin/activate | |
| pip install ipykernel | |
| python -m ipykernel install --prefix=./jupyter-local --name python3-local --display-name "Python 3 (Local)" | |
| - name: install pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| run_install: false | |
| - name: build | |
| run: cd src && pnpm run make | |
| - name: lint (eslint) | |
| run: cd src/packages/static && pnpm run lint | |
| - name: lint (eslint frontend) | |
| run: cd src/packages/frontend && pnpm run lint | |
| # This runs all the tests with text output and jest-junit reporters to generate junit.xml reports | |
| # That test-github-ci target runs workspaces.py for testing, which in turn runs the depchecks | |
| - name: test | |
| run: source venv/bin/activate && cd src && pnpm run test-github-ci --report | |
| - name: upload test results | |
| uses: actions/upload-artifact@v4 # upload test results | |
| if: ${{ !cancelled() }} # run this step even if previous step failed | |
| with: | |
| name: "test-results-node-${{ matrix.node-version }}-pg-${{ matrix.pg-version }}" | |
| path: 'src/packages/*/junit.xml' | |
| - name: Start CoCalc Hub | |
| run: | | |
| # Create conat password for hub internal authentication | |
| mkdir -p src/data/secrets | |
| echo "test-conat-password-$(date +%s)" > src/data/secrets/conat-password | |
| chmod 600 src/data/secrets/conat-password | |
| cd src/packages/hub | |
| pnpm run hub-project-dev-nobuild > hub.log 2>&1 & | |
| HUB_PID=$! | |
| echo $HUB_PID > hub.pid | |
| echo "Hub started with PID $HUB_PID" | |
| # Check if process is still running after a moment | |
| sleep 2 | |
| if ! kill -0 $HUB_PID 2>/dev/null; then | |
| echo "Error: Hub process died immediately after starting" | |
| echo "Hub log:" | |
| cat hub.log | |
| exit 1 | |
| fi | |
| env: | |
| PGDATABASE: smc | |
| PGUSER: smc | |
| PGHOST: localhost | |
| COCALC_MODE: single-user | |
| COCALC_TEST_MODE: yes | |
| DEBUG: 'cocalc:*,-cocalc:silly:*,hub:*,project:*' | |
| - name: Wait for hub readiness | |
| run: | | |
| MAX_ATTEMPTS=30 | |
| READY=false | |
| for i in $(seq 1 $MAX_ATTEMPTS); do | |
| if curl -sf --max-time 3 http://localhost:5000/healthcheck > /dev/null; then | |
| echo "Hub is ready" | |
| READY=true | |
| break | |
| fi | |
| echo "Waiting for hub... ($i/$MAX_ATTEMPTS)" | |
| sleep 3 | |
| done | |
| if [ "$READY" = "false" ]; then | |
| echo "Hub failed to become ready after $MAX_ATTEMPTS attempts" | |
| echo "Hub log:" | |
| cat src/packages/hub/hub.log || echo "No log file found" | |
| exit 1 | |
| fi | |
| - name: Create CI admin user and API key | |
| run: | | |
| cd src/packages/hub | |
| OUTPUT=$(node dist/run/test-create-admin.js) | |
| # Split output into account_id and API key (format: UUID;api-key) | |
| ACCOUNT_ID=$(echo "$OUTPUT" | cut -d';' -f1) | |
| API_KEY=$(echo "$OUTPUT" | cut -d';' -f2) | |
| # Store in separate files | |
| echo "$ACCOUNT_ID" > ../../account_id.txt | |
| echo "$API_KEY" > ../../api_key.txt | |
| # Validate account ID (UUID format) | |
| if ! echo "$ACCOUNT_ID" | grep -qE '^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$'; then | |
| echo "Error: Invalid account ID format: $ACCOUNT_ID" | |
| exit 1 | |
| fi | |
| # Validate API key was created | |
| if [ ! -s ../../api_key.txt ]; then | |
| echo "Error: API key file is empty or missing" | |
| exit 1 | |
| fi | |
| if ! echo "$API_KEY" | grep -qE '^sk-[A-Za-z0-9]+$'; then | |
| echo "Error: Invalid API key format: $API_KEY" | |
| exit 1 | |
| fi | |
| echo "Account ID: $ACCOUNT_ID" | |
| echo "API key created successfully" | |
| env: | |
| PGDATABASE: smc | |
| PGUSER: smc | |
| PGHOST: localhost | |
| - name: Restart CoCalc Hub | |
| run: | | |
| HUB_PID=$(cat src/packages/hub/hub.pid) | |
| echo "Stopping hub with PID $HUB_PID" | |
| kill $HUB_PID || true | |
| # Wait a bit for graceful shutdown | |
| sleep 5 | |
| # Force kill if still running | |
| kill -9 $HUB_PID 2>/dev/null || true | |
| # Read the admin account ID created in the previous step | |
| cd src/packages/hub | |
| ADMIN_ACCOUNT_ID=$(cat ../../account_id.txt) | |
| echo "Using admin account ID: $ADMIN_ACCOUNT_ID" | |
| # Export env vars for the hub process | |
| export COCALC_SETTING_JUPYTER_API_ENABLED=yes | |
| export COCALC_SETTING_JUPYTER_ACCOUNT_ID=$ADMIN_ACCOUNT_ID | |
| export COCALC_SETTING_JUPYTER_PROJECT_POOL_SIZE=1 | |
| # Start hub with new configuration | |
| pnpm run hub-project-dev-nobuild > hub.log 2>&1 & | |
| HUB_PID=$! | |
| echo $HUB_PID > hub.pid | |
| echo "Hub restarted with PID $HUB_PID" | |
| # Check if process is still running after a moment | |
| sleep 2 | |
| if ! kill -0 $HUB_PID 2>/dev/null; then | |
| echo "Error: Hub process died immediately after restarting" | |
| echo "Hub log:" | |
| cat hub.log | |
| exit 1 | |
| fi | |
| # Wait for hub to be ready | |
| MAX_ATTEMPTS=30 | |
| READY=false | |
| for i in $(seq 1 $MAX_ATTEMPTS); do | |
| if curl -sf --max-time 3 http://localhost:5000/healthcheck > /dev/null; then | |
| echo "Hub is ready after restart" | |
| READY=true | |
| break | |
| fi | |
| echo "Waiting for hub to be ready... ($i/$MAX_ATTEMPTS)" | |
| sleep 3 | |
| done | |
| if [ "$READY" = "false" ]; then | |
| echo "Hub failed to become ready after restart" | |
| echo "Hub log:" | |
| cat hub.log | |
| exit 1 | |
| fi | |
| env: | |
| PGDATABASE: smc | |
| PGUSER: smc | |
| PGHOST: localhost | |
| COCALC_MODE: single-user | |
| COCALC_TEST_MODE: yes | |
| DEBUG: 'cocalc:*,-cocalc:silly:*,hub:*,project:*' | |
| - name: Install uv for cocalc-api tests | |
| run: curl -LsSf https://astral.sh/uv/install.sh | sh && echo "$HOME/.local/bin" >> $GITHUB_PATH | |
| - name: Run cocalc-api tests | |
| run: | | |
| export COCALC_API_KEY=$(cat src/api_key.txt) | |
| export COCALC_HOST=http://localhost:5000 | |
| export CI=true | |
| cd src/python/cocalc-api && make ci | |
| env: | |
| PGDATABASE: smc | |
| PGUSER: smc | |
| PGHOST: localhost | |
| - name: Run api/v2 exec e2e tests | |
| run: | | |
| export COCALC_API_KEY=$(cat src/api_key.txt) | |
| export COCALC_HOST=http://localhost:5000 | |
| export COCALC_PROJECT_ID=$(cd src/python/cocalc-api && make ci-create-project) | |
| cd src/packages/next && pnpm run test-apiv2-e2e | |
| env: | |
| PGDATABASE: smc | |
| PGUSER: smc | |
| PGHOST: localhost | |
| - name: Stop CoCalc Hub | |
| if: always() | |
| run: | | |
| if [ -f src/packages/hub/hub.pid ]; then | |
| HUB_PID=$(cat src/packages/hub/hub.pid) | |
| echo "Stopping hub with PID $HUB_PID" | |
| kill $HUB_PID || true | |
| # Wait a bit for graceful shutdown | |
| sleep 5 | |
| # Force kill if still running | |
| kill -9 $HUB_PID 2>/dev/null || true | |
| fi | |
| - name: Upload hub logs | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: "hub-logs-node-${{ matrix.node-version }}-pg-${{ matrix.pg-version }}" | |
| path: 'src/packages/hub/hub.log' | |
| - name: Upload cocalc-api test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: "cocalc-api-test-results-node-${{ matrix.node-version }}-pg-${{ matrix.pg-version }}" | |
| path: 'src/python/cocalc-api/test-results.xml' |