Skip to content

Comments

chore: update configuration and workflows#48

Merged
panteLx merged 1 commit intomainfrom
chore/workflows-and-formatting
Apr 24, 2025
Merged

chore: update configuration and workflows#48
panteLx merged 1 commit intomainfrom
chore/workflows-and-formatting

Conversation

@panteLx
Copy link
Owner

@panteLx panteLx commented Apr 24, 2025

  • Updated .prettierrc to include new formatting options such as trailing commas and print width.
  • Added new scripts in package.json for format checking and TypeScript type checking.
  • Enhanced GitHub workflows for Docker publishing and PR validation, including testing steps and Node.js version matrix.
  • Removed outdated CHANGELOG.md file.
  • Refactored code for consistency and clarity across various files.

resolves #46

Summary by CodeRabbit

  • New Features

    • Added scripts for code formatting checks and TypeScript type checking.
    • Enhanced pull request validation to include type and formatting checks.
    • Expanded testing to run across multiple Node.js versions in CI workflows.
    • Improved Docker publishing workflow with automated testing, multi-platform builds, and caching.
  • Style

    • Refactored codebase for consistent formatting and concise function signatures.
  • Chores

    • Updated Prettier configuration for code style preferences.
    • Removed the changelog file and its reference from documentation.

- Updated .prettierrc to include new formatting options such as trailing commas and print width.
- Added new scripts in package.json for format checking and TypeScript type checking.
- Enhanced GitHub workflows for Docker publishing and PR validation, including testing steps and Node.js version matrix.
- Removed outdated CHANGELOG.md file.
- Refactored code for consistency and clarity across various files.
@coderabbitai
Copy link

coderabbitai bot commented Apr 24, 2025

Walkthrough

This update introduces extensive formatting and configuration changes across the project. All code files are reformatted for concise single-line imports, function signatures, and arrow functions, without altering logic or control flow. Several GitHub Actions workflows are enhanced: CI jobs now test across multiple Node.js versions, add explicit type-checking and formatting checks, and improve Docker image building with multi-platform support, Buildx, and caching. The Prettier configuration is updated for stricter formatting rules, and two new npm scripts for format and type checks are added. The changelog file is removed, and its reference is deleted from the README.

Changes

File(s) Change Summary
.github/workflows/docker-publish.yml Renamed workflow and job; added test job; build-and-push now depends on tests; permissions updated; Docker Buildx setup and multi-platform build with caching added.
.github/workflows/pr.yml Renamed workflow/job; expanded permissions; added checkout, Node.js setup, dependency install, semantic PR title validation, type-check, and format-check steps.
.github/workflows/release.yml
.github/workflows/test.yml
Both workflows now use a matrix to test across Node.js 20.x–23.x; steps are split for clarity; Node.js setup uses npm caching; minor naming and formatting improvements.
.prettierrc Updated Prettier config: new options for print width, tabs, bracket spacing, arrow parens; removed endOfLine; reordered properties.
CHANGELOG.md
README.md
CHANGELOG.md deleted; changelog link removed from README.
package.json Added "format:check" and "typecheck" npm scripts for Prettier and TypeScript checks.
packages/addon/src/addon.ts
packages/addon/src/custom-server.ts
packages/addon/src/custom-template.ts
packages/addon/src/i18n/index.ts
packages/addon/src/meta.ts
packages/addon/src/sort-option.ts
packages/addon/src/utils.test.ts
packages/addon/src/utils.ts
packages/addon/stremio-addon-sdk-builder.d.ts
packages/api/src/api.ts
packages/cloudflare-worker/src/index.ts
All files reformatted: imports, function signatures, arrow functions, and logging consolidated to single lines; no logic or control flow changes; minor missing comma added in translation; only stylistic improvements.

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant GitHub Actions
    participant Node.js
    participant Docker

    Developer->>GitHub Actions: Push or PR event
    GitHub Actions->>Node.js: Set up Node.js (matrix: 20.x-23.x)
    GitHub Actions->>Node.js: Install dependencies (npm ci)
    GitHub Actions->>Node.js: Run tests (npm run test)
    GitHub Actions->>Node.js: Run typecheck (npm run typecheck)
    GitHub Actions->>Node.js: Run format check (npm run format:check)
    alt On Docker publish
        GitHub Actions->>Docker: Set up Docker Buildx
        GitHub Actions->>Docker: Build multi-platform image (amd64, arm64)
        GitHub Actions->>Docker: Use cache for layers
        GitHub Actions->>Docker: Push image to registry
    end
Loading

Possibly related PRs

  • panteLx/easynews-plus-plus#28: Updates npm scripts and custom template, overlapping with this PR's addition of format/typecheck scripts and template formatting changes.
  • panteLx/easynews-plus-plus#30: Introduced the Docker publish workflow that this PR further extends with testing, multi-platform builds, and caching.

Poem

A rabbit hopped through fields of code,
Tidying lines where logic flowed.
Scripts for checks, and tests now run,
Docker builds for everyone!
The changelog’s gone, but not the cheer—
For code is crisp and crystal clear.
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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 (4)
packages/api/src/api.ts (2)

8-8: Consider extracting cache entry type
The inline object type for cache entries is repetitive; defining a dedicated interface (e.g., interface CacheEntry { data: EasynewsSearchResponse; timestamp: number }) and using Map<string, CacheEntry> will improve readability and maintainability.


135-135: Preserve original abort error details
Throwing a new Error on timeout discards the original stack and message. You might wrap the abort in an Error with the original as a cause, or rethrow the original AbortError to retain diagnostic information:

if (error.name === 'AbortError') {
  throw new Error(`Search timed out after 20s for '${query}'`, { cause: error });
}
packages/cloudflare-worker/src/index.ts (1)

4-4: Remove unused import
getTranslations is imported but never used in this file. Please remove it or implement its usage to avoid dead code.

.github/workflows/test.yml (1)

24-27: Consider adding lint and type-check steps
To enforce formatting and typings in CI, you could extend the job:

- name: Check formatting
  run: npm run format:check
- name: Type check
  run: npm run typecheck
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 77d95bc and 5bf5676.

📒 Files selected for processing (19)
  • .github/workflows/docker-publish.yml (3 hunks)
  • .github/workflows/pr.yml (2 hunks)
  • .github/workflows/release.yml (2 hunks)
  • .github/workflows/test.yml (1 hunks)
  • .prettierrc (1 hunks)
  • CHANGELOG.md (0 hunks)
  • README.md (0 hunks)
  • package.json (1 hunks)
  • packages/addon/src/addon.ts (18 hunks)
  • packages/addon/src/custom-server.ts (4 hunks)
  • packages/addon/src/custom-template.ts (3 hunks)
  • packages/addon/src/i18n/index.ts (3 hunks)
  • packages/addon/src/meta.ts (3 hunks)
  • packages/addon/src/sort-option.ts (2 hunks)
  • packages/addon/src/utils.test.ts (1 hunks)
  • packages/addon/src/utils.ts (17 hunks)
  • packages/addon/stremio-addon-sdk-builder.d.ts (1 hunks)
  • packages/api/src/api.ts (2 hunks)
  • packages/cloudflare-worker/src/index.ts (4 hunks)
💤 Files with no reviewable changes (2)
  • README.md
  • CHANGELOG.md
🧰 Additional context used
🧬 Code Graph Analysis (4)
packages/addon/src/sort-option.ts (1)
packages/addon/src/utils.ts (1)
  • capitalizeFirstLetter (586-589)
packages/cloudflare-worker/src/index.ts (1)
packages/addon/src/manifest.ts (1)
  • manifest (61-116)
packages/addon/src/custom-template.ts (1)
packages/addon/src/i18n/index.ts (2)
  • translations (151-723)
  • getTranslations (132-138)
packages/api/src/api.ts (1)
packages/api/src/types.ts (1)
  • EasynewsSearchResponse (5-31)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build-and-push
🔇 Additional comments (85)
packages/addon/src/utils.test.ts (1)

24-24: Approve: Update expected output for ampersand replacement.
The test now correctly expects & to be replaced with and, which matches the implementation of sanitizeTitle.

.prettierrc (1)

3-9: Approve Prettier configuration enhancements.
The additions of trailingComma, printWidth, useTabs, bracketSpacing, and arrowParens will enforce a more consistent and readable code style across the project, and the CI’s format:check step will ensure compliance.

packages/addon/src/sort-option.ts (4)

28-30: Approve: Simplify arrow function in humanReadableSortOptions.
Removing parentheses around the single parameter and condensing to a one-liner aligns with the project’s concise arrow‐function style.


42-42: Approve: Condense return in toHumanReadable.
Using nullish coalescing in a single-line return is a pure formatting change that preserves existing logic.


50-50: Approve: Streamlined find callback in fromHumanReadable.
Collapsing the callback into a single-line arrow function improves readability without functional impact.


55-57: Approve: Inline conditional in toDirection.
The concise one-liner return retains behavior and matches the concise style in other parts of the code.

packages/addon/stremio-addon-sdk-builder.d.ts (1)

27-27: Approve: Single-line signature for defineCatalogHandler.
Consolidating the multiline declaration into one line keeps it consistent with other handler definitions and doesn’t change the API.

package.json (1)

8-9: Approve: Add format:check and typecheck scripts.
Introducing npm run format:check and npm run typecheck strengthens the CI pipeline by enforcing formatting and type correctness before merging.

packages/api/src/api.ts (1)

11-11: Reevaluate the runtime options null check
Since TypeScript enforces options as a required parameter, the if (!options) check is unlikely to ever trigger. Consider either making options optional in the signature or removing the redundant guard to streamline the code.

packages/addon/src/meta.ts (6)

12-12: Formatting-only change approved
The async function signature was consolidated to a single line without altering behavior.


16-17: Formatting-only change approved
The .then() callbacks were reformatted into single-line arrow functions, improving conciseness.


43-43: Formatting-only change approved
Consistent single-line .then(res => res.json()) style aligns with other promise chains.


67-67: Formatting-only change approved
Consolidated the function declaration to one line; functionality remains unchanged.


69-69: Formatting-only change approved
Predicate callback in the promise chain simplified; no logical changes.


76-76: Formatting-only change approved
Final .then() callback streamlined for readability.

packages/addon/src/i18n/index.ts (3)

137-137: Formatting-only change approved
The ternary fallback for unsupported languages was collapsed into one line, preserving its logic.


562-562: Formatting-only change approved
Converted the Chinese strictTitleMatching string to a single line without altering content.


677-677: Formatting-only change approved
Added missing trailing comma in the Romanian sortingOptions block; aligns with JSON/TS style conventions.

packages/cloudflare-worker/src/index.ts (3)

29-29: Formatting-only change approved
The route handler declaration was consolidated to a single line; functionality is identical.


31-31: Formatting-only change approved
No-cache header calls were flattened to single-line statements, improving consistency.


60-60: Formatting-only change approved
Root redirect route definition follows the same concise arrow function style.

.github/workflows/test.yml (5)

6-7: Push trigger added for main branch
Including push alongside pull_request ensures workflows run on direct commits to main.


11-13: Node.js version matrix introduced
Testing across [20.x, 21.x, 22.x, 23.x] provides broader compatibility coverage.


18-18: Dynamic Node.js setup step
Using matrix.node-version aligns the setup with the matrix strategy.


21-22: Enable npm caching
Adding cache: 'npm' speeds up dependency installation in CI.


24-27: Separate install and test steps
Splitting npm ci and npm run test into named steps improves workflow readability.

packages/addon/src/addon.ts (15)

24-26: Consolidated imports for clarity
Single-line imports reduce verbosity and improve readability without altering functionality.


50-50: Streamlined initialization log
The one-liner for the addon initialization log is concise and retains full context.


91-91: Example custom title log formatted inline
Converting the loop’s log to a single template literal keeps the debug output clear.


129-129: MetaHandler signature condensed
The arrow function signature for defineMetaHandler is now on one line, improving compactness without changing types or logic.


234-234: StreamHandler signature condensed
Similarly, the defineStreamHandler signature is simplified to a single line, maintaining type annotations intact.


272-277: Config parsing and logging made concise
Parsing strictTitleMatching and logging its state, as well as preferred language, are now inline and easy to follow.


349-349: No-direct-custom-title log
Inline log clarifies fallback path when no direct custom title is found.


381-381: Alternative-names count log
Logging the count of metadata alternative names in a single expression is clear and retains full detail.


388-390: Inline filtering of additional titles
The .filter(…) callback is now a concise arrow function, improving readability for title deduplication logic.


397-397: Search-title count log
Single-line log for the number of titles searched keeps debug output succinct.


431-431: Example result log inline
Formatting the example result log as a one-liner preserves detail while reducing line count.


442-442: Fallback search-with-year log
Inlining the log message when retrying with year keeps intent clear.


522-522: Series strict-match condition inline
Converting the if (!queries.some(…)) check into a single line is concise and retains exact logic.


529-536: Variant matching logic inline
The .some(…) and matchesTitle call are now written inline, improving readability of the movie matching fallback.


808-808: Stream language logging inline
A one-liner for logging stream language info keeps the mapping function compact.

.github/workflows/release.yml (6)

1-1: Workflow renamed to improve clarity
Renaming to "Test and Release on GitHub" more accurately reflects the workflow’s scope.


10-13: Matrix testing across Node.js versions
Adding a Node.js version matrix (20.x–23.x) increases compatibility coverage.


17-22: Dynamic Node.js setup with caching
Using actions/setup-node with ${{ matrix.node-version }} and cache: 'npm' speeds up CI runs.


23-27: Separate install and test steps
Splitting dependency installation (npm ci) and test execution (npm run test) makes logs clearer and failures easier to diagnose.


29-29: Job dependency enforces test success
needs: test guarantees that the release job only runs if the tests pass.


39-42: Enable npm cache in release job
Caching dependencies in the release step further optimizes workflow duration.

.github/workflows/pr.yml (9)

1-1: Workflow renamed to "PR Validation"
The new name succinctly describes its purpose as a pull request validation pipeline.


11-12: Expanded permissions for content reading
Adding contents: read alongside pull-requests: read ensures the workflow can fetch necessary files for validation.


15-17: Job renamed to validate
Changing the job ID and display name to "Validate PR" aligns nomenclature with its function.


19-22: Checkout with full history
Using fetch-depth: 0 is required for semantic title checks and type/format validations.


23-28: Node.js setup and caching in PR pipeline
Pinning to Node 23.x with npm cache improves speed and consistency for TypeScript and formatting checks.


29-31: Install dependencies step added
npm ci ensures a clean install before running validations.


32-36: Semantic PR title validation integrated
Retaining the existing PR title check action within the expanded pipeline.


37-39: TypeScript type-checking added
Running npm run typecheck adds a critical layer of static analysis to catch type errors early.


40-42: Prettier formatting check added
npm run format:check enforces code style automatically on every pull request.

packages/addon/src/custom-server.ts (4)

18-18: Inline createManifestWithLanguage signature
Condensing the function declaration to one line improves compactness without affecting behavior.


33-33: Streamlined serveHTTP signature
The export signature is now a single-line declaration with a default parameter, preserving functionality.


74-74: No-cache headers set in one line
Consolidating multiple statements into a single res.setHeader call for cache control is clear and concise.


104-104: Single-line directory existence check
Throwing an error in-line when the static directory doesn’t exist reduces boilerplate.

packages/addon/src/custom-template.ts (4)

2-13: Consolidated import and UI language lookup
Combining imports and the .find() call into single‐line statements makes the initial setup more concise.


18-20: Condensed debug logging
Inline console.log calls for language and translation loading keep the template code compact.


33-87: Form field translation mapping streamlined
Collapsing multi-line conditional branches for translating strictTitleMatching and preferredLanguage into single-line checks improves readability while keeping the logic intact.


88-121: Sorting preference translation mapping condensed
Simplifying the translation mapping for sortingPreference into inline conditionals makes the code more maintainable without altering behavior.

.github/workflows/docker-publish.yml (6)

1-1: Workflow name updated for clarity
Renaming the workflow to “Test and publish Docker image” makes its intent explicit.


15-27: Introduce a dedicated test job
Adding a separate test job that runs npm ci and npm run test ensures that builds don’t proceed on failing tests. Consider aligning the Node.js version here with your supported LTS or using a matrix if you need multi-version coverage.


30-35: Enforce test completion and grant security-event permissions
Requiring build-and-push to depend on test prevents premature image publication. Granting security-events: write is appropriate for publishing SBOMs or vulnerability data.


41-43: Set up Docker Buildx for multi-platform builds
Inserting docker/setup-buildx-action@v3 prepares the runner for cross-architecture builds. This is a best practice for publishing both amd64 and arm64 images.


65-65: Specify build platforms
Targeting linux/amd64,linux/arm64 covers the majority of deployment environments. Approved.


69-70: Enable GitHub Actions cache for Docker layers
Using cache-from: type=gha and cache-to: type=gha,mode=max will significantly speed up subsequent image builds by reusing layers.

packages/addon/src/utils.ts (15)

103-105: Maintain strict-mode year matching logic
The trimmed comparison stripping the year before matching ensures exact title match plus year check. Formatting changes are correct and the logic remains intact.


130-134: Approve allWordsMatch extraction
Refactoring the every-check into a standalone allWordsMatch constant improves readability. No functional change observed.


140-142: Simplify matchingWords predicate
Switching to a concise arrow function within filter is a pure style change. Approved.


145-146: Compute significantWords inline
Collapsing the filter-and-length chain into one expression is consistent with the rest of the file.


192-192: Streamline getQuality signature
Consolidating the function declaration onto one line aligns with project style. No behavior change.


222-222: Condense createThumbnailUrl declaration
Moving from multi-line to single-line arrow signature is purely stylistic. Approved.


257-263: Enhance logging in loadCustomTitles
Adding logs for parsed title counts and sample entries improves debuggability when loading external JSON. Formatting is correct.


275-275: Log missing or inaccessible custom-titles file
Reporting the file absence via logger.info aids operational diagnostics. Approved.


330-330: Refactor custom-title replacement generation
Using a dynamic RegExp to replace the English title with its custom equivalent is unchanged logic, now formatted as intended.


345-345: Refactor English-title restoration logic
The mirrored replacement logic for custom-to-English titles is consistent and correctly formatted.


355-358: Log alternative-title discovery outcome
Informing whether alternatives were found (and how many) helps in understanding title fallback behavior at runtime. Good enhancement.


366-366: Compact buildSearchQuery export
Single-line function signatures for small utilities enhance readability. Approved.


436-436: Numeric log-level parsing guard
Verifying that parsed numbers fall within the LogLevel enum range is a solid defensive check. Formatting tweak only.


532-534: Approve consolidated logger method implementations
Collapsing each console logging call into a single-line template literal keeps the logger consistent and concise across trace, debug, warn, and error.

Also applies to: 544-546, 566-568, 576-578


582-582: Expose logError helper function
Exporting a dedicated logError wrapper aligns with the rest of the logging utilities. No issues detected.

@panteLx panteLx merged commit f501e51 into main Apr 24, 2025
9 checks passed
@panteLx panteLx deleted the chore/workflows-and-formatting branch April 24, 2025 21:52
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.

Enhance publish script

1 participant