Skip to content

Conversation

@Oksamies
Copy link
Contributor

  • Added testing instructions to README.md for Docker usage.
  • Updated package.json to include new test and coverage scripts for containerized testing.
  • Modified test files to utilize environment variables for API host configuration.
  • Introduced vite-env.d.ts to define environment variables for TypeScript.
  • Created run_test_container.mjs to manage test execution in Docker.
  • Updated Dockerfile.test and docker-compose.yml for test service configuration.
  • Added entrypoint script for test container setup.
  • Refactored CI scripts to use Docker for backend services.

@coderabbitai
Copy link

coderabbitai bot commented Dec 19, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds Docker-backed frontend test infrastructure and orchestration scripts, plus related typings and test tweaks. New files: tools/thunderstore-test-backend/Dockerfile.test, docker-compose.yml, entrypoint.test.sh; tools/scripts/run_test_container.mjs; CI script adjustments to start/stop backend; README subsection "Testing (Docker)"; npm scripts test:container and coverage:container; Vite ambient typings (vite-env.d.ts) and tsconfig updates; tests now read VITE_THUNDERSTORE_TEST_API_HOST with a fallback; vite added to devDependencies.

Possibly related PRs

  • Tests and coverage #1555 — touches the same test infra and files (vite-env.d.ts, tsconfig changes, and tests that read VITE_THUNDERSTORE_TEST_API_HOST).

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: enhancing testing setup with Docker integration and Vitest configuration, which aligns with the comprehensive changeset.
Description check ✅ Passed The description is directly related to the changeset, detailing multiple aspects of the Docker integration and Vitest configuration changes across various files.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch testing_setup

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the testing infrastructure by introducing Docker-based containerized testing for the frontend test suite. The main goal is to provide a consistent, reproducible testing environment that runs Vitest browser mode tests with Playwright in Docker containers.

Key changes:

  • Added Docker Compose configuration for a dedicated test service that syncs the repository, installs dependencies, and runs tests in an isolated container
  • Created orchestration script (run_test_container.mjs) to manage backend service startup, health checks, and test execution workflow
  • Modified test files to support configurable API host via environment variables, enabling tests to run both locally and in containers

Reviewed changes

Copilot reviewed 12 out of 14 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
tools/visual-diff-ci/run_ci_script.py Updated to use explicit service names when starting backend and split docker compose command into array format
tools/thunderstore-test-backend/entrypoint.test.sh New entrypoint script that handles source syncing, dependency installation, and test execution inside the test container
tools/thunderstore-test-backend/docker-compose.yml Added cyberstorm-tests service configuration with CORS settings update and new volumes for test workspace
tools/thunderstore-test-backend/Dockerfile.test New Dockerfile defining the test container image with Node.js 24, Playwright, and rsync
tools/test-ci/run_ci_script.py Updated to use explicit service names when starting backend and split docker compose command into array format
tools/scripts/run_test_container.mjs New Node.js script orchestrating Docker-based test execution with backend health checks and cleanup
packages/thunderstore-api/tsconfig.json Added "vite/client" to types array to support Vite environment variable typing
packages/thunderstore-api/src/vite-env.d.ts New type definitions for Vite environment variables including VITE_THUNDERSTORE_TEST_API_HOST
packages/thunderstore-api/src/tests/defaultConfig.ts Updated to read API host from environment variable with fallback to localhost
packages/dapper-ts/tsconfig.json Added "vite/client" to types array to support Vite environment variable typing
packages/dapper-ts/src/vite-env.d.ts New type definitions for Vite environment variables including VITE_THUNDERSTORE_TEST_API_HOST
packages/dapper-ts/src/tests/index.test.ts Updated to read API host from environment variable with fallback to localhost
package.json Added test:container and coverage:container scripts for running tests via Docker
README.md Added documentation section explaining Docker-based testing setup and usage

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 26 to 28
# Split RSYNC_ARGS safely into an argv-style array.
# shellcheck disable=SC2206
rsync_args=( $RSYNC_ARGS )
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The RSYNC_ARGS variable is split using word splitting, which is unsafe if any argument contains spaces or special characters. While the shellcheck directive SC2206 is present, this could still lead to unexpected behavior if RSYNC_ARGS is ever modified to include arguments with spaces. Consider using a safer approach like read -ra or mapfile if the args need to be configurable, or simply pass RSYNC_ARGS_DEFAULT directly to rsync if it's not meant to be overridden with complex arguments.

Suggested change
# Split RSYNC_ARGS safely into an argv-style array.
# shellcheck disable=SC2206
rsync_args=( $RSYNC_ARGS )
# Split RSYNC_ARGS into an argv-style array without pathname expansion.
read -r -a rsync_args <<<"$RSYNC_ARGS"

Copilot uses AI. Check for mistakes.
Comment on lines 176 to 190
run_command(
[
"docker",
"compose",
"up",
"db",
"redis",
"rabbitmq",
"minio",
"django",
],
cwd=BACKEND_DIR,
)
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docker compose up command is missing the -d flag to run containers in detached mode. Without this flag, the command will run in the foreground and block execution, preventing the subsequent wait_for_url call from ever executing. This will cause the CI script to hang.

Copilot uses AI. Check for mistakes.
Comment on lines 115 to 129
run_command(
[
"docker",
"compose",
"up",
"db",
"redis",
"rabbitmq",
"minio",
"django",
],
cwd=BACKEND_DIR,
)
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docker compose up command is missing the -d flag to run containers in detached mode. Without this flag, the command will run in the foreground and block execution, preventing the subsequent wait_for_url call from ever executing. This will cause the CI script to hang.

Copilot uses AI. Check for mistakes.
Comment on lines +107 to +108


Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cyberstorm-tests service lacks a depends_on configuration for the backend services (db, redis, rabbitmq, minio, django). While the run_test_container.mjs script manually starts these services first, defining explicit dependencies would make the service configuration more self-documenting and would help if the service is run directly with docker compose.

Suggested change
depends_on:
- db
- redis
- rabbitmq
- minio
- django

Copilot uses AI. Check for mistakes.
Comment on lines 174 to 175
// published host port and we implicitly wait for the setup commands in
// run_test_backend.py to finish.
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment references "run_test_backend.py" but this script file doesn't appear to be part of this pull request. If the referenced file exists elsewhere in the codebase, the comment is correct. However, if it doesn't exist or was renamed, this comment should be updated to reference the correct file or mechanism.

Suggested change
// published host port and we implicitly wait for the setup commands in
// run_test_backend.py to finish.
// published host port and we implicitly wait for the backend setup
// commands inside the containers to finish.

