Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • master
  • v1.0.0
  • v1.0.1
  • v1.1.0
  • v1.10.0
  • v1.10.1
  • v1.10.2
  • v1.11.0
  • v1.12.0
  • v1.12.1
  • v1.12.2
  • v1.12.3
  • v1.12.4
  • v1.12.5
  • v1.12.6
  • v1.12.7
  • v1.12.8
  • v1.13.0
  • v1.13.1
  • v1.13.2
  • v1.14.0
  • v1.15.0
  • v1.15.1
  • v1.15.10
  • v1.15.11
  • v1.15.12
  • v1.15.13
  • v1.15.14
  • v1.15.15
  • v1.15.16
  • v1.15.17
  • v1.15.2
  • v1.15.3
  • v1.15.4
  • v1.15.5
  • v1.15.6
  • v1.15.7
  • v1.15.8
  • v1.15.9
  • v1.16.0
  • v1.16.1
  • v1.17.0
  • v1.18.0
  • v1.18.1
  • v1.18.2
  • v1.19.0
  • v1.19.1
  • v1.19.2
  • v1.19.3
  • v1.19.4
  • v1.2.0
  • v1.20.0
  • v1.20.1
  • v1.20.2
  • v1.20.3
  • v1.21.0
  • v1.21.1
  • v1.22.0
  • v1.23.0
  • v1.23.1
  • v1.23.2
  • v1.3.0
  • v1.3.1
  • v1.3.2
  • v1.4.0
  • v1.5.0
  • v1.5.1
  • v1.6.0
  • v1.6.1
  • v1.7.0
  • v1.7.1
  • v1.7.2
  • v1.7.3
  • v1.8.0
  • v1.8.1
  • v1.9.0
76 results

Target

Select target project
  • oss/libraries/go/services/job-queues
1 result
Select Git revision
  • master
  • v1.0.0
  • v1.0.1
  • v1.1.0
  • v1.10.0
  • v1.10.1
  • v1.10.2
  • v1.11.0
  • v1.12.0
  • v1.12.1
  • v1.12.2
  • v1.12.3
  • v1.12.4
  • v1.12.5
  • v1.12.6
  • v1.12.7
  • v1.12.8
  • v1.13.0
  • v1.13.1
  • v1.13.2
  • v1.14.0
  • v1.15.0
  • v1.15.1
  • v1.15.10
  • v1.15.11
  • v1.15.12
  • v1.15.13
  • v1.15.14
  • v1.15.15
  • v1.15.16
  • v1.15.17
  • v1.15.2
  • v1.15.3
  • v1.15.4
  • v1.15.5
  • v1.15.6
  • v1.15.7
  • v1.15.8
  • v1.15.9
  • v1.16.0
  • v1.16.1
  • v1.17.0
  • v1.18.0
  • v1.18.1
  • v1.18.2
  • v1.19.0
  • v1.19.1
  • v1.19.2
  • v1.19.3
  • v1.19.4
  • v1.2.0
  • v1.20.0
  • v1.20.1
  • v1.20.2
  • v1.20.3
  • v1.21.0
  • v1.21.1
  • v1.22.0
  • v1.23.0
  • v1.23.1
  • v1.23.2
  • v1.3.0
  • v1.3.1
  • v1.3.2
  • v1.4.0
  • v1.5.0
  • v1.5.1
  • v1.6.0
  • v1.6.1
  • v1.7.0
  • v1.7.1
  • v1.7.2
  • v1.7.3
  • v1.8.0
  • v1.8.1
  • v1.9.0
