Skip to content
Snippets Groups Projects
Verified Commit 544fef0d authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

chore: move from devenv to flake.nix #53

parent 513a0987
Branches
Tags
No related merge requests found
File moved
{ pkgs }:
pkgs.writeShellScriptBin "hello-world" ''
echo "Hello, world!"
''
source_url "https://raw.githubusercontent.com/cachix/devenv/d1f7b48e35e6dee421cfd0f51481d17f77586997/direnvrc" "sha256-YBzqskFZxmNb3kYVoKD9ZixoPXJh1C9ZvTLGFRkauZ0="
use devenv
\ No newline at end of file
watch_file $(find . -name "*.nix" -printf '"%p" ')
use flake
......@@ -13,3 +13,4 @@ smell.go
/.attach_*
.direnv/
.direnv/
.back
......@@ -37,7 +37,7 @@ test:
tags:
- nixos
script:
- devenv shell test-lib
- nix develop --command run-ci-tests
cache:
- key: nixos
......
run:
concurrency: 4
timeout: 5m
issues-exit-code: 2
tests: false
output:
show-stats: true
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# GitHub Copilot persisted chat sessions
/copilot/chatSessions
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="accountSettings">
<option name="activeProfile" value="profile:default" />
<option name="activeRegion" value="eu-west-1" />
<option name="recentlyUsedProfiles">
<list>
<option value="profile:default" />
</list>
</option>
<option name="recentlyUsedRegions">
<list>
<option value="eu-west-1" />
</list>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GoImports">
<option name="optimizeImportsOnTheFly" value="false" />
</component>
</project>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="TsLint" enabled="true" level="WARNING" enabled_by_default="true" />
</profile>
</component>
\ No newline at end of file
......@@ -3,10 +3,7 @@
<component name="Go" enabled="true" />
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.devenv" />
<excludeFolder url="file://$MODULE_DIR$/.direnv" />
</content>
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
......
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MarkdownSettings">
<enabledExtensions>
<entry key="MermaidLanguageExtension" value="false" />
<entry key="PlantUMLLanguageExtension" value="true" />
</enabledExtensions>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager">
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
<component name="accountSettings">
<option name="activeProfile" value="profile:default" />
<option name="activeRegion" value="eu-west-1" />
<option name="recentlyUsedProfiles">
<list>
<option value="profile:default" />
</list>
</option>
<option name="recentlyUsedRegions">
<list>
<option value="eu-west-1" />
</list>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="9979eb22-471e-4f2f-b624-fd3edb5e8c6e" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/.back/scripts/hello.nix" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.golangci.yaml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/flake.lock" afterDir="false" />
<change afterPath="$PROJECT_DIR$/flake.nix" afterDir="false" />
<change afterPath="$PROJECT_DIR$/nix/scripts/build-cover-report.nix" afterDir="false" />
<change afterPath="$PROJECT_DIR$/nix/scripts/check-code.nix" afterDir="false" />
<change afterPath="$PROJECT_DIR$/nix/scripts/common.nix" afterDir="false" />
<change afterPath="$PROJECT_DIR$/nix/scripts/go-task.nix" afterDir="false" />
<change afterPath="$PROJECT_DIR$/nix/scripts/run-ci-tests.nix" afterDir="false" />
<change afterPath="$PROJECT_DIR$/nix/scripts/run-extended-tests.nix" afterDir="false" />
<change afterPath="$PROJECT_DIR$/nix/scripts/run-tests.nix" afterDir="false" />
<change afterPath="$PROJECT_DIR$/schedule-time_test.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.envrc" beforeDir="false" afterPath="$PROJECT_DIR$/.envrc" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.gitlab-ci.yml" beforeDir="false" afterPath="$PROJECT_DIR$/.gitlab-ci.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/.gitignore" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/aws.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/go.imports.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/job-queues.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/job-queues.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/markdown.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Taskfile.yml" beforeDir="false" afterPath="$PROJECT_DIR$/.back/Taskfile.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/database-6_test.go" beforeDir="false" afterPath="$PROJECT_DIR$/database-6_test.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/database.go" beforeDir="false" afterPath="$PROJECT_DIR$/database.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/database_test.go" beforeDir="false" afterPath="$PROJECT_DIR$/database_test.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/devenv.lock" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/devenv.nix" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/devenv.yaml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/errors.go" beforeDir="false" afterPath="$PROJECT_DIR$/errors.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/event-bus_test.go" beforeDir="false" afterPath="$PROJECT_DIR$/event-bus_test.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/go.mod" beforeDir="false" afterPath="$PROJECT_DIR$/go.mod" afterDir="false" />
<change beforePath="$PROJECT_DIR$/go.sum" beforeDir="false" afterPath="$PROJECT_DIR$/go.sum" afterDir="false" />
<change beforePath="$PROJECT_DIR$/job-generic.go" beforeDir="false" afterPath="$PROJECT_DIR$/job-generic.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/job-syncer.go" beforeDir="false" afterPath="$PROJECT_DIR$/job-syncer.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/job.go" beforeDir="false" afterPath="$PROJECT_DIR$/job.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/logger.go" beforeDir="false" afterPath="$PROJECT_DIR$/logger.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/manager.go" beforeDir="false" afterPath="$PROJECT_DIR$/manager.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/queue.go" beforeDir="false" afterPath="$PROJECT_DIR$/queue.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/runnable-fileoperation.go" beforeDir="false" afterPath="$PROJECT_DIR$/runnable-fileoperation.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/runnable-mail_test.go" beforeDir="false" afterPath="$PROJECT_DIR$/runnable-mail_test.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/runnable-sftp_test.go" beforeDir="false" afterPath="$PROJECT_DIR$/runnable-sftp_test.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/schedule-time.go" beforeDir="false" afterPath="$PROJECT_DIR$/schedule-time.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/scheduler-inotify.go" beforeDir="false" afterPath="$PROJECT_DIR$/scheduler-inotify.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/stat.go" beforeDir="false" afterPath="$PROJECT_DIR$/stat.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/worker.go" beforeDir="false" afterPath="$PROJECT_DIR$/worker.go" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ComposerSettings">
<execution />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Go File" />
</list>
</option>
</component>
<component name="GOROOT" url="file:///nix/store/fqzds43dcw7164rm1h51n54l2ipxi1qj-go-1.21.9/share/go" />
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="PhpWorkspaceProjectConfiguration" interpreter_name="PHP 8.2" />
<component name="ProjectColorInfo"><![CDATA[{
"customColor": "",
"associatedIndex": 8
}]]></component>
<component name="ProjectId" id="2fGcSxoYpsPbNVbRh8sUxQtBiHv" />
<component name="ProjectViewState">
<option name="flattenModules" value="true" />
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
<option name="showVisibilityIcons" value="true" />
<option name="sortByType" value="true" />
<option name="sortKey" value="BY_TYPE" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"DefaultGoTemplateProperty": "Go File",
"Go Test.TestScheduleJob in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug",
"Go Test.TestStructure in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug",
"Go Test.TestTimeFunctionSame in gitlab.schukai.com/oss/libraries/go/services/job-queues.executor": "Debug",
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.go.formatter.settings.were.checked": "true",
"RunOnceActivity.go.migrated.go.modules.settings": "true",
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
"git-widget-placeholder": "master",
"go.import.settings.migrated": "true",
"go.sdk.automatically.set": "true",
"last_opened_file_path": "/home/vs/workspaces/oss/go-libs/job-queues/nix/scripts",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"settings.editor.selected.configurable": "http.proxy",
"vue.rearranger.settings.migration": "true"
}
}]]></component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/nix/scripts" />
<recent name="$PROJECT_DIR$/system/scripts" />
</key>
<key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/.back" />
</key>
</component>
<component name="RunManager" selected="Go Test.TestStructure in gitlab.schukai.com/oss/libraries/go/services/job-queues">
<configuration default="true" type="GoApplicationRunConfiguration" factoryName="Go Application">
<module name="job-queues" />
<working_directory value="$PROJECT_DIR$" />
<go_parameters value="-i" />
<kind />
<directory value="$PROJECT_DIR$" />
<filePath value="$PROJECT_DIR$" />
<method v="2" />
</configuration>
<configuration name="TestScheduleJob in gitlab.schukai.com/oss/libraries/go/services/job-queues" type="GoTestRunConfiguration" factoryName="Go Test" temporary="true" nameIsGenerated="true">
<module name="job-queues" />
<working_directory value="$PROJECT_DIR$" />
<kind value="PACKAGE" />
<package value="gitlab.schukai.com/oss/libraries/go/services/job-queues" />
<directory value="$PROJECT_DIR$" />
<filePath value="$PROJECT_DIR$" />
<framework value="gotest" />
<pattern value="^\QTestScheduleJob\E$" />
<method v="2" />
</configuration>
<configuration name="TestStructure in gitlab.schukai.com/oss/libraries/go/services/job-queues" type="GoTestRunConfiguration" factoryName="Go Test" temporary="true" nameIsGenerated="true">
<module name="job-queues" />
<working_directory value="$PROJECT_DIR$" />
<kind value="PACKAGE" />
<package value="gitlab.schukai.com/oss/libraries/go/services/job-queues" />
<directory value="$PROJECT_DIR$" />
<filePath value="$PROJECT_DIR$" />
<framework value="gotest" />
<pattern value="^\QTestStructure\E$" />
<method v="2" />
</configuration>
<configuration name="TestTimeFunctionSame in gitlab.schukai.com/oss/libraries/go/services/job-queues" type="GoTestRunConfiguration" factoryName="Go Test" temporary="true" nameIsGenerated="true">
<module name="job-queues" />
<working_directory value="$PROJECT_DIR$" />
<kind value="PACKAGE" />
<package value="gitlab.schukai.com/oss/libraries/go/services/job-queues" />
<directory value="$PROJECT_DIR$" />
<filePath value="$PROJECT_DIR$" />
<framework value="gotest" />
<pattern value="^\QTestTimeFunctionSame\E$" />
<method v="2" />
</configuration>
<configuration default="true" type="GoTestRunConfiguration" factoryName="Go Test">
<module name="job-queues" />
<working_directory value="$PROJECT_DIR$" />
<go_parameters value="-i" />
<kind />
<directory value="$PROJECT_DIR$" />
<filePath value="$PROJECT_DIR$" />
<framework value="gotest" />
<method v="2" />
</configuration>
<recent_temporary>
<list>
<item itemvalue="Go Test.TestStructure in gitlab.schukai.com/oss/libraries/go/services/job-queues" />
<item itemvalue="Go Test.TestScheduleJob in gitlab.schukai.com/oss/libraries/go/services/job-queues" />
<item itemvalue="Go Test.TestTimeFunctionSame in gitlab.schukai.com/oss/libraries/go/services/job-queues" />
</list>
</recent_temporary>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="VgoProject">
<settings-migrated>true</settings-migrated>
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/schedule-time.go</url>
<line>61</line>
<option name="timeStamp" value="7" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/schedule-time.go</url>
<line>53</line>
<option name="timeStamp" value="8" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/schedule-time.go</url>
<line>51</line>
<option name="timeStamp" value="9" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
</project>
\ No newline at end of file
......@@ -51,16 +51,12 @@ func main() {
```
## Development
## Tests
Run tests using:
```bash
task test
```
| Command | Description |
|--------------------|--------------------------------------|
| ` task check-code` | Run linters and static code analysis |
| ` task run-tests` | Run tests |
## License
......
......@@ -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,11 @@ 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{})
db, err := gorm.Open(sqlite.Open(":memory:"), &gorm.Config{})
assert.NoError(t, err)
manager := NewManager()
manager.SetDB(db)
......
......@@ -153,7 +153,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
......@@ -206,7 +206,7 @@ func save(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
......
......@@ -42,6 +42,7 @@ 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)
......
This diff is collapsed.
inputs:
nixpkgs:
url: github:nixos/nixpkgs/nixos-23.11
version:
url: git+https://gitlab.schukai.com/oss/utilities/version.git
flake: true
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment