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
......@@ -57,4 +57,9 @@ var (
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,66 +18,62 @@
"type": "github"
}
},
"gitignore": {
"git-commit": {
"inputs": {
"nixpkgs": [
"pre-commit-hooks",
"nixpkgs"
]
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1709087332,
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
"lastModified": 1,
"narHash": "sha256-8hXrOA8SKy//ctoL1poIhJwuT7G4rvVu7FguROzEoDg=",
"path": "./git-commit",
"type": "path"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
"path": "./git-commit",
"type": "path"
}
},
"nixpkgs": {
"gitlab-commit": {
"inputs": {
"git-commit": "git-commit",
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1713145326,
"narHash": "sha256-m7+IWM6mkWOg22EC5kRUFCycXsXLSU7hWmHdmBfmC3s=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "53a2c32bc66f5ae41a28d7a9a49d321172af621e",
"type": "github"
"lastModified": 1704993617,
"narHash": "sha256-++u7I3KCDgP+JhW70k5tiLfBESWVSKdVK7aei0G+mR8=",
"ref": "refs/heads/master",
"rev": "e63b1d6ae5526158fa2a1f4cd53b0ea4f4c93573",
"revCount": 18,
"type": "git",
"url": "https://gitlab.schukai.com/schukai/entwicklung/nix-flakes"
},
"original": {
"owner": "nixos",
"ref": "nixos-23.11",
"repo": "nixpkgs",
"type": "github"
"type": "git",
"url": "https://gitlab.schukai.com/schukai/entwicklung/nix-flakes"
}
},
"nixpkgs-stable": {
"nixpkgs": {
"locked": {
"lastModified": 1710695816,
"narHash": "sha256-3Eh7fhEID17pv9ZxrPwCLfqXnYP006RKzSs0JptsN84=",
"lastModified": 1704874635,
"narHash": "sha256-YWuCrtsty5vVZvu+7BchAxmcYzTMfolSPP5io8+WYCg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "614b4613980a522ba49f0d194531beddbb7220d3",
"rev": "3dc440faeee9e889fe2d1b4d25ad0f430d449356",
"type": "github"
},
"original": {
"owner": "NixOS",
"id": "nixpkgs",
"ref": "nixos-23.11",
"repo": "nixpkgs",
"type": "github"
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1713145326,
"narHash": "sha256-m7+IWM6mkWOg22EC5kRUFCycXsXLSU7hWmHdmBfmC3s=",
"lastModified": 1713344939,
"narHash": "sha256-jpHkAt0sG2/J7ueKnG7VvLLkBYUMQbXQ2L8OBpVG53s=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "53a2c32bc66f5ae41a28d7a9a49d321172af621e",
"rev": "e402c3eb6d88384ca6c52ef1c53e61bdc9b84ddd",
"type": "github"
},
"original": {
......@@ -119,36 +82,27 @@
"type": "indirect"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable"
},
"nixpkgs_3": {
"locked": {
"lastModified": 1712897695,
"narHash": "sha256-nMirxrGteNAl9sWiOhoN5tIHyjBbVi5e2tgZUgZlK3Y=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "40e6053ecb65fcbf12863338a6dcefb3f55f1bf8",
"lastModified": 1713344939,
"narHash": "sha256-jpHkAt0sG2/J7ueKnG7VvLLkBYUMQbXQ2L8OBpVG53s=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "e402c3eb6d88384ca6c52ef1c53e61bdc9b84ddd",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"owner": "nixos",
"ref": "nixos-23.11",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"devenv": "devenv",
"nixpkgs": "nixpkgs",
"pre-commit-hooks": "pre-commit-hooks",
"version": "version"
"flake-utils": "flake-utils",
"gitlab-commit": "gitlab-commit",
"nixpkgs": "nixpkgs_3"
}
},
"systems": {
......@@ -165,24 +119,6 @@
"repo": "default",
"type": "github"
}
},
"version": {
"inputs": {
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1704542622,
"narHash": "sha256-HnFuaOXHoxv8tpBvMsEjfhcl/hFNxEY7GbBqoyJ1U8U=",
"ref": "refs/heads/master",
"rev": "6b4f85fe6d934429cf3055bbcd8cf15014730118",
"revCount": 114,
"type": "git",
"url": "https://gitlab.schukai.com/oss/utilities/version.git"
},
"original": {
"type": "git",
"url": "https://gitlab.schukai.com/oss/utilities/version.git"
}
}
},
"root": "root",
......
{
description = "Development environment";
inputs = {
nixpkgs = {url = "github:nixos/nixpkgs/nixos-23.11";};
flake-utils = {url = "github:numtide/flake-utils";};
gitlab-commit = {url = "git+https://gitlab.schukai.com/schukai/entwicklung/nix-flakes";};
};
outputs = {
self,
nixpkgs,
flake-utils,
gitlab-commit,
}:
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 {};
import-gitlab-commit = gitlab-commit.packages.${system}.git-commit;
# ciJobToken = builtins.getEnv "CI_JOB_TOKEN";
# gitCommit =
# if ciJobToken == ""
# then (builtins.getFlake "git+https://gitlab.schukai.com/schukai/entwicklung/nix-flakes").packages.${builtins.currentSystem}.git-commit
# else "";
in {
devShells = {
default = let
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
import-gitlab-commit
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=
......@@ -56,7 +56,7 @@ func (js *JobSyncer) Wait(timeout time.Duration) error {
}
}
func (js *JobSyncer) Sync(job GenericJob) {
func (js *JobSyncer) Sync(job GenericJob) error {
js.mu.Lock()
defer js.mu.Unlock()
......@@ -70,6 +70,8 @@ func (js *JobSyncer) Sync(job GenericJob) {
}
}()
return nil
}
func (js *JobSyncer) LastError() error {
......
......@@ -119,7 +119,7 @@ func (j *Job[T]) GetPersistence() JobPersistence {
job.Stats.JobID = job.ID
for i, _ := range job.Logs {
for i := range job.Logs {
job.Logs[i].JobID = job.ID
}
......
......@@ -101,7 +101,7 @@ func Trace(msg string, keysAndValues ...interface{}) {
type ZapAdapter struct {
logger *zap.Logger
mu sync.Mutex
// mu sync.Mutex
}
func NewZapAdapter(logger *zap.Logger) *ZapAdapter {
......
......@@ -137,6 +137,11 @@ func (m *Manager) GetActiveJobs() map[JobID]GenericJob {
// DeleteJob removes a job from the active jobs and the database
func (m *Manager) DeleteJob(id JobID) error {
if m == nil {
return ErrManagerNotInitialized
}
m.mu.Lock()
defer m.mu.Unlock()
......@@ -153,36 +158,54 @@ func (m *Manager) DeleteJob(id JobID) error {
}
if m.jobSyncer != nil {
err := m.jobSyncer.DeleteJob(job)
if err != nil {
return err
}
return m.jobSyncer.DeleteJob(job)
}
return nil
}
func (m *Manager) WaitSync() {
func (m *Manager) WaitSync() error {
if m == nil {
return ErrManagerNotInitialized
}
m.mu.Lock()
defer m.mu.Unlock()
if m.jobSyncer != nil {
_ = m.jobSyncer.Wait(2 * time.Second)
return m.jobSyncer.Wait(2 * time.Second)
}
return nil
}
func (m *Manager) Sync(job GenericJob) error {
if m == nil {
return ErrManagerNotInitialized
}
func (m *Manager) Sync(job GenericJob) {
m.mu.Lock()
defer m.mu.Unlock()
if m.jobSyncer != nil {
m.jobSyncer.Sync(job)
return m.jobSyncer.Sync(job)
}
return nil
}
// RemoveJob removes a job from the active jobs
// If you want to remove a job from the active jobs and the database, use DeleteJob instead
func (m *Manager) RemoveJob(id JobID) error {
if m == nil {
return ErrManagerNotInitialized
}
m.mu.Lock()
defer m.mu.Unlock()
......@@ -195,6 +218,11 @@ func (m *Manager) RemoveJob(id JobID) error {
// ResetJobLogs deletes the logs of a job
func (m *Manager) ResetJobLogs(id JobID) error {
if m == nil {
return ErrManagerNotInitialized
}
m.mu.Lock()
defer m.mu.Unlock()
......@@ -215,6 +243,11 @@ func (m *Manager) ResetJobLogs(id JobID) error {
// ResetJobStats deletes the stats of a job
func (m *Manager) ResetJobStats(id JobID) error {
if m == nil {
return ErrManagerNotInitialized
}
m.mu.Lock()
defer m.mu.Unlock()
......@@ -250,6 +283,10 @@ func cancelSchedulerByManager(scheduler CancelScheduler, id JobID) error {
func (m *Manager) removeJobInternal(id JobID) error {
if m == nil {
return ErrManagerNotInitialized
}
scheduler := m.activeJobs[id].GetScheduler()
if scheduler == nil {
return ErrJobNotScheduled
......@@ -270,6 +307,11 @@ func (m *Manager) removeJobInternal(id JobID) error {
}
func (m *Manager) UpdateJob(job GenericJob) error {
if m == nil {
return ErrManagerNotInitialized
}
m.mu.Lock()
defer m.mu.Unlock()
......@@ -318,6 +360,10 @@ func (m *Manager) GetDB() *gorm.DB {
// GetQueue returns the queue
func (m *Manager) checkAndSetRunningState() error {
if m == nil {
return ErrManagerNotInitialized
}
m.state = ManagerStateStopped
if m.workerMap == nil {
......@@ -340,6 +386,11 @@ func (m *Manager) checkAndSetRunningState() error {
// AddWorker adds a worker to the manager
func (m *Manager) AddWorker(worker Worker) error {
if m == nil {
return ErrManagerNotInitialized
}
m.mu.Lock()
defer m.mu.Unlock()
......@@ -369,6 +420,11 @@ func (m *Manager) AddWorker(worker Worker) error {
// RemoveWorker removes a worker from the manager
func (m *Manager) RemoveWorker(worker Worker) error {
if m == nil {
return ErrManagerNotInitialized
}
m.mu.Lock()
defer m.mu.Unlock()
......@@ -400,6 +456,10 @@ func (m *Manager) RemoveWorker(worker Worker) error {
// Start starts the manager
func (m *Manager) Start() error {
if m == nil {
return ErrManagerNotInitialized
}
m.mu.Lock()
defer m.mu.Unlock()
......@@ -575,7 +635,7 @@ func (m *Manager) ScheduleJob(job GenericJob, scheduler Scheduler) error {
m.activeJobs[job.GetID()] = job
if m.jobSyncer != nil {
m.jobSyncer.Sync(job)
return m.jobSyncer.Sync(job)
}
return nil
......@@ -656,7 +716,7 @@ func (m *Manager) handleJobEvents() {
}
}
if assigned == true {
if assigned {
break
}
......
{ pkgs, lib, ... }:
let
common = pkgs.callPackage ./common.nix {};
# Definieren eines schreibbaren Verzeichnisses
writableDir = pkgs.stdenv.mkDerivation {
name = "cover-report";
buildCommand = ''
mkdir -p $out
'';
};
in
pkgs.writeShellScriptBin "build-cover-report" ''
${common}
echo_header "Building cover report"
download_test_images
setup_go_env
echo_section "Building"
${pkgs.go}/bin/go test -v -coverprofile=${writableDir}/coverage.out ./...
if [ $? -ne 0 ];
then
echo_fail "Failed to run tests"
exit 1
fi
if ! ${pkgs.go}/bin/go tool cover -html=${writableDir}/coverage.out -o ${writableDir}/coverage.html
then
echo_fail "Failed to generate coverage report"
exit 1
fi
echo_ok "Coverage report stored at ${writableDir}"
echo_step "Opening coverage report in browser"
if ! ${pkgs.xdg-utils}/bin/xdg-open ${writableDir}/coverage.html > /dev/null 2>&1
then
echo_fail "Failed to open coverage report in browser"
exit 1
fi
echo_ok "Report opened in browser"
''
{
pkgs,
lib,
...
}: let
common = pkgs.callPackage ./common.nix {};
in
pkgs.writeShellScriptBin "check-code" ''
${common}
echo_header "Checking code"
cd_working_dir
echo_step "Running go vet"
if ! ${pkgs.go}/bin/go vet .
then
echo_fail "go vet failed"
exit 1
fi
echo_step "Running go fmt"
if ! ${pkgs.go}/bin/go fmt .
then
echo_fail "go fmt failed"
exit 1
fi
echo_step "Running go mod tidy"
if ! ${pkgs.go}/bin/go mod tidy
then
echo_fail "go mod tidy failed"
exit 1
fi
echo_step "Running lint"
if ! ${pkgs.golangci-lint}/bin/golangci-lint run .
then
echo_fail "lint failed"
exit 1
fi
echo_step "Running gosec"
if ! ${pkgs.gosec}/bin/gosec .
then
echo_fail "gosec failed"
exit 1
fi
''
{pkgs, ...}: ''
if [ -t 1 ]; then
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
RESET='\033[0m'
BOLD='\033[1m'
else
RED=""
GREEN=""
BLUE=""
RESET=""
fi
## this function is used to change the working directory to the one specified in
## the USER_WORKING_DIR environment variable. this is necessary if you want to edit
## files in the repository.
cd_working_dir() {
working_dir=$(echo $USER_WORKING_DIR)
if [ -z "$working_dir" ]; then
echo_fail "USER_WORKING_DIR is not set"
echo_hint "Please set the USER_WORKING_DIR environment variable"
exit 1
fi
if [ ! -d "$working_dir" ]; then
echo_fail "USER_WORKING_DIR does not exist"
echo_hint "Please set the USER_WORKING_DIR environment variable to a valid directory"
exit 1
fi
cd $working_dir
git_root=$(git rev-parse --show-toplevel)
if [ -z "$git_root" ]; then
echo_fail "Not a git repository"
echo_hint "Please run this script in a git repository"
exit 1
fi
cd $git_root
echo_ok "Changed directory to $working_dir"
}
is_true() {
val="$1"
if [ "$val" = 'true' ] || [ "$val" = '1' ]; then
return 0
else
return 1
fi
}
echo_header() {
${pkgs.figlet}/bin/figlet -t -f doom -l "$1"
}
echo_ok() {
echo -e "$GREEN✔$RESET $1"
}
echo_delimiter() {
echo " "
}
echo_section() {
echo -e "\n\n$BOLD$1$RESET"
}
echo_text() {
echo -e "$1"
}
echo_fail() {
echo -e "$RED✖ $1$RESET"
}
echo_hint() {
echo -e "$BLUE→ $1$RESET"
}
echo_step() {
echo -e "$BLUE•$RESET $1"
}
convert_multiline_for_nix() {
printf "%s" "
}$1" | ${pkgs.gnused}/bin/sed 's/\\/\\\\/g; s/"/\\"/g; s/$/\\n/g' | tr -d '\n'
}
if [ -z "$DEBUG_MODE" ]; then
DEBUG_MODE='false'
fi
if [ -n "$CI_JOB_TOKEN" ]; then
CI_MODE='true'
fi
if is_true "$DEBUG_MODE" || is_true "$CI_MODE"; then
set -x
fi
download_test_images() {
echo_step "Downloading docker images"
if ! ${pkgs.docker}/bin/docker images | grep atmoz/sftp | grep alpine
then
echo_step "Downloading atmoz/sftp:alpine"
if ! ${pkgs.docker}/bin/docker pull atmoz/sftp:alpine
then
echo_fail "Failed to download atmoz/sftp:alpine"
exit 1
fi
fi
if ! ${pkgs.docker}/bin/docker images | grep axllent/mailpit
then
echo_step "Downloading atmoz/sftp:alpine"
if ! ${pkgs.docker}/bin/docker pull axllent/mailpit
then
echo_fail "Failed to download axllent/mailpit"
exit 1
fi
fi
}
setup_go_env() {
echo_step "Changing directory to ${../..}"
cd ${../..}
echo_step "Setting GO111MODULE=auto"
if ! ${pkgs.go}/bin/go env -w GO111MODULE=auto
then
echo_fail "Failed to set GO111MODULE=auto"
exit 1
fi
}
''
{
pkgs,
}: let
taskfile = builtins.toFile "taskfile.yml" ''
version: '3'
tasks:
default:
cmds:
- task --list
silent: true
run-tests:
desc: Execute all tests.
env:
TEST_BY_TASK: true
cmds:
- run-tests
run-extended-tests:
desc: Execute all tests including cover, bench and race tests.
env:
TEST_BY_TASK: true
cmds:
- run-extended-tests
build-cover-report:
desc: Build coverage report.
aliases:
- cr
env:
TEST_BY_TASK: true
cmds:
- build-cover-report
check-code:
desc: Check code style, linting, and formatting.
env:
USER_WORKING_DIR: "{{.USER_WORKING_DIR}}"
cmds:
- check-code
'';
in
pkgs.writeShellScriptBin "task" ''
${pkgs.go-task}/bin/task -t "${taskfile}" "$@"
''
{
pkgs,
lib,
...
}: let
common = pkgs.callPackage ./common.nix {};
in
pkgs.writeShellScriptBin "run-ci-tests" ''
${common}
echo_header "Running CI tests"
download_test_images
setup_go_env
echo_section "Running tests"
if ! ${pkgs.go}/bin/go test -tags "runOnTask" -cover ./...
then
echo_fail "Failed to run tests"
exit 1
fi
echo_section "Running tests"
if ! ${pkgs.go}/bin/go test -tags "runOnTask,bench" -bench ./...
then
echo_fail "Failed to run benchmarks"
exit 1
fi
echo_section "Running tests"
if ! ${pkgs.go}/bin/go test -tags "runOnTask,race" -race ./...
then
echo_fail "Failed to run race tests"
exit 1
fi
''
{
pkgs,
lib,
...
}: let
common = pkgs.callPackage ./common.nix {};
in
pkgs.writeShellScriptBin "run-extended-tests" ''
${common}
echo_header "Running tests"
echo_step "Downloading docker images"
download_test_images
setup_go_env
echo_section "Running tests"
if ! ${pkgs.go}/bin/go test -tags "runOnTask" -cover ./...
then
echo_fail "Failed to run tests"
exit 1
fi
echo_section "Running tests"
if ! ${pkgs.go}/bin/go test -tags "runOnTask,bench" -bench ./...
then
echo_fail "Failed to run benchmarks"
exit 1
fi
echo_section "Running tests"
if ! ${pkgs.go}/bin/go test -tags "runOnTask,race" -race ./...
then
echo_fail "Failed to run race tests"
exit 1
fi
''
{
pkgs,
lib,
...
}: let
common = pkgs.callPackage ./common.nix {};
in
pkgs.writeShellScriptBin "run-tests" ''
${common}
echo_header "Running tests"
selection=$(${pkgs.gum}/bin/gum choose "run specific test" "run all tests" "Cancel")
if [[ "$selection" == "Cancel" ]]; then
echo_ok "Exiting."
exit 0
fi
download_test_images
setup_go_env
if [[ "$selection" == "run all tests" ]]; then
echo_ok "Running all tests"
if ! ${pkgs.go}/bin/go test -v -failfast ./...
then
echo_fail "ERROR: Tests failed, check your Go!"
exit 1
fi
echo_ok "All tests passed!"
exit 0
fi
test_files=$(${pkgs.findutils}/bin/find . -name "*_test.go")
test_names=""
for file in $test_files; do
names=$(${pkgs.gnugrep}/bin/grep -oP 'func (Test\w+)' $file | ${pkgs.gawk}/bin/gawk '{print $2}')
test_names+="$names "
done
if [[ -z "$test_names" ]]; then
echo_fail "No tests found!"
exit 1
fi
selected_tests=$(echo "$test_names" | ${pkgs.coreutils}/bin/tr ' ' '\n' | ${pkgs.gum}/bin/gum filter --no-limit )
if [[ -z "$selected_tests" ]]; then
echo_ok "No tests selected, exiting."
exit 0
fi
if ! ${pkgs.go}/bin/go test -run "$(echo $selected_tests | tr '\n' "")"
then
echo_fail "ERROR: Tests failed, check your Go!"
exit 1
fi
echo_ok "All tests passed!"
''
......@@ -86,9 +86,7 @@ func (q *Queue) Enqueue(job GenericJob) error {
// Run topological sort on jobs in the ready queue
readyJobList := []GenericJob{}
for _, readyJob := range q.readyQueue {
readyJobList = append(readyJobList, readyJob)
}
readyJobList = append(readyJobList, q.readyQueue...)
currentReadyJobIDs := make(map[JobID]struct{})
for _, job := range readyJobList {
......@@ -96,9 +94,7 @@ func (q *Queue) Enqueue(job GenericJob) error {
}
var fullJobList []GenericJob
for _, job := range readyJobList {
fullJobList = append(fullJobList, job)
}
fullJobList = append(fullJobList, readyJobList...)
for i := range q.processedJobs {
id := q.processedJobs[i].ID
......@@ -154,7 +150,7 @@ func (q *Queue) ClearProcessedJobs() {
}
}
func (q *Queue) isDependency(id JobID) bool {
func (q *Queue) IsDependency(id JobID) bool {
for _, deps := range q.pendingDependencies {
for _, depID := range deps {
if depID == id {
......
......@@ -43,7 +43,7 @@ func (f *FileOperationResult) GetResult() string {
}
func (f *FileOperationResult) GetError() (string, int) {
if f.Success == false {
if !f.Success {
return "FileOperationResult failed", 1
}
return "", 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment