Skip to content

Add systemd service and timer configuration for continuous Playwright…#2572

Open
vwh wants to merge 6 commits intoquran:playwright-testsfrom
vwh:playwright-tests
Open

Add systemd service and timer configuration for continuous Playwright…#2572
vwh wants to merge 6 commits intoquran:playwright-testsfrom
vwh:playwright-tests

Conversation

@vwh
Copy link
Member

@vwh vwh commented Nov 3, 2025

Summary by CodeRabbit

  • Chores
    • Added systemd-based automated testing to run integration tests on a recurring schedule.
  • Documentation
    • Added setup and management instructions for the new testing service and its scheduler, including enable/start commands, status/log checks, scheduling verification, and environment configuration examples.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 3, 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 systemd-based automated Playwright test infrastructure: a README documenting usage and configuration, a oneshot service unit that runs a specific Playwright test with a Discord reporter, and a timer unit that schedules the service to run every 5 minutes.

Changes

Cohort / File(s) Summary
Systemd testing infra
tests/service/README.md, tests/service/quran-tests.service, tests/service/quran-tests.timer
New documentation and two systemd units. README describes setup, management, and environment config. Service unit runs yarn playwright test tests/integration/url/path.spec.ts (via wrapper) from /srv/apps/playwright-tests with stdout/stderr to journal. Timer unit triggers the service every 5 minutes and installs to timers.target.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Timer as systemd.timer
    participant Systemd as systemd
    participant Service as quran-tests.service
    participant Runner as mise (wrapper)
    participant Playwright as yarn playwright
    participant Reporter as Discord reporter
    Note over Timer,Systemd `#E0F7FA`: every 5 minutes (OnCalendar)
    Timer->>Systemd: schedule trigger
    Systemd->>Service: start oneshot unit
    Service->>Runner: run in /srv/apps/playwright-tests
    Runner->>Playwright: execute test file
    Playwright->>Reporter: send results
    Playwright->>Systemd: stdout/stderr -> journal
    Systemd->>Timer: unit completes
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Focus review on correct timer schedule, service timeouts, and WorkingDirectory/path to test file.
  • Verify environment-file path and wrapper invocation (/srv/apps/playwright-tests/.mise.local.toml and mise command).
  • Confirm logging (StandardOutput/StandardError=journal) and dependency on network.target.

Poem

🐰 A rabbit taps the clock with glee,
Every five minutes, tests run free,
Systemd hums, the runner hops,
Reports to Discord — never stops,
Cheers to logs and CI-tuned tea! 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description is entirely empty. The template requires multiple sections including summary, type of change, test plan, and checklist, none of which were provided. Add a complete pull request description following the repository template, including summary of changes, type of change classification, test plan, and completion of the provided checklist items.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding systemd service and timer configuration for continuous Playwright testing. It is concise, specific, and directly reflects the changeset.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0a1cd30 and 4689440.