Copilot uses AI. Check for mistakes.
async function waitForUrl(url, { timeoutMs = 120_000, pollMs = 1_000 } = {}) {
const deadline = Date.now() + timeoutMs;

// Node 24 has global fetch.
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment states "Node 24 has global fetch" which is technically true (global fetch was added in Node.js 18), but this script is being executed on the host machine, not inside the Docker container. The repository's package.json specifies node >=20.17.0 as the engine requirement. While Node.js 20 does have global fetch (since 18.0.0), the comment creates an expectation that Node.js 24 is required for this script to work, which is misleading. Consider updating the comment to clarify that Node.js 18+ has global fetch, or remove it entirely if it's not necessary.

Suggested change
// Node 24 has global fetch.
// Node 18+ has global fetch.

Copilot uses AI. Check for mistakes.
Comment on lines 36 to 70
async function waitForUrl(url, { timeoutMs = 120_000, pollMs = 1_000 } = {}) {
const deadline = Date.now() + timeoutMs;

// Node 24 has global fetch.
while (Date.now() < deadline) {
try {
const abortController = new AbortController();
const timeout = setTimeout(() => abortController.abort(), 3000);
const response = await fetch(url, {
signal: abortController.signal,
// The backend may redirect to host.docker.internal (needed for browser-in-container),
// but that hostname isn't guaranteed to resolve on the host. Don't follow redirects.
redirect: "manual",
});
clearTimeout(timeout);

// Treat any successful/redirect response as "up".
if (response.status >= 200 && response.status < 400) {
return;
}
} catch {
// ignore until timeout
}

const remainingSeconds = Math.max(
0,
Math.round((deadline - Date.now()) / 1000)
);
console.log(`Waiting for ${url} (${remainingSeconds}s remaining)`);
await new Promise((r) => setTimeout(r, pollMs));
}

throw new Error(`Timed out waiting for ${url}`);
}

Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused function waitForUrl.

Suggested change
async function waitForUrl(url, { timeoutMs = 120_000, pollMs = 1_000 } = {}) {
const deadline = Date.now() + timeoutMs;
// Node 24 has global fetch.
while (Date.now() < deadline) {
try {
const abortController = new AbortController();
const timeout = setTimeout(() => abortController.abort(), 3000);
const response = await fetch(url, {
signal: abortController.signal,
// The backend may redirect to host.docker.internal (needed for browser-in-container),
// but that hostname isn't guaranteed to resolve on the host. Don't follow redirects.
redirect: "manual",
});
clearTimeout(timeout);
// Treat any successful/redirect response as "up".
if (response.status >= 200 && response.status < 400) {
return;
}
} catch {
// ignore until timeout
}
const remainingSeconds = Math.max(
0,
Math.round((deadline - Date.now()) / 1000)
);
console.log(`Waiting for ${url} (${remainingSeconds}s remaining)`);
await new Promise((r) => setTimeout(r, pollMs));
}
throw new Error(`Timed out waiting for ${url}`);
}

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Oksamies commented Dec 19, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (6)
tools/thunderstore-test-backend/Dockerfile.test (1)

1-1: Consider aligning Node version with project requirements.

The package.json files specify >=20.17.0. While Node 24 satisfies this, using node:20-bookworm would be more consistent with the project's stated requirements.

tools/scripts/run_test_container.mjs (3)

39-39: Comment about Node version is misleading.

Global fetch has been available since Node 18, not just Node 24.


174-175: Comment references potentially non-existent file.

The comment mentions run_test_backend.py - verify this file exists or update the comment.


36-70: Unused function waitForUrl.

This function is never called. waitForDjangoInContainer is used instead. Remove dead code.

tools/thunderstore-test-backend/entrypoint.test.sh (1)

26-29: Word splitting of RSYNC_ARGS is fragile.

The shellcheck disable is in place, but using read -ra would be safer for potential edge cases.

Safer approach
   # Split RSYNC_ARGS safely into an argv-style array.
-  # shellcheck disable=SC2206
-  rsync_args=( $RSYNC_ARGS )
+  read -r -a rsync_args <<<"$RSYNC_ARGS"
   rsync "${rsync_args[@]}" /src/ /workspace/
tools/thunderstore-test-backend/docker-compose.yml (1)

85-107: Add explicit service dependencies.

The cyberstorm-tests service should declare depends_on for backend services (db, redis, rabbitmq, minio, django) to make the service configuration self-documenting and ensure proper startup order when running directly with docker compose.

Suggested addition
  cyberstorm-tests:
    user: "0:0"
    build:
      context: .
      dockerfile: Dockerfile.test
    working_dir: /workspace
+   depends_on:
+     - db
+     - redis
+     - rabbitmq
+     - minio
+     - django
    volumes:
🧹 Nitpick comments (5)
tools/thunderstore-test-backend/Dockerfile.test (1)

16-20: Playwright directory created after browser installation.

The mkdir -p "$PLAYWRIGHT_BROWSERS_PATH" happens after npx playwright install chromium, but Playwright will attempt to write to that path during install. Since PLAYWRIGHT_BROWSERS_PATH is set before the install, Playwright should create it automatically, making the explicit mkdir potentially redundant. However, the chown is still valuable for the node user.

Consider reordering to create the directory before the install for clarity:

Suggested reordering
 ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
-RUN npm -g i "playwright@${PLAYWRIGHT_VERSION}" \
+RUN mkdir -p "$PLAYWRIGHT_BROWSERS_PATH" \
+	&& npm -g i "playwright@${PLAYWRIGHT_VERSION}" \
 	&& npx playwright install-deps chromium \
 	&& npx playwright install chromium \
-	&& mkdir -p "$PLAYWRIGHT_BROWSERS_PATH" \
 	&& chown -R node:node "$PLAYWRIGHT_BROWSERS_PATH"
packages/dapper-ts/src/vite-env.d.ts (1)

1-6: Duplicate declaration exists in thunderstore-api.

This file is identical to packages/thunderstore-api/src/vite-env.d.ts. While per-package vite-env.d.ts files are a common Vite pattern, you could consider extracting shared env types to a common location if more packages need them.

The typing itself looks correct.

tools/thunderstore-test-backend/docker-compose.yml (3)

7-7: Minor redundancy with existing CORS setting.

Line 6 already sets CORS_ALLOWED_ORIGINS: "*". The addition of CORS_ALLOW_ALL_ORIGINS: "True" may be redundant depending on your Django CORS middleware version, though both might be needed for compatibility. Consider verifying if both are necessary.


86-86: Review whether running as root is necessary.

The service runs as root (user: "0:0"). Consider whether this is required for your test operations, as running containers with elevated privileges should be avoided when possible, even in test environments.


102-102: Consider moving RSYNC_ARGS to the entrypoint script.

Defining RSYNC_ARGS as an environment variable in docker-compose is unusual. This might be better suited as a variable within the entrypoint script or passed as a build argument, depending on how it's consumed.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2cbec7e and 272a60d.

📒 Files selected for processing (14)
  • README.md (1 hunks)
  • package.json (1 hunks)
  • packages/dapper-ts/src/__tests__/index.test.ts (1 hunks)
  • packages/dapper-ts/src/vite-env.d.ts (1 hunks)
  • packages/dapper-ts/tsconfig.json (1 hunks)
  • packages/thunderstore-api/src/__tests__/defaultConfig.ts (1 hunks)
  • packages/thunderstore-api/src/vite-env.d.ts (1 hunks)
  • packages/thunderstore-api/tsconfig.json (1 hunks)
  • tools/scripts/run_test_container.mjs (1 hunks)
  • tools/test-ci/run_ci_script.py (1 hunks)
  • tools/thunderstore-test-backend/Dockerfile.test (1 hunks)
  • tools/thunderstore-test-backend/docker-compose.yml (3 hunks)
  • tools/thunderstore-test-backend/entrypoint.test.sh (1 hunks)
  • tools/visual-diff-ci/run_ci_script.py (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-01T11:36:11.065Z
Learnt from: anttimaki
Repo: thunderstore-io/thunderstore-ui PR: 1559
File: packages/ts-api-react/package.json:16-18
Timestamp: 2025-10-01T11:36:11.065Z
Learning: In the thunderstore-ui repository, exact Node version pinning (e.g., "24.9.0") is intentionally used in package.json engines fields rather than semver ranges, to ensure consistency across environments.

Applied to files:

  • tools/scripts/run_test_container.mjs
  • tools/thunderstore-test-backend/Dockerfile.test
🧬 Code graph analysis (1)
tools/test-ci/run_ci_script.py (1)
tools/visual-diff-ci/run_ci_script.py (3)
  • run_command (76-87)
  • wait_for_url (153-169)
  • stop_backend (194-195)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build
  • GitHub Check: Generate visual diffs
🔇 Additional comments (19)
packages/dapper-ts/tsconfig.json (1)

26-26: LGTM - Consistent with thunderstore-api tsconfig.

Same addition of "vite/client" types for environment variable support.

package.json (1)

15-17: LGTM - New containerized test scripts.

The new test:container and coverage:container scripts enable Docker-based testing as documented in the README.

packages/dapper-ts/src/__tests__/index.test.ts (1)

12-16: LGTM - Environment-driven test configuration.

The use of import.meta.env.VITE_THUNDERSTORE_TEST_API_HOST with a sensible fallback enables flexible test execution across different environments (local, Docker, CI).

README.md (1)

153-171: LGTM - Clear documentation for Docker-based testing.

The new section provides straightforward instructions for running tests in a containerized environment, with proper prerequisites called out.

tools/test-ci/run_ci_script.py (2)

115-129: LGTM - Explicit service list with proper detached mode.

The addition of the -d flag addresses the previous review concern about blocking execution. Explicitly listing services (db, redis, rabbitmq, minio, django) and using --remove-orphans improves reliability.


134-134: LGTM - Orphan cleanup on teardown.

The --remove-orphans flag ensures clean teardown of test infrastructure.

packages/thunderstore-api/src/__tests__/defaultConfig.ts (1)

3-5: LGTM - Consistent environment-driven configuration.

This mirrors the pattern used in dapper-ts tests, providing uniform configuration across packages.

tools/visual-diff-ci/run_ci_script.py (2)

176-190: LGTM - Consistent with test-ci script improvements.

The explicit service list with -d and --remove-orphans flags addresses the past review concern and maintains consistency across CI scripts.


195-195: LGTM - Clean teardown.

Consistent orphan cleanup as in test-ci script.

packages/thunderstore-api/src/vite-env.d.ts (1)

1-6: LGTM!

Ambient typing is correct for Vite's import.meta.env pattern.

tools/scripts/run_test_container.mjs (3)

12-34: LGTM!

Clean utility function with proper error propagation and exit code handling.


71-120: Good use of in-container health check.

The inline Python approach to check Django readiness from within the container network is a solid pattern - avoids host networking issues and ensures the check runs in the same network context as the tests.


143-203: Well-structured orchestration with proper cleanup.

The try/finally ensures teardown even on failure, and the best-effort .catch() on cleanup prevents masking the original error. Good defensive coding.

tools/thunderstore-test-backend/entrypoint.test.sh (3)

1-11: LGTM!

Good defensive setup: strict mode enabled, proper permissions on secrets file.


38-46: Solid dependency installation logic.

The check for empty node_modules OR missing vitest executable ensures deps are installed when needed. --production=false correctly includes dev dependencies required for testing.


48-52: LGTM!

Using exec for the final command is correct - it replaces the shell process and ensures proper signal handling.

tools/thunderstore-test-backend/Dockerfile.test (1)

5-5: Playwright version alignment with dependencies.

Version 1.55.1 matches the project's package.json declarations, but is 2 minor versions behind the latest stable release (1.57.0). Decide whether to update this version to track the latest or keep it pinned to match declared dependencies.

tools/thunderstore-test-backend/docker-compose.yml (2)

41-41: LGTM!

Changing PRIMARY_HOST to use the service name django:8000 is correct for inter-container communication within the Docker network.


115-117: Provide the npmrc secret file before running the tests.

The docker-compose configuration expects ../../build-secrets/.npmrc (relative to this file) to exist, as documented in build-secrets/README.md. This file is required for the cyberstorm-tests service and must be created locally before the tests will start.

Comment on lines 26 to 29
# Split RSYNC_ARGS safely into an argv-style array.
# shellcheck disable=SC2206
rsync_args=( $RSYNC_ARGS )
rsync "${rsync_args[@]}" /src/ /workspace/
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsafe word splitting in rsync arguments. The line rsync_args=( $RSYNC_ARGS ) performs unquoted expansion which will fail if RSYNC_ARGS contains:

  • Paths with spaces (e.g., --exclude="my file")
  • Glob characters (*, ?, [) which will expand to matching filenames
  • Other special shell characters

The shellcheck disable=SC2206 comment acknowledges this but incorrectly claims it's "safe". While the current usage in docker-compose.yml doesn't trigger these issues, this will break if anyone adds exclude patterns with spaces.

Fix:

# Use bash array with proper quoting
eval "rsync_args=($RSYNC_ARGS)"
# OR use a safer alternative:
IFS=' ' read -r -a rsync_args <<< "$RSYNC_ARGS"

Note: The eval approach handles quoted strings correctly but has its own security implications if RSYNC_ARGS comes from untrusted sources. Since this is container configuration, it should be safe.

Spotted by Graphite Agent

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
tools/thunderstore-test-backend/docker-compose.yml (1)

85-107: Consider adding explicit service dependencies.

While the orchestration script starts services manually, adding depends_on for the backend services (db, redis, rabbitmq, minio, django) would make the configuration more self-documenting and robust if run directly with docker compose.

Suggested dependency declaration
  cyberstorm-tests:
    user: "0:0"
    build:
      context: .
      dockerfile: Dockerfile.test
+   depends_on:
+     - db
+     - redis
+     - rabbitmq
+     - minio
+     - django
    working_dir: /workspace
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 272a60d and a7f22bc.

📒 Files selected for processing (15)
  • README.md (1 hunks)
  • package.json (1 hunks)
  • packages/dapper-ts/src/__tests__/index.test.ts (1 hunks)
  • packages/dapper-ts/src/vite-env.d.ts (1 hunks)
  • packages/dapper-ts/tsconfig.json (1 hunks)
  • packages/thunderstore-api/package.json (1 hunks)
  • packages/thunderstore-api/src/__tests__/defaultConfig.ts (1 hunks)
  • packages/thunderstore-api/src/vite-env.d.ts (1 hunks)
  • packages/thunderstore-api/tsconfig.json (1 hunks)
  • tools/scripts/run_test_container.mjs (1 hunks)
  • tools/test-ci/run_ci_script.py (2 hunks)
  • tools/thunderstore-test-backend/Dockerfile.test (1 hunks)
  • tools/thunderstore-test-backend/docker-compose.yml (3 hunks)
  • tools/thunderstore-test-backend/entrypoint.test.sh (1 hunks)
  • tools/visual-diff-ci/run_ci_script.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (9)
  • README.md
  • packages/thunderstore-api/src/tests/defaultConfig.ts
  • packages/dapper-ts/tsconfig.json
  • tools/thunderstore-test-backend/Dockerfile.test
  • packages/dapper-ts/src/vite-env.d.ts
  • packages/thunderstore-api/tsconfig.json
  • tools/visual-diff-ci/run_ci_script.py
  • tools/thunderstore-test-backend/entrypoint.test.sh
  • tools/scripts/run_test_container.mjs
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-01T11:36:11.065Z
Learnt from: anttimaki
Repo: thunderstore-io/thunderstore-ui PR: 1559
File: packages/ts-api-react/package.json:16-18
Timestamp: 2025-10-01T11:36:11.065Z
Learning: In the thunderstore-ui repository, exact Node version pinning (e.g., "24.9.0") is intentionally used in package.json engines fields rather than semver ranges, to ensure consistency across environments.

Applied to files:

  • packages/thunderstore-api/package.json
🧬 Code graph analysis (1)
tools/test-ci/run_ci_script.py (1)
tools/visual-diff-ci/run_ci_script.py (3)
  • run_command (76-87)
  • wait_for_url (153-169)
  • stop_backend (194-195)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build
  • GitHub Check: Generate visual diffs
🔇 Additional comments (11)
packages/dapper-ts/src/__tests__/index.test.ts (1)

12-16: LGTM!

The environment-driven API host configuration is well-implemented. Nullish coalescing ensures backward compatibility when the environment variable is not set.

package.json (1)

15-17: LGTM!

The containerized test scripts are properly configured and align with the Docker-based testing infrastructure introduced in this PR.

packages/thunderstore-api/src/vite-env.d.ts (1)

1-6: LGTM!

The ambient ImportMeta interface declaration properly extends Vite's typing to include the custom test environment variable. Works correctly with the vite/client types referenced in tsconfig.

tools/test-ci/run_ci_script.py (3)

100-100: LGTM!

The increased timeout to 90 seconds provides better reliability for backend startup in CI environments.


115-129: LGTM!

The explicit service list and -d flag ensure controlled, detached startup. The --remove-orphans flag prevents stale containers from interfering with tests.


134-134: LGTM!

The --remove-orphans flag ensures complete cleanup after test runs.

tools/thunderstore-test-backend/docker-compose.yml (4)

7-7: LGTM!

Permissive CORS is appropriate for the test backend environment.


41-41: LGTM!

Parameterizing PRIMARY_HOST allows flexibility for different test environments while maintaining backward compatibility.


109-113: LGTM!

Named volumes for workspace and caches enable efficient test execution and dependency management.


115-117: No action needed. The .npmrc requirement is already clearly documented in ./build-secrets/README.md, which explicitly mentions that the directory should contain the .npmrc file for build-time secrets. The setup is properly configured with .gitignore rules to exclude actual secrets while preserving documentation.

packages/thunderstore-api/package.json (1)

31-31: Version 7.1.7 is valid and receives security patches.

Important fixes and security patches are backported to vite@7.1, and no risks were detected for vite 7.1.7.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
README.md (1)

153-171: Consider specifying the compose file path.

The section mentions "the dedicated test runner compose file" but doesn't specify which file. Adding the path (e.g., tools/thunderstore-test-backend/docker-compose.yml) would improve clarity.

🔎 Suggested addition
-Frontend tests run in Vitest browser mode (Playwright). To keep the environment consistent, use the dedicated test runner compose file instead of the dev container.
+Frontend tests run in Vitest browser mode (Playwright). To keep the environment consistent, use the dedicated test runner compose file (`tools/thunderstore-test-backend/docker-compose.yml`) instead of the dev container.
tools/thunderstore-test-backend/Dockerfile.test (1)

1-29: Consider adding an explicit USER directive.

The Dockerfile doesn't include a USER directive, so the container runs as root by default. While the entrypoint script may handle user switching, explicitly setting USER node before the ENTRYPOINT would follow Docker security best practices.

🔎 Suggested addition
 RUN chmod +x /usr/local/bin/entrypoint.test.sh
 
+USER node
+
 ENTRYPOINT ["/usr/local/bin/entrypoint.test.sh"]
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a7f22bc and e360607.

📒 Files selected for processing (15)
  • README.md (1 hunks)
  • package.json (1 hunks)
  • packages/dapper-ts/src/__tests__/index.test.ts (1 hunks)
  • packages/dapper-ts/src/vite-env.d.ts (1 hunks)
  • packages/dapper-ts/tsconfig.json (1 hunks)
  • packages/thunderstore-api/package.json (1 hunks)
  • packages/thunderstore-api/src/__tests__/defaultConfig.ts (1 hunks)
  • packages/thunderstore-api/src/vite-env.d.ts (1 hunks)
  • packages/thunderstore-api/tsconfig.json (1 hunks)
  • tools/scripts/run_test_container.mjs (1 hunks)
  • tools/test-ci/run_ci_script.py (2 hunks)
  • tools/thunderstore-test-backend/Dockerfile.test (1 hunks)
  • tools/thunderstore-test-backend/docker-compose.yml (3 hunks)
  • tools/thunderstore-test-backend/entrypoint.test.sh (1 hunks)
  • tools/visual-diff-ci/run_ci_script.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (11)
  • tools/scripts/run_test_container.mjs
  • packages/dapper-ts/src/tests/index.test.ts
  • packages/dapper-ts/src/vite-env.d.ts
  • packages/thunderstore-api/package.json
  • packages/thunderstore-api/src/vite-env.d.ts
  • tools/thunderstore-test-backend/entrypoint.test.sh
  • tools/visual-diff-ci/run_ci_script.py
  • package.json
  • tools/test-ci/run_ci_script.py
  • packages/dapper-ts/tsconfig.json
  • tools/thunderstore-test-backend/docker-compose.yml
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-01T11:36:11.065Z
Learnt from: anttimaki
Repo: thunderstore-io/thunderstore-ui PR: 1559
File: packages/ts-api-react/package.json:16-18
Timestamp: 2025-10-01T11:36:11.065Z
Learning: In the thunderstore-ui repository, exact Node version pinning (e.g., "24.9.0") is intentionally used in package.json engines fields rather than semver ranges, to ensure consistency across environments.

Applied to files:

  • tools/thunderstore-test-backend/Dockerfile.test
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build
  • GitHub Check: Generate visual diffs
🔇 Additional comments (2)
packages/thunderstore-api/tsconfig.json (1)

26-26: LGTM—vite dependency issue resolved.

The addition of "vite/client" types is appropriate now that vite has been added as a dependency (per the previous review resolution). This enables proper typing for import.meta.env used in the test files.

packages/thunderstore-api/src/__tests__/defaultConfig.ts (1)

3-5: LGTM—clean environment variable integration.

The environment variable approach with nullish coalescing fallback maintains backward compatibility while enabling Docker-based test configuration. The pattern is consistent with similar changes across the test suite.


WORKDIR /workspace

ARG PLAYWRIGHT_VERSION=1.55.1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Upgrade Playwright to latest stable version.

The latest stable Playwright version is 1.57.0, but 1.55.1 is hardcoded. The Playwright Docker image v1.55.0 contains vulnerable Chrome binaries, and keeping the version pinned means missing critical security patches and bug fixes.

🤖 Prompt for AI Agents
In tools/thunderstore-test-backend/Dockerfile.test around line 5, the Playwright
version is pinned to ARG PLAYWRIGHT_VERSION=1.55.1 which is out of date and
contains vulnerable browser binaries; update the ARG to the current stable
release (1.57.0) so the Docker image pulls the patched Playwright release, and
run a quick build/test to verify compatibility with the newer Playwright
version.

- Added testing instructions to README.md for Docker usage.
- Updated package.json to include new test and coverage scripts for containerized testing.
- Modified test files to utilize environment variables for API host configuration.
- Introduced vite-env.d.ts to define environment variables for TypeScript.
- Created run_test_container.mjs to manage test execution in Docker.
- Updated Dockerfile.test and docker-compose.yml for test service configuration.
- Added entrypoint script for test container setup.
- Refactored CI scripts to use Docker for backend services.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
tools/thunderstore-test-backend/docker-compose.yml (1)

85-107: Add explicit service dependencies.

The cyberstorm-tests service should declare its dependencies on backend services (db, redis, rabbitmq, minio, django) using depends_on. While run_test_container.mjs may orchestrate the startup order, explicit dependencies make the configuration self-documenting and enable direct service execution via docker compose up cyberstorm-tests.

🔎 Proposed fix
   cyberstorm-tests:
     user: "0:0"
     build:
       context: .
       dockerfile: Dockerfile.test
     working_dir: /workspace
+    depends_on:
+      - db
+      - redis
+      - rabbitmq
+      - minio
+      - django
     volumes:
🧹 Nitpick comments (1)
tools/thunderstore-test-backend/docker-compose.yml (1)

6-7: Consider simplifying CORS configuration.

Both CORS_ALLOWED_ORIGINS: "*" and CORS_ALLOW_ALL_ORIGINS: "True" achieve similar results. Having both settings is redundant. For a test environment, either one is sufficient.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e360607 and 2d0a561.

📒 Files selected for processing (15)
  • README.md (1 hunks)
  • package.json (1 hunks)
  • packages/dapper-ts/src/__tests__/index.test.ts (1 hunks)
  • packages/dapper-ts/src/vite-env.d.ts (1 hunks)
  • packages/dapper-ts/tsconfig.json (1 hunks)
  • packages/thunderstore-api/package.json (1 hunks)
  • packages/thunderstore-api/src/__tests__/defaultConfig.ts (1 hunks)
  • packages/thunderstore-api/src/vite-env.d.ts (1 hunks)
  • packages/thunderstore-api/tsconfig.json (1 hunks)
  • tools/scripts/run_test_container.mjs (1 hunks)
  • tools/test-ci/run_ci_script.py (2 hunks)
  • tools/thunderstore-test-backend/Dockerfile.test (1 hunks)
  • tools/thunderstore-test-backend/docker-compose.yml (3 hunks)
  • tools/thunderstore-test-backend/entrypoint.test.sh (1 hunks)
  • tools/visual-diff-ci/run_ci_script.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (11)
  • packages/thunderstore-api/package.json
  • packages/thunderstore-api/src/vite-env.d.ts
  • tools/scripts/run_test_container.mjs
  • packages/dapper-ts/tsconfig.json
  • tools/test-ci/run_ci_script.py
  • tools/thunderstore-test-backend/Dockerfile.test
  • README.md
  • packages/dapper-ts/src/vite-env.d.ts
  • tools/thunderstore-test-backend/entrypoint.test.sh
  • packages/dapper-ts/src/tests/index.test.ts
  • tools/visual-diff-ci/run_ci_script.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build
  • GitHub Check: Generate visual diffs
🔇 Additional comments (7)
packages/thunderstore-api/tsconfig.json (1)

26-26: LGTM! Types configuration is correct.

The addition of "vite/client" types is appropriate for the Vite-based testing setup. The previous dependency concern has been resolved.

packages/thunderstore-api/src/__tests__/defaultConfig.ts (1)

3-5: LGTM! Environment-driven configuration is well implemented.

The use of import.meta.env.VITE_THUNDERSTORE_TEST_API_HOST with a sensible fallback enables flexible test configuration while maintaining backward compatibility. This aligns well with the Docker-based testing infrastructure.

package.json (1)

15-17: LGTM!

The new container test scripts follow existing naming patterns and properly delegate to the orchestration script. The trailing comma on line 15 is a good practice for cleaner future diffs.

tools/thunderstore-test-backend/docker-compose.yml (4)

41-41: LGTM!

Parameterizing PRIMARY_HOST with a sensible default improves configurability while maintaining backward compatibility.


86-86: Verify the necessity of running as root.

The service runs as root (user: "0:0"). While this may be required for Playwright browser installation or specific test operations, running as root in containers is generally discouraged. Confirm this is necessary and consider using a non-root user if possible.


109-113: LGTM!

The named volumes are properly structured. Isolating node_modules and caching yarn artifacts will improve test performance and prevent conflicts.


115-117: The npmrc secret is properly documented in build-secrets/README.md as an expected build-time secret that developers provide during deployment. No action needed.


x-django-service: &django-service
image: ${DJANGO_IMAGE:-thunderstore/thunderstore:release-0.145.1}
image: ${DJANGO_IMAGE:-thunderstore/thunderstore:release-0.151.0}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Correct the Django image version—0.151.0 does not exist.

The latest available version in the GitHub container registry is release-0.149.0. Update the image tag to an actual released version.

🤖 Prompt for AI Agents
In tools/thunderstore-test-backend/docker-compose.yml at line 4, the Docker
image tag references a non-existent Django image release-0.151.0; change the
image tag to a valid released version (for example release-0.149.0) so the
compose file pulls an existing image; update the environment substitution or
literal tag accordingly and verify the new tag matches the GitHub container
registry listing.

@codecov
Copy link

codecov bot commented Dec 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 11.56%. Comparing base (a6eae79) to head (2d0a561).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1675      +/-   ##
==========================================
- Coverage   11.57%   11.56%   -0.02%     
==========================================
  Files         320      320              
  Lines       22913    22915       +2     
  Branches      511      508       -3     
==========================================
- Hits         2653     2650       -3     
- Misses      20260    20265       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants