Skip to content

feat: [#534] add schedule:run and schedule:list commands#1019

Merged
almas-x merged 3 commits intomasterfrom
almas/#534
May 4, 2025
Merged

feat: [#534] add schedule:run and schedule:list commands#1019
almas-x merged 3 commits intomasterfrom
almas/#534

Conversation

@almas-x
Copy link
Contributor

@almas-x almas-x commented Apr 29, 2025

📑 Description

Closes goravel/goravel#534

This PR adds two new Artisan commands:

  • schedule:run: Starts the internal scheduler and runs all due tasks.

  • schedule:list: Lists all registered scheduled tasks.

Goravel has a built-in task scheduling system based on robfig/cron, a robust and flexible cron engine for Go.
Thanks to this internal scheduler, there is no need to rely on the system’s crontab to trigger scheduled tasks. We can manage task execution entirely within the application by keeping the schedule:run process alive.

We only need to:

  • Run artisan schedule:run as the main process in a Docker container, or

  • Use a process manager like supervisord, systemd, or pm2 to ensure the schedule:run process remains running.

This approach provides a reliable, container-friendly, and framework-native solution for task scheduling in Goravel applications.

code

✅ Checks

  • Added test cases for my code

Copilot AI review requested due to automatic review settings April 29, 2025 02:32
@almas-x almas-x requested a review from a team as a code owner April 29, 2025 02:32
@almas-x almas-x marked this pull request as draft April 29, 2025 02:32
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 pull request implements two new Artisan commands for managing scheduled tasks in Goravel. The changes include command registration in the service provider, implementation of the schedule:run command and schedule:list command with corresponding tests, and required updates to the schedule interface and mocks.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
schedule/service_provider.go Registers the new schedule:list and schedule:run commands.
schedule/console/run_command.go Implements the schedule:run command to trigger the scheduler.
schedule/console/list_command.go Implements the schedule:list command to display scheduled tasks.
schedule/console/list_command_test.go Adds tests to verify output for the list command.
schedule/application.go Updates the application to manage schedule events.
mocks/schedule/Schedule.go Updates the mocks to provide the new Events method.
contracts/schedule/schedule.go Updates the schedule interface with the Events method.

@codecov
Copy link

codecov bot commented Apr 29, 2025

Codecov Report

Attention: Patch coverage is 88.18182% with 13 lines in your changes missing coverage. Please review.

Project coverage is 71.16%. Comparing base (ee0bc55) to head (e955f55).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
schedule/service_provider.go 0.00% 6 Missing ⚠️
schedule/console/list_command.go 95.12% 3 Missing and 1 partial ⚠️
schedule/application.go 40.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1019      +/-   ##
==========================================
+ Coverage   70.97%   71.16%   +0.18%     
==========================================
  Files         170      172       +2     
  Lines       11705    11807     +102     
==========================================
+ Hits         8308     8402      +94     
- Misses       3044     3052       +8     
  Partials      353      353              

☔ 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.

@almas-x almas-x force-pushed the almas/#534 branch 2 times, most recently from eca73dd to a95ec46 Compare April 29, 2025 07:27
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.50.

Benchmark suite Current: 1c21aa6 Previous: 35ac966 Ratio
BenchmarkFile_ReadWrite 305268 ns/op 2072 B/op 28 allocs/op 184622 ns/op 2072 B/op 28 allocs/op 1.65
BenchmarkFile_ReadWrite - ns/op 305268 ns/op 184622 ns/op 1.65

This comment was automatically generated by workflow using github-action-benchmark.

@almas-x almas-x marked this pull request as ready for review April 29, 2025 08:27
Copy link
Contributor

@hwbrzzl hwbrzzl left a comment

Choose a reason for hiding this comment

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

Amazing PR 👍 Could you please optimize the print? It's not aligned.

image

@almas-x
Copy link
Contributor Author

almas-x commented Apr 30, 2025

Amazing PR 👍 Could you please optimize the print? It's not aligned.

image

Done!

@almas-x almas-x requested a review from hwbrzzl April 30, 2025 01:54
Copy link
Contributor

@hwbrzzl hwbrzzl left a comment

Choose a reason for hiding this comment

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

Great PR 👍

@hwbrzzl
Copy link
Contributor

hwbrzzl commented May 3, 2025

Sorry for the delay, I‘ve been moving house recently.

@almas-x almas-x merged commit 42cdf88 into master May 4, 2025
13 checks passed
@almas-x almas-x deleted the almas/#534 branch May 4, 2025 03:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

✨ [Feature] Add a new command: schedule:run, support to call it external (linux crontab)

3 participants