📒 Files selected for processing (1)
  • tests/service/quran-tests.timer (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.*

📄 CodeRabbit inference engine (.cursor/rules/bug-handling-with-todo-comments.mdc)

If you encounter a bug in existing code, or the instructions lead to suboptimal or buggy code, add comments starting with "TODO:" outlining the problems.

**/*.*: Utilize Early Returns: Use early returns to avoid nested conditions and improve readability.
Conditional Classes: Prefer conditional classes over ternary operators for class attributes.

**/*.*: Use comments sparingly, and when you do, make them meaningful.
Don't comment on obvious things. Excessive or unclear comments can clutter the codebase and become outdated.
Use comments to convey the 'why' behind specific actions or explain unusual behavior and potential pitfalls.
Provide meaningful information about the function's behavior and explain unusual behavior and potential pitfalls.

**/*.*: Write short functions that only do one thing.
Follow the single responsibility principle (SRP), which means that a function should have one purpose and perform it effectively.
If a function becomes too long or complex, consider breaking it into smaller, more manageable functions.

Order functions with those that are composing other functions appearing earlier in the file. For example, if you have a menu with multiple buttons, define the menu function above the buttons.

**/*.*: Always add helpful comments to the code explaining what you are doing.
Never delete old comments, unless they are no longer relevant because the code has been rewritten or deleted.

**/*.*: Choose names for variables, functions, and classes that reflect their purpose and behavior.
A name should tell you why it exists, what it does, and how it is used. If a name requires a comment, then the name does not reveal its intent.
Use specific names that provide a clearer understanding of what the variables represent and how they are used.

Files:

  • tests/service/quran-tests.timer
🧠 Learnings (1)
📓 Common learnings
Learnt from: CR
Repo: quran/quran.com-frontend-next PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-10-07T08:37:58.213Z
Learning: Use Playwright for integration tests
🔇 Additional comments (3)
tests/service/quran-tests.timer (3)

1-3: LGTM: Unit configuration is correct.

The Unit section properly describes the timer's purpose and establishes the necessary dependency on the service file.


5-7: Excellent: Critical bug from previous review has been fixed.

The OnCalendar=*:0/5 syntax now correctly schedules the tests to run every 5 minutes (at 0, 5, 10, 15, 20, 25, etc. minutes past each hour). The previous value *:*:0/5 would have triggered every 5 seconds, which has been corrected.

The Persistent=true setting is also a good practice—it ensures that if the system is down when a test should run, it will execute once after boot.


9-10: LGTM: Install configuration follows systemd conventions.

The WantedBy=timers.target directive is the standard way to enable systemd timers and ensures the timer is activated when the system boots.


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

@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: 4

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 10b1d30 and 709d34d.

📒 Files selected for processing (3)
  • tests/service/README.md (1 hunks)
  • tests/service/quran-tests.service (1 hunks)
  • tests/service/quran-tests.timer (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.*

📄 CodeRabbit inference engine (.cursor/rules/bug-handling-with-todo-comments.mdc)

If you encounter a bug in existing code, or the instructions lead to suboptimal or buggy code, add comments starting with "TODO:" outlining the problems.

**/*.*: Utilize Early Returns: Use early returns to avoid nested conditions and improve readability.
Conditional Classes: Prefer conditional classes over ternary operators for class attributes.

**/*.*: Use comments sparingly, and when you do, make them meaningful.
Don't comment on obvious things. Excessive or unclear comments can clutter the codebase and become outdated.
Use comments to convey the 'why' behind specific actions or explain unusual behavior and potential pitfalls.
Provide meaningful information about the function's behavior and explain unusual behavior and potential pitfalls.

**/*.*: Write short functions that only do one thing.
Follow the single responsibility principle (SRP), which means that a function should have one purpose and perform it effectively.
If a function becomes too long or complex, consider breaking it into smaller, more manageable functions.

Order functions with those that are composing other functions appearing earlier in the file. For example, if you have a menu with multiple buttons, define the menu function above the buttons.

**/*.*: Always add helpful comments to the code explaining what you are doing.
Never delete old comments, unless they are no longer relevant because the code has been rewritten or deleted.

**/*.*: Choose names for variables, functions, and classes that reflect their purpose and behavior.
A name should tell you why it exists, what it does, and how it is used. If a name requires a comment, then the name does not reveal its intent.
Use specific names that provide a clearer understanding of what the variables represent and how they are used.

Files:

  • tests/service/quran-tests.service
  • tests/service/quran-tests.timer
  • tests/service/README.md
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
Repo: quran/quran.com-frontend-next PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-10-07T08:37:58.213Z
Learning: Use Playwright for integration tests
📚 Learning: 2025-10-07T08:37:58.213Z
Learnt from: CR
Repo: quran/quran.com-frontend-next PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-10-07T08:37:58.213Z
Learning: Use Playwright for integration tests

Applied to files:

  • tests/service/quran-tests.service
🔇 Additional comments (5)
tests/service/quran-tests.timer (1)

1-3: LGTM: Timer configuration is sound.

The unit dependencies, persistent setting, and install target are correctly configured. The Requires=quran-tests.service ensures the service unit is loaded, Persistent=true will execute missed runs after system downtime, and WantedBy=timers.target enables proper systemd timer lifecycle management.

Also applies to: 7-7, 9-10

tests/service/quran-tests.service (2)

7-8: Note: Hardcoded deployment paths.

The service uses hardcoded paths (/srv/apps/playwright-tests) which is standard for systemd but limits portability. Ensure this path requirement is documented in deployment procedures or consider using systemd specifiers if the path may vary across environments.

Based on the README, this path is already documented. Verify that deployment/installation procedures clearly specify this directory structure requirement.


1-6: LGTM: Service configuration is well-structured.

The unit dependencies (After=network.target), service type (Type=simple), logging configuration (journal output), and timeout/kill settings are appropriately configured for a long-running test execution service. The 180-second start timeout accommodates Playwright's initialization time, and the graceful termination settings allow proper cleanup.

Also applies to: 11-12, 14-17

tests/service/README.md (2)

9-9: Inconsistent timer interval documentation.

The documentation states the timer triggers every 5 minutes, but the actual quran-tests.timer has a critical bug where OnCalendar=*:*:0/5 means every 5 seconds, not minutes. Once the timer configuration is fixed, this documentation will be accurate.

This comment relates to the critical issue flagged in quran-tests.timer line 6. Verify both files are corrected consistently.


20-119: LGTM: Comprehensive setup and management documentation.

The setup instructions, service management commands, and log viewing examples are thorough and correctly use systemd user service conventions (--user flag, ~/.config/systemd/user/ paths, journalctl --user). The symlink approach keeps the systemd units under version control while installing them properly.

Copy link
Contributor

@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: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 709d34d and 94faeb0.

📒 Files selected for processing (3)
  • .gitignore (1 hunks)
  • tests/service/quran-tests.service (1 hunks)
  • tests/service/quran-tests.timer (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.*

📄 CodeRabbit inference engine (.cursor/rules/bug-handling-with-todo-comments.mdc)

If you encounter a bug in existing code, or the instructions lead to suboptimal or buggy code, add comments starting with "TODO:" outlining the problems.

**/*.*: Utilize Early Returns: Use early returns to avoid nested conditions and improve readability.
Conditional Classes: Prefer conditional classes over ternary operators for class attributes.

**/*.*: Use comments sparingly, and when you do, make them meaningful.
Don't comment on obvious things. Excessive or unclear comments can clutter the codebase and become outdated.
Use comments to convey the 'why' behind specific actions or explain unusual behavior and potential pitfalls.
Provide meaningful information about the function's behavior and explain unusual behavior and potential pitfalls.

**/*.*: Write short functions that only do one thing.
Follow the single responsibility principle (SRP), which means that a function should have one purpose and perform it effectively.
If a function becomes too long or complex, consider breaking it into smaller, more manageable functions.

Order functions with those that are composing other functions appearing earlier in the file. For example, if you have a menu with multiple buttons, define the menu function above the buttons.

**/*.*: Always add helpful comments to the code explaining what you are doing.
Never delete old comments, unless they are no longer relevant because the code has been rewritten or deleted.

**/*.*: Choose names for variables, functions, and classes that reflect their purpose and behavior.
A name should tell you why it exists, what it does, and how it is used. If a name requires a comment, then the name does not reveal its intent.
Use specific names that provide a clearer understanding of what the variables represent and how they are used.

Files:

  • tests/service/quran-tests.service
  • tests/service/quran-tests.timer
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
Repo: quran/quran.com-frontend-next PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-10-07T08:37:58.213Z
Learning: Use Playwright for integration tests
📚 Learning: 2025-10-07T08:37:58.213Z
Learnt from: CR
Repo: quran/quran.com-frontend-next PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-10-07T08:37:58.213Z
Learning: Use Playwright for integration tests

Applied to files:

  • tests/service/quran-tests.service
🔇 Additional comments (7)
.gitignore (1)

38-40: LGTM: Appropriate ignore pattern for local configuration.

The addition of .mise.local.toml to .gitignore is correct, preventing local mise configuration from being committed to version control.

tests/service/quran-tests.service (3)

1-3: LGTM: Appropriate [Unit] configuration.

The unit description is clear and After=network.target correctly ensures network availability before running Playwright tests.


5-7: LGTM: Correct service type and configuration.

Type=oneshot is appropriate for a timer-triggered test service. The absence of a Restart= directive is correct since the timer handles scheduling.


9-13: LGTM: Appropriate logging and timeout configuration.

Redirecting output to the journal is correct for systemd services, and the timeout values (180s start, 60s stop) are reasonable for Playwright test execution.

tests/service/quran-tests.timer (3)

1-3: LGTM: Appropriate timer unit configuration.

The description is clear and Requires=quran-tests.service correctly establishes the dependency on the service unit.


5-7: LGTM: Timer correctly schedules every 5 minutes.

The OnCalendar=*-*-* *:0/5:00 format is correct for 5-minute intervals (runs at :00, :05, :10, etc.). Persistent=true ensures missed runs execute after system downtime.


9-10: LGTM: Correct installation target.

WantedBy=timers.target is the appropriate target for systemd timer units.

@mustafa0x
Copy link
Contributor

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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 adds systemd-based continuous integration testing infrastructure for Quran.com's Playwright tests. The service is configured to run URL path validation tests every 5 minutes, with results reported to Discord via a custom reporter.

Key Changes:

  • Systemd timer configured to trigger tests every 5 minutes using OnCalendar syntax
  • Service unit configured to run a specific Playwright test file with Discord reporting
  • Comprehensive documentation covering setup, management, and troubleshooting

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
tests/service/quran-tests.timer Defines the systemd timer that triggers test execution every 5 minutes with persistent scheduling
tests/service/quran-tests.service Configures the oneshot service that executes Playwright tests via mise with timeout and journaling settings
tests/service/README.md Provides complete documentation for setup, service management, status monitoring, and environment configuration


[Service]
Type=oneshot
WorkingDirectory=/srv/apps/playwright-tests
Copy link

Copilot AI Nov 30, 2025

Choose a reason for hiding this comment

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

The hardcoded path /srv/apps/playwright-tests is specific to a particular deployment environment. This should be documented as an example that needs to be customized, or consider using a relative path or environment variable to make the service more portable across different deployment environments.

Suggested change
WorkingDirectory=/srv/apps/playwright-tests
# Set PLAYWRIGHT_TESTS_DIR to the directory containing your Playwright tests.
Environment="PLAYWRIGHT_TESTS_DIR=/srv/apps/playwright-tests"
WorkingDirectory=${PLAYWRIGHT_TESTS_DIR}

Copilot uses AI. Check for mistakes.
[Service]
Type=oneshot
WorkingDirectory=/srv/apps/playwright-tests
ExecStart=mise x -- yarn playwright test tests/integration/url/path.spec.ts --reporter=./tests/reporter/discord-reporter.js,list
Copy link

Copilot AI Nov 30, 2025

Choose a reason for hiding this comment

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

The service will run only a single test file (tests/integration/url/path.spec.ts) rather than the full test suite. If this is intentional for continuous monitoring of critical paths, this should be clearly documented in the README explaining why only this specific test file is run. If the intention is to run all tests, the path should be updated to include all test files or removed to run the entire test suite.

Suggested change
ExecStart=mise x -- yarn playwright test tests/integration/url/path.spec.ts --reporter=./tests/reporter/discord-reporter.js,list
ExecStart=mise x -- yarn playwright test --reporter=./tests/reporter/discord-reporter.js,list

Copilot uses AI. Check for mistakes.
Comment on lines +120 to +129
```toml
[env]
PLAYWRIGHT_TEST_BASE_URL = "https://quran.com"
PLAYWRIGHT_SKIP_WEB_SERVER = "true"
DISCORD_BOT_TOKEN = "your_bot_token_here"
DISCORD_CHANNEL_ID = "your_channel_id_here"
TEST_USER_EMAIL = "test@example.com"
TEST_USER_PASSWORD = "password"
TEST_USER_USERNAME = "testuser"
```
Copy link

Copilot AI Nov 30, 2025

Choose a reason for hiding this comment

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

The environment variables section shows example credentials with placeholder values like "your_bot_token_here" and "password". While this is documentation, it should include a security warning that these values must be kept secret and should never be committed to version control. Consider adding a note like "⚠️ Security Note: Never commit actual credentials to version control. Keep .mise.local.toml in .gitignore."

Copilot uses AI. Check for mistakes.
Comment on lines +25 to +26
# Navigate to service directory
cd /srv/apps/playwright-tests/tests/service
Copy link

Copilot AI Nov 30, 2025

Choose a reason for hiding this comment

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

[nitpick] The hardcoded path /srv/apps/playwright-tests appears multiple times in the documentation. Consider adding a note at the beginning of the Setup section clarifying that this path should be adjusted to match the actual deployment location, or use a placeholder like <PROJECT_ROOT> to make it clearer that this needs customization.

Copilot uses AI. Check for mistakes.
Comment on lines +17 to +18
- Run Playwright tests against the live quran.com site
- Send Discord notifications for test failures
Copy link

Copilot AI Nov 30, 2025

Choose a reason for hiding this comment

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

The README states that the service "Run Playwright tests against the live quran.com site" (line 17), but the ExecStart command in the service file only runs a single test file (tests/integration/url/path.spec.ts). The documentation should be updated to clarify that only URL path tests are run, not the entire test suite, or provide guidance on how to customize which tests are executed.

Copilot uses AI. Check for mistakes.
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