76 results
Show changes
# THIS FILE IS AUTOGENERATED BY THE DEVENVSHELL
# DO NOT EDIT THIS FILE MANUALLY
# INSTEAD EDIT THE DEVENVSHELL CONFIGURATION FILE devenv.nix
# AND OPEN A SHELL WITH THE COMMAND devenv shell
#
# Information about the task runner can be found here:
# https://taskfile.dev
version: '3'
tasks:
default:
cmds:
- task --list
silent: true
test:
desc: Execute unit tests in Go.
env:
TEST_BY_TASK: true
cmds:
- docker pull atmoz/sftp:alpine
- docker pull axllent/mailpit
- echo "Execute unit tests in Go."
- test-lib
test-fuzz:
desc: Conduct fuzzing tests.#
env:
TEST_BY_TASK: true
cmds:
- echo "Conduct fuzzing tests."
- go test -tags=runOnTask -v -fuzztime=30s -fuzz=Fuzz ./...
add-licenses:
desc: Attach license headers to Go files.
cmds:
- echo "Attach license headers to Go files."
- go install github.com/google/addlicense@latest
- addlicense -c "schukai GmbH" -s -l "AGPL-3.0" ./*.go
silent: true
check-licenses:
desc: Check license headers of Go files.
silent: true
cmds:
- go-licenses save "$(get-go-default-packages)" --ignore "gitlab.schukai.com" --force --save_path ${DEVENV_ROOT}/licenses/
check:
desc: Confirm repository status.
cmds:
- git diff-index --quiet HEAD || (echo "There are uncommitted changes after running make. Please commit or stash them before running make."; exit 1)
silent: true
commit:
desc: Commit changes to the repository.
aliases:
- c
- ci
- git-commit
cmds:
- do-git-commit
......@@ -15,10 +15,17 @@ import (
func TestWriteToDB1(t *testing.T) {
gormDB, err := gorm.Open(sqlite.Open("file::memory:?cache=shared"), &gorm.Config{})
gormDB, err := gorm.Open(sqlite.Open("file:unique_id?mode=memory&cache=shared"), &gorm.Config{})
if err != nil {
t.Fatalf("a error occurred while opening the database: %v", err)
}
t.Cleanup(func() {
sqlDB, err := gormDB.DB()
if err != nil {
t.Fatalf("failed to get generic database object from GORM DB: %v", err)
}
_ = sqlDB.Close()
})
gormDB.Logger = gormDB.Logger.LogMode(4)
......@@ -36,18 +43,17 @@ func TestWriteToDB1(t *testing.T) {
}
job.scheduler = scheduler
saver.Sync(job)
saver.Sync(job)
manager.WaitSync()
// check if stats are in database
time.Sleep(1 * time.Second)
var stats JobPersistence
err = gormDB.First(&stats, "id = ?", job.GetID()).Error
assert.Nil(t, err)
assert.Equal(t, job.GetID(), stats.ID)
assert.Equal(t, job.GetID(), stats.ID)
manager.WaitSync()
}
......@@ -9,38 +9,33 @@ import (
"gorm.io/driver/sqlite"
"gorm.io/gorm"
"runtime"
"sync"
"testing"
"time"
)
func TestWriteToDB2(t *testing.T) {
gormDB, err := gorm.Open(sqlite.Open("file::memory:?cache=shared"), &gorm.Config{})
gormDB, err := gorm.Open(sqlite.Open("file:unique_id?mode=memory&cache=shared"), &gorm.Config{})
if err != nil {
t.Fatalf("a error occurred while opening the database: %v", err)
}
t.Cleanup(func() {
sqlDB, err := gormDB.DB()
if err != nil {
t.Fatalf("failed to get generic database object from GORM DB: %v", err)
}
_ = sqlDB.Close()
})
gormDB.Logger = gormDB.Logger.LogMode(4)
manager := &Manager{database: gormDB}
// Starte den DBSaver
NewJobSyncer(manager)
db := gormDB
var wg sync.WaitGroup
wg.Add(1)
defer wg.Done()
mgr := NewManager()
mgr.SetDB(gormDB)
// run sub tests
wg.Add(1)
defer wg.Done()
worker := NewLocalWorker(1)
err = mgr.AddWorker(worker)
assert.Nil(t, err)
......@@ -54,66 +49,73 @@ func TestWriteToDB2(t *testing.T) {
scheduler := &InstantScheduler{}
err = mgr.ScheduleJob(job, scheduler)
assert.Nil(t, err)
_ = manager.WaitSync()
err = mgr.CancelJobSchedule("job1")
assert.Nil(t, err)
_ = manager.WaitSync()
time.Sleep(1 * time.Second)
// time.Sleep(1 * time.Second)
scheduler2 := &InstantScheduler{}
err = mgr.ScheduleJob(job, scheduler2)
assert.Nil(t, err)
_ = manager.WaitSync()
err = mgr.CancelJobSchedule("job1")
assert.Nil(t, err)
time.Sleep(1 * time.Second)
// time.Sleep(1 * time.Second)
scheduler3 := &InstantScheduler{}
err = mgr.ScheduleJob(job, scheduler3)
assert.Nil(t, err)
_ = manager.WaitSync()
time.Sleep(1 * time.Second)
// time.Sleep(1 * time.Second)
if mgr.jobSyncer == nil {
t.Error("mgr.JobSyncer == nil")
return
}
time.Sleep(1 * time.Second)
// time.Sleep(1 * time.Second)
mgr.jobSyncer.Sync(job)
_ = mgr.jobSyncer.Sync(job)
_ = manager.WaitSync()
runtime.Gosched()
time.Sleep(1 * time.Second)
// time.Sleep(1 * time.Second)
err = mgr.CancelJobSchedule("job1")
assert.Nil(t, err)
runtime.Gosched()
time.Sleep(1 * time.Second)
// time.Sleep(1 * time.Second)
_ = manager.WaitSync()
scheduler4 := &InstantScheduler{}
err = mgr.ScheduleJob(job, scheduler4)
assert.Nil(t, err)
_ = manager.WaitSync()
runtime.Gosched()
time.Sleep(1 * time.Second)
//time.Sleep(1 * time.Second)
mgr.jobSyncer.Sync(job)
_ = mgr.jobSyncer.Sync(job)
_ = manager.WaitSync()
time.Sleep(2 * time.Second)
//time.Sleep(2 * time.Second)
err = mgr.CancelJobSchedule("job1")
assert.Nil(t, err)
_ = manager.WaitSync()
tries := 10
for tries > 0 {
var tmpJob JobPersistence
if err := db.First(&tmpJob, "id = ?", "job1").Error; err == nil {
break
}
tries--
time.Sleep(1 * time.Second)
......@@ -121,11 +123,10 @@ func TestWriteToDB2(t *testing.T) {
assert.True(t, tries > 0)
time.Sleep(1 * time.Second)
err = LoadJobsAndScheduleFromDatabase(db, mgr)
assert.Nil(t, err)
_ = manager.WaitSync()
time.Sleep(1 * time.Second)
mgr.jobSyncer.Sync(job)
}
......@@ -14,11 +14,19 @@ import (
func TestWriteToDB3(t *testing.T) {
db, err := gorm.Open(sqlite.Open("file::memory:?cache=shared"), &gorm.Config{})
gormDB, err := gorm.Open(sqlite.Open("file:unique_id?mode=memory&cache=shared"), &gorm.Config{})
if err != nil {
t.Fatalf("a error occurred while opening the database: %v", err)
}
t.Cleanup(func() {
sqlDB, err := gormDB.DB()
if err != nil {
t.Fatalf("failed to get generic database object from GORM DB: %v", err)
}
_ = sqlDB.Close()
})
db := gormDB
db.Logger = db.Logger.LogMode(4)
manager := NewManager()
......
......@@ -12,11 +12,19 @@ import (
func TestWriteToDB4(t *testing.T) {
db, err := gorm.Open(sqlite.Open("file::memory:?cache=shared"), &gorm.Config{})
//db, err := gorm.Open(sqlite.Open("file:/home/vs/workspaces/alvine/cloud/framework/dummy.sqlite"), &gorm.Config{})
gormDB, err := gorm.Open(sqlite.Open("file:unique_id?mode=memory&cache=shared"), &gorm.Config{})
if err != nil {
t.Fatalf("an error occurred while opening the database: %v", err)
t.Fatalf("a error occurred while opening the database: %v", err)
}
t.Cleanup(func() {
sqlDB, err := gormDB.DB()
if err != nil {
t.Fatalf("failed to get generic database object from GORM DB: %v", err)
}
_ = sqlDB.Close()
})
db := gormDB
manager := NewManager()
manager.SetDB(db)
......
......@@ -11,10 +11,19 @@ import (
func TestWriteToDB5(t *testing.T) {
db, err := gorm.Open(sqlite.Open("file::memory:?cache=shared"), &gorm.Config{})
gormDB, err := gorm.Open(sqlite.Open("file:unique_id?mode=memory&cache=shared"), &gorm.Config{})
if err != nil {
t.Fatalf("a error occurred while opening the database: %v", err)
}
t.Cleanup(func() {
sqlDB, err := gormDB.DB()
if err != nil {
t.Fatalf("failed to get generic database object from GORM DB: %v", err)
}
_ = sqlDB.Close()
})
db := gormDB
manager := NewManager()
manager.SetDB(db)
......
......@@ -7,7 +7,7 @@ package jobqueue
import (
"fmt"
"github.com/stretchr/testify/assert"
"gorm.io/driver/mysql"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
"testing"
"time"
......@@ -20,8 +20,22 @@ func TestWriteToDB6(t *testing.T) {
// docker run --name mysql-test -e MYSQL_ROOT_PASSWORD=my-secret-pw -e MYSQL_DATABASE=testdb -p 3306:3306 -d mysql:latest && \
// docker logs -f mysql-test
dsn := "root:my-secret-pw@tcp(localhost:3306)/testdb?charset=utf8mb4&parseTime=True&loc=Local"
db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})
//dsn := "root:my-secret-pw@tcp(localhost:3306)/testdb?charset=utf8mb4&parseTime=True&loc=Local"
//db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})
gormDB, err := gorm.Open(sqlite.Open("file:unique_id?mode=memory&cache=shared"), &gorm.Config{})
if err != nil {
t.Fatalf("a error occurred while opening the database: %v", err)
}
t.Cleanup(func() {
sqlDB, err := gormDB.DB()
if err != nil {
t.Fatalf("failed to get generic database object from GORM DB: %v", err)
}
_ = sqlDB.Close()
})
db := gormDB
manager := NewManager()
manager.SetDB(db)
......
......@@ -11,8 +11,19 @@ import (
)
func TestCreateOrUpdateJob(t *testing.T) {
db, err := gorm.Open(sqlite.Open(":memory:"), &gorm.Config{})
assert.NoError(t, err)
gormDB, err := gorm.Open(sqlite.Open("file:unique_id?mode=memory&cache=shared"), &gorm.Config{})
if err != nil {
t.Fatalf("a error occurred while opening the database: %v", err)
}
t.Cleanup(func() {
sqlDB, err := gormDB.DB()
if err != nil {
t.Fatalf("failed to get generic database object from GORM DB: %v", err)
}
_ = sqlDB.Close()
})
db := gormDB
// Migrate the schema
assert.NoError(t, db.AutoMigrate(&JobPersistence{}, &JobLog{}, &JobStats{}))
......@@ -20,7 +31,7 @@ func TestCreateOrUpdateJob(t *testing.T) {
runner := &CounterRunnable{}
job := NewJob[CounterResult]("job1", runner)
assert.NoError(t, saveJob(job, db))
assert.NoError(t, saveJob(job.GetPersistence(), db))
var jobPersistence JobPersistence
assert.NoError(t, db.First(&jobPersistence, "id = ?", job.GetID()).Error)
......@@ -29,7 +40,7 @@ func TestCreateOrUpdateJob(t *testing.T) {
assert.Equal(t, "", jobPersistence.Description)
assert.Equal(t, Priority(1), jobPersistence.Priority)
job.description = "Updated description"
assert.NoError(t, saveJob(job, db))
assert.NoError(t, saveJob(job.GetPersistence(), db))
assert.NoError(t, db.First(&jobPersistence, "id = ?", job.GetID()).Error)
assert.Equal(t, "Updated description", jobPersistence.Description)
......
......@@ -7,31 +7,39 @@ import (
"github.com/stretchr/testify/assert"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
"gorm.io/gorm/logger"
"log"
"os"
"testing"
"time"
)
func TestUpdateJob(t *testing.T) {
db, err := gorm.Open(sqlite.Open(":memory:"), &gorm.Config{})
assert.NoError(t, err)
gormDB, err := gorm.Open(sqlite.Open("file:unique_id?mode=memory&cache=shared"), &gorm.Config{})
if err != nil {
t.Fatalf("a error occurred while opening the database: %v", err)
}
t.Cleanup(func() {
sqlDB, err := gormDB.DB()
if err != nil {
t.Fatalf("failed to get generic database object from GORM DB: %v", err)
}
_ = sqlDB.Close()
})
db := gormDB
assert.NoError(t, db.AutoMigrate(&JobPersistence{}, &JobLog{}, &JobStats{}))
runner := &CounterRunnable{}
job := NewJob[CounterResult]("job1", runner)
assert.NoError(t, saveJob(job, db))
assert.NoError(t, saveJob(job.GetPersistence(), db))
job.SetPriority(PriorityHigh)
assert.NoError(t, updateJob(job, db))
assert.NoError(t, updateJob(job.GetPersistence(), db))
var jobPersistence JobPersistence
assert.NoError(t, db.First(&jobPersistence, "id = ?", job.GetID()).Error)
assert.Equal(t, PriorityDefault, jobPersistence.Priority) // PriorityDefault because the update should not update the priority
assert.NoError(t, saveJob(job, db))
assert.NoError(t, saveJob(job.GetPersistence(), db))
assert.NoError(t, db.First(&jobPersistence, "id = ?", job.GetID()).Error)
assert.Equal(t, PriorityHigh, jobPersistence.Priority)
......@@ -43,19 +51,19 @@ func TestUpdateJob(t *testing.T) {
func TestCheckAndSaveOrUpdate(t *testing.T) {
newLogger := logger.New(
log.New(os.Stdout, "\r\n", log.LstdFlags),
logger.Config{
SlowThreshold: time.Second,
LogLevel: logger.Info,
Colorful: true,
},
)
db, err := gorm.Open(sqlite.Open(":memory:"), &gorm.Config{
Logger: newLogger,
gormDB, err := gorm.Open(sqlite.Open("file:unique_id?mode=memory&cache=shared"), &gorm.Config{})
if err != nil {
t.Fatalf("a error occurred while opening the database: %v", err)
}
t.Cleanup(func() {
sqlDB, err := gormDB.DB()
if err != nil {
t.Fatalf("failed to get generic database object from GORM DB: %v", err)
}
_ = sqlDB.Close()
})
assert.NoError(t, err)
db := gormDB
assert.NoError(t, db.AutoMigrate(&JobPersistence{}, &JobLog{}, &JobStats{}))
......@@ -66,13 +74,13 @@ func TestCheckAndSaveOrUpdate(t *testing.T) {
var jobPersistence JobPersistence
assert.NoError(t, syncer.CheckAndSaveOrUpdate(job))
assert.NoError(t, syncer.CheckAndSaveOrUpdate(job.GetPersistence()))
jobPersistence = JobPersistence{}
assert.NoError(t, db.First(&jobPersistence, "id = ?", job.GetID()).Error)
assert.Equal(t, PriorityDefault, jobPersistence.Priority)
job.SetPriority(PriorityHigh)
assert.NoError(t, syncer.CheckAndSaveOrUpdate(job))
assert.NoError(t, syncer.CheckAndSaveOrUpdate(job.GetPersistence()))
jobPersistence = JobPersistence{}
assert.NoError(t, db.First(&jobPersistence, "id = ?", job.GetID()).Error)
assert.Equal(t, PriorityDefault, jobPersistence.Priority) // second update should not update the priority, because update only update stats and logs
......@@ -94,10 +102,10 @@ func TestCheckAndSaveOrUpdate(t *testing.T) {
JobID: job.GetID(),
}}
assert.NoError(t, syncer.CheckAndSaveOrUpdate(job))
assert.NoError(t, syncer.CheckAndSaveOrUpdate(job.GetPersistence()))
job.stats.RunCount = 9
assert.NoError(t, syncer.CheckAndSaveOrUpdate(job))
assert.NoError(t, syncer.CheckAndSaveOrUpdate(job.GetPersistence()))
jobPersistence = JobPersistence{}
assert.NoError(t, db.First(&jobPersistence, "id = ?", job.GetID()).Error)
......
......@@ -5,12 +5,13 @@ package jobqueue
import (
"errors"
"fmt"
"gorm.io/gorm"
"strings"
"time"
)
func (s *JobSyncer) CheckAndSaveOrUpdate(job GenericJob) error {
func (s *JobSyncer) CheckAndSaveOrUpdate(job JobPersistence) error {
s.mu.Lock()
defer s.mu.Unlock()
......@@ -18,11 +19,10 @@ func (s *JobSyncer) CheckAndSaveOrUpdate(job GenericJob) error {
return ErrNoDatabaseConnection
}
permJob := job.GetPersistence()
db := s.manager.database
fmt.Println("Database: ", db)
var existing JobPersistence
result := db.Where("id = ?", permJob.ID).First(&existing)
result := db.Where("id = ?", job.GetID()).First(&existing)
if result.Error == nil {
return updateJob(job, db)
......@@ -88,7 +88,7 @@ func (s *JobSyncer) ResetStats(job GenericJob) error {
if s.manager == nil || s.manager.database == nil {
return ErrNoDatabaseConnection
}
return updateJob(job, s.manager.database)
return updateJob(job.GetPersistence(), s.manager.database)
}
......@@ -98,21 +98,19 @@ func (s *JobSyncer) UpdateJob(job GenericJob) error {
if s.manager == nil || s.manager.database == nil {
return ErrNoDatabaseConnection
}
return updateJob(job, s.manager.database)
return updateJob(job.GetPersistence(), s.manager.database)
}
func updateJob(job GenericJob, db *gorm.DB) error {
func updateJob(job JobPersistence, db *gorm.DB) error {
if db == nil {
return ErrNoDatabaseConnection
}
permJob := job.GetPersistence()
maxRetries := 3
var attempt int
for attempt = 0; attempt < maxRetries; attempt++ {
err := update(&permJob, db)
err := update(&job, db)
if err != nil {
if strings.Contains(err.Error(), "lock") {
time.Sleep(time.Millisecond * 100)
......@@ -154,7 +152,7 @@ func update(job *JobPersistence, db *gorm.DB) error {
}
}
for i, _ := range job.Logs {
for i := range job.Logs {
job.Logs[i].LogID = 0
_ = tx.Create(&job.Logs[i])
// no error handling, if it fails, it fails
......@@ -170,7 +168,7 @@ func (s *JobSyncer) SaveJob(job GenericJob) error {
if s.manager == nil || s.manager.database == nil {
return ErrNoDatabaseConnection
}
return saveJob(job, s.manager.database)
return saveJob(job.GetPersistence(), s.manager.database)
}
func save(job *JobPersistence, db *gorm.DB) error {
......@@ -181,23 +179,33 @@ func save(job *JobPersistence, db *gorm.DB) error {
return db.Transaction(func(tx *gorm.DB) error {
var existingJob JobPersistence
if err := tx.First(&existingJob, "id = ?", job.ID).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
if err := tx.Create(job).Error; err != nil {
return ErrFailedToCreate
}
} else {
return ErrFailedToQueryExistingJob
}
} else {
if err := tx.Save(job).Error; err != nil {
return err
return ErrFailedToSaveJob
}
}
if job.Stats != (JobStats{}) {
job.Stats.JobID = job.ID
if job.Stats.RunCount == 0 {
Info("Stats runCount is 0, skipping update")
}
if err := tx.Save(&job.Stats).Error; err != nil {
if err := tx.Model(job.Stats).
Select("*").
Omit("job_id", "created_at").
Updates(job.Stats).Error; err != nil {
return err
}
}
for i, _ := range job.Logs {
for i := range job.Logs {
job.Logs[i].LogID = 0
_ = tx.Create(&job.Logs[i])
// no error handling, if it fails, it fails
......@@ -207,18 +215,16 @@ func save(job *JobPersistence, db *gorm.DB) error {
})
}
func saveJob(job GenericJob, db *gorm.DB) error {
func saveJob(job JobPersistence, db *gorm.DB) error {
if db == nil {
return ErrNoDatabaseConnection
}
permJob := job.GetPersistence()
maxRetries := 3
var attempt int
for attempt = 0; attempt < maxRetries; attempt++ {
err := save(&permJob, db)
err := save(&job, db)
if err != nil {
if strings.Contains(err.Error(), "lock") {
time.Sleep(time.Millisecond * 100)
......
......@@ -12,8 +12,19 @@ import (
)
func TestDeleteJob(t *testing.T) {
db, err := gorm.Open(sqlite.Open("file::memory:?cache=shared"), &gorm.Config{})
gormDB, err := gorm.Open(sqlite.Open("file:unique_id?mode=memory&cache=shared"), &gorm.Config{})
if err != nil {
t.Fatalf("a error occurred while opening the database: %v", err)
}
t.Cleanup(func() {
sqlDB, err := gormDB.DB()
if err != nil {
t.Fatalf("failed to get generic database object from GORM DB: %v", err)
}
_ = sqlDB.Close()
})
db := gormDB
db.Logger = db.Logger.LogMode(4)
assert.Nil(t, err)
......@@ -27,7 +38,7 @@ func TestDeleteJob(t *testing.T) {
// Erstelle einen Job zum Löschen
runner := &CounterRunnable{}
job := NewJob[CounterResult]("testJobID", runner)
err = saveJob(job, db)
err = saveJob(job.GetPersistence(), db)
assert.Nil(t, err)
var count int64
......@@ -42,9 +53,21 @@ func TestDeleteJob(t *testing.T) {
db.Model(&JobPersistence{}).Where("id = ?", "testJobID").Count(&count)
assert.Equal(t, int64(0), count)
}
func TestResetLogs(t *testing.T) {
db, err := gorm.Open(sqlite.Open("file::memory:?cache=shared"), &gorm.Config{})
assert.Nil(t, err)
gormDB, err := gorm.Open(sqlite.Open("file:unique_id?mode=memory&cache=shared"), &gorm.Config{})
if err != nil {
t.Fatalf("a error occurred while opening the database: %v", err)
}
t.Cleanup(func() {
sqlDB, err := gormDB.DB()
if err != nil {
t.Fatalf("failed to get generic database object from GORM DB: %v", err)
}
_ = sqlDB.Close()
})
db := gormDB
db.Logger = db.Logger.LogMode(4)
......@@ -59,7 +82,7 @@ func TestResetLogs(t *testing.T) {
// Erstelle einen Job und füge einige Logs hinzu
runner := &CounterRunnable{}
job := NewJob[CounterResult]("testJobID", runner)
err = saveJob(job, db)
err = saveJob(job.GetPersistence(), db)
assert.Nil(t, err)
// Füge Logs zum Job hinzu
......@@ -84,8 +107,19 @@ func TestResetLogs(t *testing.T) {
}
func TestResetStats(t *testing.T) {
db, err := gorm.Open(sqlite.Open("file::memory:?cache=shared"), &gorm.Config{})
assert.Nil(t, err)
gormDB, err := gorm.Open(sqlite.Open("file:unique_id?mode=memory&cache=shared"), &gorm.Config{})
if err != nil {
t.Fatalf("a error occurred while opening the database: %v", err)
}
t.Cleanup(func() {
sqlDB, err := gormDB.DB()
if err != nil {
t.Fatalf("failed to get generic database object from GORM DB: %v", err)
}
_ = sqlDB.Close()
})
db := gormDB
db.Logger = db.Logger.LogMode(4)
......@@ -100,7 +134,7 @@ func TestResetStats(t *testing.T) {
// Erstelle einen Job und setze einige Statistiken
runner := &CounterRunnable{}
job := NewJob[CounterResult]("testJobID", runner)
err = saveJob(job, db)
err = saveJob(job.GetPersistence(), db)
assert.Nil(t, err)
// Aktualisiere die Job-Statistiken
......
{ pkgs ? import <nixpkgs> {}, inputs, phps, lib, config, modulesPath, ... }:
{
# https://devenv.sh/packages/
packages = with pkgs; [
inputs.version.defaultPackage."${builtins.currentSystem}"
appimage-run
blackbox
blackbox-terminal
coreutils-full
dbeaver
dbeaver
delve
dialog
drill
eza
fd
fd
feh
gcc12
gdlv
git
glab
gnugrep
gnumake
gnused
go-licenses
gosec
go-task
gum
httpie
hurl
jq
libffi
logrotate
meld
memcached
netcat
nixfmt
nodePackages.mermaid-cli
openssh
procps
ranger
unixtools.xxd
unzip
util-linux
wget
zlib
];
# https://devenv.sh/languages/
# languages.nix.enable = true;
languages = { go = { enable = true; }; };
difftastic.enable = true;
scripts.run-sshd.exec = ''
set -x
cd ${config.devenv.root}/docker/sftp-server
${pkgs.docker-client}/bin/docker docker build -t jobqueue-sftp-server .
cd -
${pkgs.coreutils}/bin/chmod 700 ${config.devenv.root}/.config/temp_rsa_key
${pkgs.coreutils}/bin/chmod 700 ${config.devenv.root}/.config/temp_ed25518_key
${pkgs.coreutils}/bin/mkdir -p ${config.devenv.root}/.devenv/chroot/home/demo/.ssh
${pkgs.coreutils}/bin/cat ${config.devenv.root}/.config/demo_ssh_key.pub > ${config.devenv.root}/.devenv/chroot/home/demo/.ssh/authorized_keys
${pkgs.coreutils}/bin/chmod 700 ${config.devenv.root}/.devenv/chroot/home/demo/.ssh
${pkgs.coreutils}/bin/chmod 600 ${config.devenv.root}/.devenv/chroot/home/demo/.ssh/authorized_keys
${pkgs.coreutils}/bin/cat <<EOF > ${config.devenv.root}/.config/sshd_config
AuthorizedKeysCommand ${pkgs.coreutils}/bin/cat ${config.devenv.root}/.devenv/chroot/home/demo/.ssh/authorized_keys
AuthorizedKeysCommandUser nobody
Match User root
ChrootDirectory ${config.devenv.root}/.devenv/chroot
ForceCommand internal-sftp
PasswordAuthentication no
PermitTunnel no
AllowAgentForwarding no
AllowTcpForwarding no
X11Forwarding no
PermitRootLogin no
AllowUsers demo root
EOF
${pkgs.openssh}/bin/sshd -D -e -o \
HostKey=${config.devenv.root}/.config/temp_rsa_key \
-f ${config.devenv.root}/.config/sshd_config \
-o HostKey=${config.devenv.root}/.config/temp_ed25518_key \
-o Port=''${1:-2222} \
-o AuthorizedKeysFile=${config.devenv.root}/.devenv/chroot/home/demo/.ssh/authorized_keys \
-o PidFile=${config.devenv.root}/.devenv/sshd.pid
'';
scripts.draw-graph.exec = ''
echo -e "Enter Meirmaid graph definition. ''${RED}End with Ctrl+D''${RESET}\n"
diagram=$(${pkgs.gum}/bin/gum write --placeholder "Enter Meirmaid graph definition. End with Ctrl+D")
tmpOutput=$(mktemp).png
echo "$diagram" | ${pkgs.nodePackages.mermaid-cli}/bin/mmdc -i - -o "$tmpOutput"
${pkgs.feh}/bin/feh $tmpOutput
# should delte the file, but does not work ask with gum
${pkgs.gum}/bin/gum confirm "Delete temporary file?"
if [ $? -eq 0 ]; then
rm "$tmpOutput"
else
echo "not deleting; file is at $tmpOutput"
fi
'';
scripts.get-go-default-packages.exec = ''
#!${pkgs.bash}/bin/bash
echo $(awk -F ' ' '/^module / { print $2 }' go.mod)
'';
# This script is executed when the app is built
# You can use it to build the app
scripts.test-lib.exec = ''
#!${pkgs.bash}/bin/bash
set -x
${pkgs.gosec}/bin/gosec ${config.devenv.root}
${pkgs.go}/bin/go test -tags=runOnTask -cover -v ${config.devenv.root}
${pkgs.go}/bin/go test -tags=runOnTask -bench -v ${config.devenv.root}
${pkgs.go}/bin/go test -tags=runOnTask -race -v ${config.devenv.root}
'';
# This scritp is used to deploy the app to the gitlab registry
# It is used by the gitlab-ci.yml file
# The environment variables are set in the gitlab project settings
scripts.deploy-lib.exec = ''
#!${pkgs.bash}/bin/bash
PATH="''${PATH}":${pkgs.coreutils}/bin
PATH="''${PATH}":${pkgs.jq}/bin/
PATH="''${PATH}":${pkgs.curl}/bin/
PATH="''${PATH}":${pkgs.moreutils}/bin/
PATH="''${PATH}":${pkgs.gnutar}/bin
PATH="''${PATH}":${pkgs.gzip}/bin/
PATH="''${PATH}":${pkgs.eza}/bin/
PATH="''${PATH}":${pkgs.git}/bin/
PATH="''${PATH}":${
inputs.version.defaultPackage."${builtins.currentSystem}"
}/bin/
export PATH
if [[ -f .env-gitlab-ci ]]; then
source .env-gitlab-ci
rm .env-gitlab-ci
fi
set -x
## if $HOME not set, set it to current directory
if [[ -z "''${HOME}" ]]; then
HOME=$(pwd)
fi
export HOME
git config user.email "''${GITLAB_USER_EMAIL}"
git config user.name "''${GITLAB_USER_NAME:-"Gitlab CI"}"
git config pull.rebase true
git config http.sslVerify "false"
git remote set-url origin https://pad:''${GITLAB_TOKEN}@''${CI_REPOSITORY_URL#*@}
git fetch --all --tags --unshallow
git reset --hard origin/master
git checkout $CI_COMMIT_REF_NAME
git pull origin $CI_COMMIT_REF_NAME
if [ ! -z "''${CI_PROJECT_DIR}" ]; then
echo "CI_PROJECT_DIR is set, using it as project root."
project_root=$(realpath "''${CI_PROJECT_DIR}")/
elif [ ! -z "''${DEVENV_ROOT}" ]; then
echo "DEVENV_ROOT is set, using it as project root."
project_root=$(realpath "''${DEVENV_ROOT}")/
else
echo "Error: DEVENV_ROOT or CI_PROJECT_DIR environment variables are not set."
exit 1
fi
if [ ! -d "''${project_root}" ]; then
echo "Error: Project root directory does not seem to be valid."
echo "Check the DEVENV_ROOT or CI_PROJECT_DIR environment variables."
exit 1
fi
if [ -z "'CI_JOB_TOKEN" ]; then
echo "Error: CI_JOB_TOKEN variable is not set."
exit 1
fi
git --no-pager log --decorate=short --pretty=oneline
gitVersion=v$(version predict)
git tag -a $gitVersion -m"chore: bump version"
git --no-pager log --decorate=short --pretty=oneline
git push -o ci.skip origin ''${CI_COMMIT_REF_NAME} --tags
echo "done"
'';
enterShell = ''
cat <<'EOF' > CONTRIBUTING.md
# Contributing to schukai GmbH Projects
## Code of Conduct
Be a human, not an asshole. Common sense and basic human decency apply.
## Getting Started
### Setting up the Project
1. Fork the project on GitLab.
2. Clone your fork locally. Replace `[your-username]` with your GitLab username and `[project-name]` with the actual project name:
```bash
git clone $(git config --get remote.origin.url)
```
3. Add the upstream repository. Replace `[original-username]` and `[project-name]` with the original repository's username and project name:
```bash
git remote add upstream https://gitlab.schukai.com/[original-username]/[project-name].git
```
### Making Changes
1. Create a new branch:
```bash
git checkout -b new-feature-branch
```
2. Make your changes.
3. Commit your changes:
```bash
git commit -m "Description of change"
```
### Submitting a Merge Request
1. Push your changes to your fork:
```bash
git push origin new-feature-branch
```
2. Navigate to the original project repository on `gitlab.schukai.com`.
3. Open a Merge Request and provide a clear description of the changes.
## Coding Guidelines
- Follow the coding style used in the project.
- Write unit tests for new features.
- Ensure that all tests pass before submitting a Merge Request.
## Reporting Issues
If you find an issue, please create a new issue on `gitlab.schukai.com`.
## Additional Resources
- [GitLab Flow](https://docs.gitlab.com/ee/topics/gitlab_flow.html)
- [GitLab Merge Request Guidelines](https://docs.gitlab.com/ee/user/project/merge_requests/)
Thank you for your contribution!
EOF
cat <<'EOF' > LICENSE
Copyright (C) 2023 schukai GmbH
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
EOF
cat <<'EOF' > Taskfile.yml
# THIS FILE IS AUTOGENERATED BY THE DEVENVSHELL
# DO NOT EDIT THIS FILE MANUALLY
# INSTEAD EDIT THE DEVENVSHELL CONFIGURATION FILE devenv.nix
# AND OPEN A SHELL WITH THE COMMAND devenv shell
#
# Information about the task runner can be found here:
# https://taskfile.dev
version: '3'
tasks:
default:
cmds:
- task --list
silent: true
test:
desc: Execute unit tests in Go.
env:
TEST_BY_TASK: true
cmds:
- docker pull atmoz/sftp:alpine
- docker pull axllent/mailpit
- echo "Execute unit tests in Go."
- test-lib
test-fuzz:
desc: Conduct fuzzing tests.#
env:
TEST_BY_TASK: true
cmds:
- echo "Conduct fuzzing tests."
- go test -tags=runOnTask -v -fuzztime=30s -fuzz=Fuzz ./...
add-licenses:
desc: Attach license headers to Go files.
cmds:
- echo "Attach license headers to Go files."
- go install github.com/google/addlicense@latest
- addlicense -c "schukai GmbH" -s -l "AGPL-3.0" ./*.go
silent: true
check-licenses:
desc: Check license headers of Go files.
silent: true
cmds:
- go-licenses save "$(get-go-default-packages)" --ignore "gitlab.schukai.com" --force --save_path ''${DEVENV_ROOT}/licenses/
check:
desc: Confirm repository status.
cmds:
- git diff-index --quiet HEAD || (echo "There are uncommitted changes after running make. Please commit or stash them before running make."; exit 1)
silent: true
commit:
desc: Commit changes to the repository.
aliases:
- c
- ci
- git-commit
cmds:
- do-git-commit
EOF
cat <<'EOF' > .gitlab-ci.yml
# THIS FILE IS AUTOGENERATED BY THE DEVENVSHELL
# DO NOT EDIT THIS FILE MANUALLY
# INSTEAD EDIT THE DEVENVSHELL CONFIGURATION FILE devenv.nix
# AND OPEN A SHELL WITH THE COMMAND devenv shell
#
image: docker-registry.schukai.com:443/nixos-ci-devenv:latest
# services:
# - docker:dind
variables:
# The repo name as used in
# https://github.com/nix-community/NUR/blob/master/repos.json
NIXOS_VERSION: "23.05"
NIXPKGS_ALLOW_UNFREE: "1"
NIXPKGS_ALLOW_INSECURE: "1"
GIT_DEPTH: 10
stages:
- test
- deploy
before_script:
- echo > .env-gitlab-ci
- variables=("HOME=$HOME" "CI_COMMIT_REF_NAME=$CI_COMMIT_REF_NAME" "CI_REPOSITORY_URL=$CI_REPOSITORY_URL" "GITLAB_TOKEN=$GITLAB_TOKEN" "CI_JOB_TOKEN=$CI_JOB_TOKEN" "GITLAB_USER_EMAIL=$GITLAB_USER_EMAIL" "GITLAB_USER_NAME=\"$GITLAB_USER_NAME\"" "CI_REGISTRY_USER=$CI_REGISTRY_USER" "CI_PROJECT_ID=$CI_PROJECT_ID" "CI_PROJECT_DIR=$CI_PROJECT_DIR" "CI_API_V4_URL=$CI_API_V4_URL" "CI_PROJECT_NAME=$CI_PROJECT_NAME" "CI_COMMIT_SHORT_SHA=$CI_COMMIT_SHORT_SHA"); for var in "''${variables[@]}"; do echo "$var" >> .env-gitlab-ci; done
- cat .env-gitlab-ci
- env
- nix shell nixpkgs#docker-client -c docker info
after_script:
- if [ -f .env-gitlab-ci ]; then rm .env-gitlab-ci; fi
test:
stage: test
tags:
- nixos
script:
- devenv shell test-lib
cache:
- key: nixos
paths:
- /nix/store
artifacts:
paths:
- dist
deploy:
stage: deploy
tags:
- nixos
script:
- devenv shell -c deploy-lib
when: on_success
cache:
- key: nixos
paths:
- /nix/store
EOF
'';
scripts.do-git-commit.exec = ''
#!/usr/bin/env bash
# Define colors if the terminal supports it
if [ -t 1 ]; then
RED='\033[0;31m'
GREEN='\033[0;32m'
RESET='\033[0m'
BOLD='\033[1m'
else
RED=""
GREEN=""
RESET=""
fi
step=1
reset
clear
# create random log file
LOGFILE="$(mktemp)"
if [ $? -ne 0 ]; then
echo -e "''${RED}✖ Could not create temporary log file. Exiting.''${RESET}"
exit 1
fi
log_and_display() {
echo -e "''${GREEN}==> $step. $1''${RESET}" | tee -a $LOGFILE
step=$((step + 1))
}
log_error_and_display() {
echo -e "''${RED}==> $step. $1''${RESET}" | tee -a $LOGFILE
}
printLogfileAndExit() {
exit_code=$1
echo -e "\n\n========================================\n\n\n"
echo -e "\n\n''${BOLD}Git and GitLab Automation Script''${RESET}\n\nI have performed the following actions:\n\n"
cat "$LOGFILE"
# Optional: Remove log file
rm -f "$LOGFILE"
if [ $exit_code -eq 0 ]; then
echo -e "\n''${GREEN}✔''${RESET} All actions were successful" | tee -a $LOGFILE
elif [ $exit_code -eq -1 ]; then
echo -e "\n''${RED}✖''${RESET} The script was manually cancelled" | tee -a $LOGFILE
exit_code=0
else
echo -e "\n''${RED}✖''${RESET} Some actions failed" | tee -a $LOGFILE
fi
exit $exit_code
}
print_headline() {
local title=$1
local underline=$(printf '─%.0s' $(seq 1 ''${#title}))
echo -e "\n\n''${BOLD}''${title}\n''${underline}''${RESET}\n"
}
do_cancel() {
echo -e "''${RED}==> ✖ Cancelled.''${RESET}" | tee -a $LOGFILE
printLogfileAndExit -1
}
# Function for unified logging and display
log_action() {
if [ $? -eq 0 ]; then
echo -e " ''${GREEN}✔''${RESET} $1: Successful" | tee -a $LOGFILE
else
echo -e " ''${RED}✖''${RESET} $1: Failed" | tee -a $LOGFILE
printLogfileAndExit 1
fi
}
print_what_to_do() {
echo -e "\n\nWhat do you want to do?\n"
}
git_status=$(git status --porcelain)
if [[ -z "$git_status" ]]; then
log_error_and_display "No changes to commit. Exiting."
printLogfileAndExit 0
fi
print_headline "Choose commit type"
selection=$(gum choose "feat: (new feature for the user, not a new feature for build script)" "fix: (bug fix for the user, not a fix to a build script)" "chore: (updating grunt tasks etc.; no production code change)" "docs: (changes to the documentation)" "style: (formatting, missing semi colons, etc; no production code change)" "refactor: (refactoring production code, eg. renaming a variable)" "test: (adding missing tests, refactoring tests; no production code change)" "Cancel")
commit_type=$(echo "$selection" | awk -F':' '{print $1}')
if [[ "$commit_type" == "Cancel" ]]; then
do_cancel
fi
log_and_display "You chose the commit type: $commit_type"
# NEXT STEP ISSUE HANDLING ############################################################################################################
#log_and_display "Issue handling"
gitlabIssues=()
while IFS= read -r line; do
if [[ $line =~ ^# ]]; then
id=$(echo "$line" | awk '{print substr($1, 2)}')
title=$(echo "$line" | awk -F'about' '{print $1}' | awk '{$1=$2=""; print substr($0, 3)}')
gitlabIssues+=("$id > $title")
fi
done < <(gum spin --spinner dot --show-output --title "Ask gitlab ..." -- glab issue list --output-format=details)
## if issues are available, ask if user wants to use an existing issue or create a new one
createOption="Create new issue"
existingOption="Use existing issue"
cancelOption="Cancel"
print_headline "Choose issue handling"
if [ ''${#gitlabIssues[@]} -eq 0 ]; then
log_and_display "There are no issues available."
print_what_to_do
choice=$(gum choose "$createOption" "$cancelOption")
else
log_and_display "There are ''${#gitlabIssues[@]} issues available."
print_what_to_do
choice=$(gum choose "$createOption" "$existingOption" "$cancelOption")
fi
if [[ "$choice" == "$cancelOption" ]]; then
do_cancel
fi
## array of issue ids
work_on_issue_ids=()
issue_text=""
if [[ "$choice" == "$createOption" ]]; then
print_headline "Create new issue"
issue_text=$(gum input --placeholder "Enter issue title")
echo -e "Enter issue description. ''${RED}End with Ctrl+D''${RESET}\n"
issue_description=$(gum write --placeholder "Enter issue description. End with Ctrl+D")
if [[ -z "$issue_text" ]]; then
log_error_and_display "Issue title is empty. Exiting."
printLogfileAndExit 1
fi
log_and_display "You entered the issue title: $issue_text"
log_and_display "You entered the issue description: $issue_description"
echo -e "\n"
gum confirm "Do you want to create this issue?"
# gum confirm exits with status 0 if confirmed and status 1 if cancelled.
if [ $? -eq 1 ]; then
do_cancel
fi
issue_output=$(glab issue create -t"$issue_text" --no-editor --description "$issue_description")
issue_id=$(echo "$issue_output" | grep -oP '(?<=/issues/)\d+')
work_on_issue_ids+=("$issue_id")
log_action "glab issue with id $issue_id created"
else
print_headline "Use existing issue"
echo -e "Select issue with arrow keys and press tab or space to select. Press enter to confirm.\n"
issue_ids=$(gum choose --no-limit "''${gitlabIssues[@]}")
# assign issue_ids to work_on_issue_ids. iterate over lines and take integer from beginning of line
while IFS= read -r line; do
work_on_issue_ids+=($(echo "$line" | grep -oP '^\d+'))
done <<<"$issue_ids"
fi
if [ ''${#work_on_issue_ids[@]} -eq 0 ]; then
log_and_display "No issue selected. Exiting."
printLogfileAndExit 0
fi
# NEXT STEP COMMIT MESSAGE ############################################################################################################
# print work_on_issue_ids
work_on_issue_ids_string=""
for i in "''${work_on_issue_ids[@]}"; do
work_on_issue_ids_string+="#$i "
done
log_and_display "You chose to work on the following issues: ''${work_on_issue_ids_string}"
print_headline "Check for changes to commit"
# ' ' = unmodified
# M = modified
# T = file type changed (regular file, symbolic link or submodule)
# A = added
# D = deleted
# R = renamed
# C = copied (if config option status.renames is set to "copies")
# U = updated but unmerged
# https://man.freebsd.org/cgi/man.cgi?query=git-status&sektion=1&manpath=freebsd-release-ports
count_all_changes=$(echo "$git_status" | wc -l)
count_staged_changes=$(echo "$git_status" | grep -c '^M')
count_new_staged_files=$(echo "$git_status" | grep -c '^A')
count_staged_changes=$((count_staged_changes + count_new_staged_files))
git_options_all="All $count_all_changes changes"
git_options_staged="Only the $count_staged_changes staged changes"
git_options_select_files="Select files"
git_options_cancel="Cancel"
git_options_array=()
if [[ $count_all_changes -gt 0 ]]; then
git_options_array+=("$git_options_all")
fi
if [[ $count_staged_changes -gt 0 ]]; then
git_options_array+=("$git_options_staged")
fi
git_options_array+=( "$git_options_select_files" )
git_options_array+=( "$git_options_cancel" )
selection=$(gum choose "''${git_options_array[@]}")
if [[ "$selection" == "$git_options_cancel" ]]; then
do_cancel
fi
if [[ "$selection" == "$git_options_all" ]]; then
git add -A
echo "1"
elif [[ "$selection" == "$git_options_select_files" ]]; then
files=()
while IFS= read -r line; do
files+=("$line")
done <<<"$git_status"
selected_files=$(gum choose --no-limit "''${files[@]}")
# no files selected
if [[ -z "$selected_files" ]]; then
log_and_display "No files selected. Exiting."
printLogfileAndExit 0
fi
# add selected files
while IFS= read -r line; do
## git proclimne could have letter, ? or ! at the beginning of the line
file=$(echo "$line" | awk '{print $2}')
if [[ -z "$file" || ! -f "$file" ]]; then
log_and_display "No file found in line: $line"
continue
fi
git add "$file"
done <<<"$selected_files"
fi
## count staged changes again and print
count_staged_changes=$(echo "$git_status" | grep -c '^M')
count_new_staged_files=$(echo "$git_status" | grep -c '^A')
count_staged_changes=$((count_staged_changes + count_new_staged_files))
log_and_display "You have $count_staged_changes staged changes to commit."
# NEXT STEP COMMIT MESSAGE ############################################################################################################
print_headline "Enter commit message"
commit_message=$(gum input --placeholder "Enter commit message" --value "$commit_type: $issue_text $work_on_issue_ids_string")
if [[ -z "$commit_message" ]]; then
log_error_and_display "Commit message is empty. Exiting."
printLogfileAndExit 1
fi
log_and_display "You entered the commit message: $commit_message"
gum confirm "Do you want to commit with this message?"
if [ $? -eq 1 ]; then
do_cancel
fi
# NEXT STEP COMMIT ####################################################################################################################
print_headline "Committing changes"
if ! git commit -m "$commit_message" ; then
log_error_and_display "Commit failed. Exiting."
printLogfileAndExit 1
fi
log_and_display "Commit successful."
# NEXT STEP PUSH ######################################################################################################################
print_headline "Pushing changes"
if ! git push ; then
log_error_and_display "Push failed. Exiting."
printLogfileAndExit 1
fi
log_and_display "Push successful."
# Close issue ######################################################################################################################
print_headline "Closing issues"
for issue_id in "''${work_on_issue_ids[@]}"; do
gum confirm "Do you want to close issue #$issue_id?"
if [ $? -eq 1 ]; then
continue
fi
if ! glab issue close "$issue_id" ; then
log_error_and_display "Closing issue $issue_id failed. Exiting."
else
log_and_display "Closing issue $issue_id successful."
fi
done
printLogfileAndExit 0
'';
}
inputs:
nixpkgs:
url: github:nixos/nixpkgs/nixos-23.11
version:
url: git+https://gitlab.schukai.com/oss/utilities/version.git
flake: true
......@@ -43,7 +43,7 @@ var (
ErrSchedulerNotSet = fmt.Errorf("scheduler is not set")
ErrJobNotActive = fmt.Errorf("job is not active")
ErrJobAlreadyActive = fmt.Errorf("job is already active")
ErrChannelAlreadyClosed = fmt.Errorf("channel is already closed")
ErrChannelAlreadyClosed = fmt.Errorf("the channel is already closed")
ErrUnknownScheduleType = fmt.Errorf("unknown schedule type")
ErrNoManager = fmt.Errorf("no manager")
ErrCannotLoadStatsFromDatabase = fmt.Errorf("errors while loading stats from database")
......@@ -54,4 +54,12 @@ var (
ErrJobSyncerNotRunning = fmt.Errorf("JobSyncer is not running")
ErrMaxRetriesReached = fmt.Errorf("maximum number of retries reached")
ErrTimeoutReached = fmt.Errorf("timeout reached")
ErrFailedToCreate = fmt.Errorf("failed to create")
ErrFailedToQueryExistingJob = fmt.Errorf("failed to query an existing job")
ErrFailedToSaveJob = fmt.Errorf("failed to save a job")
ErrScheduleTimeIsInThePast = fmt.Errorf("scheduled time is in the past")
ErrParameterIsNil = fmt.Errorf("parameter is nil")
ErrJobIDEmpty = fmt.Errorf("job ID is empty")
ErrManagerNotInitialized = fmt.Errorf("manager is not initialized")
ErrJobSyncerNotInitialized = fmt.Errorf("JobSyncer is not initialized")
)
{
"nodes": {
"devenv": {
"locked": {
"dir": "src/modules",
"lastModified": 1713353943,
"narHash": "sha256-1gDYT+Hhqpnt+CDYL1h2huE07c6BCod6qlsaFNTPcn8=",
"owner": "cachix",
"repo": "devenv",
"rev": "5b933eb8522b61873e859c9c68de16330d8f5d8b",
"type": "github"
},
"original": {
"dir": "src/modules",
"owner": "cachix",
"repo": "devenv",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
......@@ -51,34 +18,13 @@
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"pre-commit-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1713145326,
"narHash": "sha256-m7+IWM6mkWOg22EC5kRUFCycXsXLSU7hWmHdmBfmC3s=",
"lastModified": 1713344939,
"narHash": "sha256-jpHkAt0sG2/J7ueKnG7VvLLkBYUMQbXQ2L8OBpVG53s=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "53a2c32bc66f5ae41a28d7a9a49d321172af621e",
"rev": "e402c3eb6d88384ca6c52ef1c53e61bdc9b84ddd",
"type": "github"
},
"original": {
......@@ -88,29 +34,13 @@
"type": "github"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1710695816,
"narHash": "sha256-3Eh7fhEID17pv9ZxrPwCLfqXnYP006RKzSs0JptsN84=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "614b4613980a522ba49f0d194531beddbb7220d3",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.11",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1713145326,
"narHash": "sha256-m7+IWM6mkWOg22EC5kRUFCycXsXLSU7hWmHdmBfmC3s=",
"lastModified": 1704145853,
"narHash": "sha256-G/1AMt9ibpeMlcxvD1vNaC8imGaK+g7zZ99e29BLgWw=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "53a2c32bc66f5ae41a28d7a9a49d321172af621e",
"rev": "2d2ea8eab9e400618748ab1a6a108255233b602c",
"type": "github"
},
"original": {
......@@ -119,35 +49,10 @@
"type": "indirect"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1712897695,
"narHash": "sha256-nMirxrGteNAl9sWiOhoN5tIHyjBbVi5e2tgZUgZlK3Y=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "40e6053ecb65fcbf12863338a6dcefb3f55f1bf8",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": {
"inputs": {
"devenv": "devenv",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"pre-commit-hooks": "pre-commit-hooks",
"version": "version"
}
},
......@@ -177,11 +82,11 @@
"rev": "6b4f85fe6d934429cf3055bbcd8cf15014730118",
"revCount": 114,
"type": "git",
"url": "https://gitlab.schukai.com/oss/utilities/version.git"
"url": "https://gitlab.schukai.com/oss/utilities/version.git/"
},
"original": {
"type": "git",
"url": "https://gitlab.schukai.com/oss/utilities/version.git"
"url": "https://gitlab.schukai.com/oss/utilities/version.git/"
}
}
},
......
{
description = "Development environment";
inputs = {
nixpkgs = {url = "github:nixos/nixpkgs/nixos-23.11";};
flake-utils = {url = "github:numtide/flake-utils";};
version = {url = "git+https://gitlab.schukai.com/oss/utilities/version.git/";};
};
outputs = {
self,
nixpkgs,
flake-utils,
version,
}:
flake-utils.lib.eachDefaultSystem (system: let
inherit (nixpkgs.lib) optional;
pkgs' = import nixpkgs {inherit system;};
script-task = pkgs'.callPackage ./nix/scripts/go-task.nix {};
script-run-tests = pkgs'.callPackage ./nix/scripts/run-tests.nix {};
script-run-extended-tests = pkgs'.callPackage ./nix/scripts/run-extended-tests.nix {};
script-run-ci-tests = pkgs'.callPackage ./nix/scripts/run-ci-tests.nix {};
script-check-code = pkgs'.callPackage ./nix/scripts/check-code.nix {};
script-build-cover-report = pkgs'.callPackage ./nix/scripts/build-cover-report.nix {};
script-clean-up = pkgs'.callPackage ./nix/scripts/clean-up.nix {};
script-deploy = pkgs'.callPackage ./nix/scripts/deploy.nix {};
import-version = version.packages.${system}.version;
in {
devShells = {
default = let
ciJobToken = builtins.getEnv "CI_JOB_TOKEN";
in
pkgs'.mkShell {
nativeBuildInputs = with pkgs'; [
script-run-tests
script-run-extended-tests
script-run-ci-tests
script-check-code
script-build-cover-report
script-task
script-clean-up
script-deploy
import-version
alejandra
blackbox
blackbox-terminal
coreutils-full
delve
dialog
drill
fd
feh
gcc12
gdlv
git
glab
gnugrep
gnumake
gnused
go
go-licenses
golangci-lint
gosec
gum
jq
niv
libffi
logrotate
meld
memcached
netcat
ranger
unixtools.xxd
unzip
util-linux
vhs
wget
zlib
];
shellHook = ''
echo "Welcome to your development environment."
'';
};
};
});
}
......@@ -18,6 +18,7 @@ require (
gorm.io/driver/mysql v1.5.6
gorm.io/driver/sqlite v1.5.5
gorm.io/gorm v1.25.9
gotest.tools/v3 v3.5.1
)
require (
......@@ -30,6 +31,7 @@ require (
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-sql-driver/mysql v1.8.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/kr/fs v0.1.0 // indirect
......@@ -52,5 +54,4 @@ require (
golang.org/x/sys v0.19.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.6.0 // indirect
gotest.tools/v3 v3.5.1 // indirect
)
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8=
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
......@@ -29,6 +31,7 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
......@@ -45,7 +48,9 @@ github.com/lufia/plan9stats v0.0.0-20240408141607-282e7b5d6b74 h1:1KuuSOy4ZNgW0K
github.com/lufia/plan9stats v0.0.0-20240408141607-282e7b5d6b74/go.mod h1:ilwx/Dta8jXAgpFYFvSWEMwxmbWXyiUHkd5FwyKhb5k=
github.com/mattn/go-sqlite3 v1.14.17 h1:mCRHCLDUBXgpKAqIKsaAaAsrAlbkeomtRFKXh2L6YIM=
github.com/mattn/go-sqlite3 v1.14.17/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0=
github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y=
github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc=
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
......@@ -66,6 +71,7 @@ github.com/shirou/gopsutil/v3 v3.24.3 h1:eoUGJSmdfLzJ3mxIhmOAhgKEKgQkeOwKpz1NbhV
github.com/shirou/gopsutil/v3 v3.24.3/go.mod h1:JpND7O217xa72ewWz9zN2eIIkPWsDN/3pl0H8Qt0uwg=
github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM=
github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ=
github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU=
github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
......@@ -87,6 +93,8 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
......@@ -116,6 +124,8 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
......@@ -134,10 +144,13 @@ golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q=
golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
......@@ -150,6 +163,7 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
......@@ -159,8 +173,7 @@ gorm.io/driver/mysql v1.5.6/go.mod h1:sEtPWMiqiN1N1cMXoXmBbd8C6/l+TESwriotuRRpkD
gorm.io/driver/sqlite v1.5.5 h1:7MDMtUZhV065SilG62E0MquljeArQZNfJnjd9i9gx3E=
gorm.io/driver/sqlite v1.5.5/go.mod h1:6NgQ7sQWAIFsPrJJl1lSNSu2TABh0ZZ/zm5fosATavE=
gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
gorm.io/gorm v1.25.8 h1:WAGEZ/aEcznN4D03laj8DKnehe1e9gYQAjW8xyPRdeo=
gorm.io/gorm v1.25.8/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
gorm.io/gorm v1.25.9 h1:wct0gxZIELDk8+ZqF/MVnHLkA1rvYlBWUMv2EdsK1g8=
gorm.io/gorm v1.25.9/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU=
gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU=
......@@ -16,7 +16,7 @@ import (
)
// TestRoundTrip tests the round trip of jobs from yaml to the manager and back to yaml
// This test runs forever and must be stopped manually
// This test runs forever and must be stopped manually. this test run without database
// Use the following command to run this test:
// go test -timeout 6h -run TestRoundTrip -v
func TestRoundTrip(t *testing.T) {
......@@ -63,6 +63,8 @@ func TestRoundTrip(t *testing.T) {
var err error
t.Log("This test runs forever and must be stopped manually")
cronInstance := cron.New(cron.WithSeconds())
cronInstance.Start()
......