Skip to content

Commit d2fc0eb

Browse files
committed
chore: 添加 workflows/test.yml
1 parent 21a0b67 commit d2fc0eb

File tree

6 files changed

+156
-12
lines changed

6 files changed

+156
-12
lines changed

.github/workflows/test.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
go-version: [ '1.21' ]
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Go
22+
uses: actions/setup-go@v5
23+
with:
24+
go-version: ${{ matrix.go-version }}
25+
26+
- name: Cache Go modules
27+
uses: actions/cache@v4
28+
with:
29+
path: |
30+
~/.cache/go-build
31+
~/go/pkg/mod
32+
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
33+
restore-keys: |
34+
${{ runner.os }}-go-${{ matrix.go-version }}-
35+
36+
- name: Download dependencies
37+
run: go mod download
38+
39+
- name: Verify dependencies
40+
run: go mod verify
41+
42+
- name: Run tests
43+
run: go test -v -race -coverprofile=coverage.out ./...
44+
45+
- name: Run benchmarks
46+
run: go test -bench=. -benchmem ./...
47+
48+
- name: Check coverage
49+
run: go tool cover -html=coverage.out -o coverage.html
50+
51+
- name: Upload coverage reports
52+
uses: codecov/codecov-action@v4
53+
if: matrix.go-version == '1.21'
54+
with:
55+
file: ./coverage.out
56+
flags: unittests
57+
name: codecov-umbrella
58+
fail_ci_if_error: false

README.md

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,42 @@
66
> A lightweight Golang scheduler supporting standard cron expressions, custom descriptors, custom intervals, and task dependencies. Easily write schedules using Go.<br>
77
> Originally designed for [pardnchiu/go-ip-sentry](https://github.com/pardnchiu/go-ip-sentry) to handle threat score decay calculations.
88
9-
![lang](https://img.shields.io/github/languages/top/pardnchiu/go-cron)
9+
[![pkg](https://pkg.go.dev/badge/github.com/pardnchiu/go-cron.svg)](https://pkg.go.dev/github.com/pardnchiu/go-cron)
10+
[![card](https://goreportcard.com/badge/github.com/pardnchiu/go-cron)](https://goreportcard.com/report/github.com/pardnchiu/go-cron)
11+
[![version](https://img.shields.io/github/v/tag/pardnchiu/go-cron?label=release)](https://github.com/pardnchiu/go-cron/releases)<br>
1012
[![license](https://img.shields.io/github/license/pardnchiu/go-cron)](LICENSE)
11-
[![version](https://img.shields.io/github/v/tag/pardnchiu/go-cron)](https://github.com/pardnchiu/go-cron/releases)
12-
![card](https://goreportcard.com/badge/github.com/pardnchiu/go-cron)<br>
1313
[![readme](https://img.shields.io/badge/readme-EN-white)](README.md)
14-
[![readme](https://img.shields.io/badge/readme-ZH-white)](README.zh.md)
14+
[![readme](https://img.shields.io/badge/readme-ZH-white)](README.zh.md)
15+
16+
- [Key Features](#key-features)
17+
- [Flexible Syntax](#flexible-syntax)
18+
- [Task Dependencies](#task-dependencies)
19+
- [Efficient Architecture](#efficient-architecture)
20+
- [Flowcharts](#flowcharts)
21+
- [Dependencies](#dependencies)
22+
- [Usage](#usage)
23+
- [Installation](#installation)
24+
- [Initialization](#initialization)
25+
- [Basic Usage](#basic-usage)
26+
- [Task Dependencies](#task-dependencies-1)
27+
- [Configuration](#configuration)
28+
- [Supported Formats](#supported-formats)
29+
- [Standard](#standard)
30+
- [Custom](#custom)
31+
- [Available Functions](#available-functions)
32+
- [Scheduler Management](#scheduler-management)
33+
- [Task Management](#task-management)
34+
- [Task Dependencies](#task-dependencies-2)
35+
- [Basic Usage](#basic-usage-1)
36+
- [Task States](#task-states)
37+
- [Timeout Mechanism](#timeout-mechanism)
38+
- [Features](#features)
39+
- [Upcoming Features](#upcoming-features)
40+
- [Enhanced Task Dependencies](#enhanced-task-dependencies)
41+
- [Task Completion Trigger Rewrite](#task-completion-trigger-rewrite)
42+
- [License](#license)
43+
- [Star](#star)
44+
- [Author](#author)
1545

1646
## Key Features
1747

@@ -120,8 +150,15 @@ flowchart TD
120150
## Usage
121151

122152
### Installation
153+
154+
> [!NOTE]
155+
> Latest commits may change. Recommended to use tagged versions.<br>
156+
> Commits containing only documentation updates or non-functional changes will be rebased later.
157+
123158
```bash
124-
go get github.com/pardnchiu/go-cron
159+
go get github.com/pardnchiu/go-cron@[VERSION]
160+
161+
git clone --depth 1 --branch [VERSION] https://github.com/pardnchiu/go-cron.git
125162
```
126163

127164
### Initialization
@@ -436,6 +473,10 @@ When execution time exceeds the configured `Delay`:
436473

437474
This project is licensed under [MIT](LICENSE).
438475

476+
## Star
477+
478+
[![Star](https://api.star-history.com/svg?repos=pardnchiu/go-cron&type=Date)](https://www.star-history.com/#pardnchiu/go-cron&Date)
479+
439480
## Author
440481

441482
<img src="https://avatars.githubusercontent.com/u/25631760" align="left" width="96" height="96" style="margin-right: 0.5rem;">

README.zh.md

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,43 @@
33
> 輕量的 Golang 排程器,支援標準 cron 表達式、自定義描述符、自訂間隔和任務依賴關係。輕鬆使用 Go 撰寫排程<br>
44
> 原本是設計給 [pardnchiu/go-ip-sentry](https://github.com/pardnchiu/go-ip-sentry) 威脅分數衰退計算所使用到的排程功能
55
6-
![lang](https://img.shields.io/github/languages/top/pardnchiu/go-cron)
6+
[![pkg](https://pkg.go.dev/badge/github.com/pardnchiu/go-cron.svg)](https://pkg.go.dev/github.com/pardnchiu/go-cron)
7+
[![card](https://goreportcard.com/badge/github.com/pardnchiu/go-cron)](https://goreportcard.com/report/github.com/pardnchiu/go-cron)
8+
[![version](https://img.shields.io/github/v/tag/pardnchiu/go-cron?label=release)](https://github.com/pardnchiu/go-cron/releases)<br>
79
[![license](https://img.shields.io/github/license/pardnchiu/go-cron)](LICENSE)
8-
[![version](https://img.shields.io/github/v/tag/pardnchiu/go-cron)](https://github.com/pardnchiu/go-cron/releases)
9-
![card](https://goreportcard.com/badge/github.com/pardnchiu/go-cron)<br>
1010
[![readme](https://img.shields.io/badge/readme-EN-white)](README.md)
1111
[![readme](https://img.shields.io/badge/readme-ZH-white)](README.zh.md)
1212

13+
- [三大核心特色](#三大核心特色)
14+
- [靈活語法](#靈活語法)
15+
- [任務依賴](#任務依賴)
16+
- [高效架構](#高效架構)
17+
- [流程圖](#流程圖)
18+
- [依賴套件](#依賴套件)
19+
- [使用方法](#使用方法)
20+
- [安裝](#安裝)
21+
- [初始化](#初始化)
22+
- [基本使用](#基本使用)
23+
- [任務依賴](#任務依賴-1)
24+
- [配置介紹](#配置介紹)
25+
- [支援格式](#支援格式)
26+
- [標準](#標準)
27+
- [自定義](#自定義)
28+
- [可用函式](#可用函式)
29+
- [排程管理](#排程管理)
30+
- [任務管理](#任務管理)
31+
- [任務依賴](#任務依賴-2)
32+
- [基本使用](#基本使用-1)
33+
- [任務狀態](#任務狀態)
34+
- [超時機制](#超時機制)
35+
- [特點](#特點)
36+
- [功能預告](#功能預告)
37+
- [任務依賴增強](#任務依賴增強)
38+
- [任務完成觸發改寫](#任務完成觸發改寫)
39+
- [授權條款](#授權條款)
40+
- [](#星)
41+
- [作者](#作者)
42+
1343
## 三大核心特色
1444

1545
### 靈活語法
@@ -114,8 +144,15 @@ flowchart TD
114144
## 使用方法
115145

116146
### 安裝
147+
148+
> [!NOTE]
149+
> 最新 commit 可能會變動,建議使用標籤版本<br>
150+
> 針對僅包含文檔更新等非功能改動的 commit,後續會進行 rebase
151+
117152
```bash
118-
go get github.com/pardnchiu/go-cron
153+
go get github.com/pardnchiu/go-cron@[VERSION]
154+
155+
git clone --depth 1 --branch [VERSION] https://github.com/pardnchiu/go-cron.git
119156
```
120157

121158
### 初始化
@@ -430,6 +467,10 @@ const (
430467

431468
此專案採用 [MIT](LICENSE) 授權條款。
432469

470+
##
471+
472+
[![Star](https://api.star-history.com/svg?repos=pardnchiu/go-cron&type=Date)](https://www.star-history.com/#pardnchiu/go-cron&Date)
473+
433474
## 作者
434475

435476
<img src="https://avatars.githubusercontent.com/u/25631760" align="left" width="96" height="96" style="margin-right: 0.5rem;">

cron_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
// cron_test.go - 放在主程式碼同目錄
1+
/*
2+
* Test code generated by GitHub Copilot with Claude 4
3+
*/
24
package goCron
35

46
import (

go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
module github.com/pardnchiu/go-cron
22

3-
go 1.24.3
3+
go 1.21
4+
5+
require github.com/stretchr/testify v1.10.0
46

57
require (
68
github.com/davecgh/go-spew v1.1.1 // indirect
79
github.com/pmezard/go-difflib v1.0.0 // indirect
8-
github.com/stretchr/testify v1.10.0 // indirect
910
gopkg.in/yaml.v3 v3.0.1 // indirect
1011
)

go.sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
44
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
55
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
66
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
7+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
78
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
89
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
910
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)