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

Target

Select target project
  • oss/libraries/go/services/job-queues
1 result
Select Git revision
Show changes
Showing
with 696 additions and 159 deletions
module gitlab.schukai.com/oss/libraries/go/services/job-queues
module gitlab.schukai.com/oss/libraries/go/services/job-queues.git
go 1.22
require (
filippo.io/edwards25519 v1.1.0
github.com/DATA-DOG/go-sqlmock v1.5.0
github.com/docker/docker v24.0.6+incompatible
github.com/docker/go-connections v0.4.0
......@@ -13,16 +14,15 @@ require (
github.com/shirou/gopsutil/v3 v3.24.5
github.com/stretchr/testify v1.9.0
go.uber.org/zap v1.27.0
golang.org/x/crypto v0.26.0
golang.org/x/crypto v0.27.0
gopkg.in/yaml.v3 v3.0.1
gorm.io/driver/mysql v1.5.7
gorm.io/driver/sqlite v1.5.5
gorm.io/gorm v1.25.11
gorm.io/gorm v1.25.12
gotest.tools/v3 v3.5.1
)
require (
filippo.io/edwards25519 v1.1.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/distribution/reference v0.5.0 // indirect
......@@ -35,7 +35,7 @@ require (
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/kr/fs v0.1.0 // indirect
github.com/lufia/plan9stats v0.0.0-20240819163618-b1d8f4d146e7 // indirect
github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683 // indirect
github.com/mattn/go-sqlite3 v1.14.17 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/morikuni/aec v1.0.0 // indirect
......@@ -52,8 +52,8 @@ require (
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/text v0.18.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
)
......@@ -41,8 +41,8 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kr/fs v0.1.0 h1:Jskdu9ieNAYnjxsi0LbQp1ulIKZV1LAFgK1tWhpZgl8=
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
github.com/lufia/plan9stats v0.0.0-20240819163618-b1d8f4d146e7 h1:5RK988zAqB3/AN3opGfRpoQgAVqr6/A5+qRTi67VUZY=
github.com/lufia/plan9stats v0.0.0-20240819163618-b1d8f4d146e7/go.mod h1:ilwx/Dta8jXAgpFYFvSWEMwxmbWXyiUHkd5FwyKhb5k=
github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683 h1:7UMa6KCCMjZEMDtTVdcGu0B1GmmC7QJKiCCjyTAWQy0=
github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683/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=
......@@ -95,8 +95,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
......@@ -127,19 +127,19 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
golang.org/x/sys v0.25.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.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU=
golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk=
golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
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/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
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=
......@@ -163,7 +163,7 @@ gorm.io/driver/mysql v1.5.7/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.11 h1:/Wfyg1B/je1hnDx3sMkX+gAlxrlZpn6X0BXRlwXlvHg=
gorm.io/gorm v1.25.11/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ=
gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8=
gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ=
gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU=
gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU=
......@@ -746,12 +746,10 @@ func (m *Manager) handleJobEvents() {
} else {
eventBus := m.GetEventBus()
eventBus.Publish(JobDone, nextJob)
if nextJob.GetScheduler() != nil {
if nextJob.GetScheduler().IsAdHoc() {
eventBus.Publish(JobFinished, nextJob)
//eventBus := m.GetEventBus()
//eventBus.Publish(JobFinished, nextJob)
}
}
}
......
{pkgs'}:
with pkgs'; let
php = pkgs.php83.buildEnv {
extensions = {
enabled,
all,
}:
enabled ++ (with all; [memcached xdebug]);
};
in [
alejandra
blackbox
coreutils-full
curl
d2
dbeaver-bin
delve
dialog
dive
drill
eza
fd
feh
gcc12
gdlv
git
gitty
glab
gnugrep
gnumake
gnused
go
go-licenses
go-migrate
golangci-lint
google-fonts
gosec
graphviz
grpc
gum
httpie
hurl
jq
libffi
logrotate
mdbook
mdbook-admonish
mdbook-cmdrun
mdbook-d2
mdbook-emojicodes
mdbook-graphviz
mdbook-linkcheck
mdbook-mermaid
mdbook-pdf
mdbook-plantuml
meld
memcached
netcat
nghttp2
nodePackages.mermaid-cli
openssh
pandoc-katex
plantuml
procps
ranger
roboto
unixtools.xxd
unzip
util-linux
vhs
wget
zlib
]
{
}
{
# this file is generated by nix/scripts/init-project.nix
# please don't edit it manually
version = "1.19.4";
commit = "deb4cad6cd14bb73447a9e6afd1bd19049baacd1";
projectURL = "https://gitlab.schukai.com/oss/libraries/go/services/job-queues";
name = "job-queues";
mnemonic = "job-queues";
projectID = "335";
# this file is generated by nix/scripts/init-project.nix
# please don't edit it manually
}
{
# this file is generated by nix/scripts/init-project.nix
# please don't edit it manually
version = "$VERSION";
commit = "$COMMIT";
projectURL = "https://gitlab.schukai.com/oss/libraries/go/services/job-queues";
name = "job-queues";
mnemonic = "job-queues";
projectID = "335";
# this file is generated by nix/scripts/init-project.nix
# please don't edit it manually
}
{
pkgs',
system,
self,
...
}: let
releaseInfo = import ../config/release.nix;
in
derivation {
name = "manual";
version = releaseInfo.version;
builder = "${pkgs'.bash}/bin/bash";
args = let
script = pkgs'.callPackage ../scripts/build-manual.nix {inherit pkgs' system;};
in ["${script}/bin/build-manual"];
buildInputs = with pkgs'; [];
system = system;
}
{pkgs', ...}: ''
convert_multiline_for_nix() {
printf "%s" "
}$1" | ${pkgs'.gnused}/bin/sed 's/\\/\\\\/g; s/"/\\"/g; s/$/\\n/g' | tr -d '\n'
}
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 "Setting GO111MODULE=auto"
if ! ${pkgs'.go}/bin/go env -w GO111MODULE=auto
then
echo_fail "Failed to set GO111MODULE=auto"
exit 1
fi
}
''
{
pkgs,
lib,
...
}: let
common = pkgs.callPackage ./common.nix {};
# Definieren eines schreibbaren Verzeichnisses
writableDir = pkgs.stdenv.mkDerivation {
name = "cover-report";
buildCommand = ''
mkdir -p $out
'';
{pkgs', ...}: let
bashFktScript = import ./bash-fkt.nix {
inherit pkgs';
};
in
pkgs.writeShellScriptBin "build-cover-report" ''
${common}
pkgs'.writeShellScriptBin "build-cover-report" ''
source ${pkgs'.common}/bin/common
${bashFktScript}
echo_header "Building cover report"
download_test_images
echo_hint "The command is executed in the current working directory and not in a nix derivation."
cd_working_dir
setup_go_env
download_test_images
if [ -z "''${out}" ];
then
echo_fail "No out directory specified"
exit 1
fi
writableDir="''${out}/coverage"
if ! ${pkgs'.coreutils}/bin/mkdir -p ''${writableDir} > /dev/null 2>&1
then
write_fail "Failed to create directory ''${writableDir}"
exit 1
fi
echo_step "Running tests"
echo_section "Building"
${pkgs.go}/bin/go test -v -coverprofile=${writableDir}/coverage.out ./...
${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
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_ok "Coverage report stored at ''${writableDir}"
if [ -f ''${writableDir}/coverage.html ];
then
echo_fail "Coverage report not found"
exit 1
fi
echo_step "Opening coverage report in browser"
if ! ${pkgs.xdg-utils}/bin/xdg-open ${writableDir}/coverage.html > /dev/null 2>&1
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
......
{pkgs', ...}: let
bashFktScript = import ./bash-fkt.nix {
inherit pkgs';
};
updateSummary = pkgs'.callPackage ./update-manual-summary.nix {inherit pkgs';};
in
pkgs'.writeShellScriptBin "build-manual" ''
source ${pkgs'.common}/bin/common
source ${bashFktScript}
${updateSummary}
${pkgs'.coreutils}/bin/mkdir -p $out/manual/de
cd ${../../documentation/manual/de}
${pkgs'.mdbook}/bin/mdbook build --dest-dir $out/manual .
''
{
pkgs,
lib,
...
}: let
common = pkgs.callPackage ./common.nix {};
in
{pkgs, ...}:
pkgs.writeShellScriptBin "clean-up" ''
${common}
echo_header "Cleaning up"
echo "Cleaning up"
echo_step "Removing credentials"
echo "Removing credentials"
${pkgs.git}/bin/git config --global --unset credential.helper
if [ -f /root/.docker/config.json ]; then rm /root/.docker/config.json; fi
if [ -f /root/.docker/config.json ]; then ${pkgs.coreutils}/bin/rm /root/.docker/config.json; fi
if [ -f .env-gitlab-ci ]; then ${pkgs.coreutils}/bin/rm .env-gitlab-ci; fi
echo_ok "Cleaned up"
echo "Cleaned up"
''
{pkgs}: let
taskfile = pkgs.writeTextFile {
{
pkgs',
system,
self,
...
}: let
scriptBuildCoverReport = pkgs'.callPackage ./build-cover-report.nix {pkgs' = pkgs';};
scriptRunTests = pkgs'.callPackage ./run-tests.nix {pkgs' = pkgs';};
scriptRunExtendedTests = pkgs'.callPackage ./run-extended-tests.nix {pkgs' = pkgs';};
scriptUpdateProject = pkgs'.callPackage ./update-project.nix {pkgs' = pkgs';};
scriptUpdateChangelog = pkgs'.callPackage ./update-changelog.nix {pkgs' = pkgs';};
taskfile = pkgs'.writeTextFile {
name = "taskfile.yml";
text = ''
version: '3'
......@@ -9,62 +20,102 @@
cmds:
- task --list
silent: true
run-tests:
desc: Execute all tests.
aliases:
- rt
- a
env:
TEST_BY_TASK: true
USER_WORKING_DIR: "{{.USER_WORKING_DIR}}"
cmds:
- run-tests
- ${scriptRunTests}/bin/run-tests
silent: true
run-extended-tests:
desc: Execute all tests including cover, bench and race tests.
aliases:
- ret
- s
env:
TEST_BY_TASK: true
USER_WORKING_DIR: "{{.USER_WORKING_DIR}}"
cmds:
- run-extended-tests
- ${scriptRunExtendedTests}/bin/run-extended-tests
silent: true
build-cover-report:
desc: Build coverage report.
aliases:
- cr
- d
env:
TEST_BY_TASK: true
USER_WORKING_DIR: "{{.USER_WORKING_DIR}}"
cmds:
- build-cover-report
- ${scriptBuildCoverReport}/bin/build-cover-report
silent: true
check-code:
update-project:
desc: Check code style, linting, and formatting.
aliases:
- cc
- e
env:
USER_WORKING_DIR: "{{.USER_WORKING_DIR}}"
cmds:
- check-code
- ${scriptUpdateProject}/bin/update-project
silent: true
git-commit:
desc: Commit changes.
aliases:
- gc
- commit
- f
cmds:
- check-code
- cd "{{.USER_WORKING_DIR}}" && cd $(${pkgs.git}/bin/git rev-parse --show-toplevel) && nix run git+https://gitlab.schukai.com/schukai/entwicklung/nix-flakes#git-commit --no-write-lock-file
- ${scriptUpdateProject}/bin/update-project
- cd "{{.USER_WORKING_DIR}}" && cd $(${pkgs'.git}/bin/git rev-parse --show-toplevel) && nix run git+https://gitlab.schukai.com/schukai/entwicklung/nix-flakes#git-commit --no-write-lock-file
silent: true
env:
USER_WORKING_DIR: "{{.USER_WORKING_DIR}}"
build-manual:
aliases:
- g
desc: Build the manual
cmds:
- cd "{{.USER_WORKING_DIR}}" && cd $(${pkgs'.git}/bin/git rev-parse --show-toplevel) && ${pkgs'.nix}/bin/nix build .#manual --no-write-lock-file
silent: true
watch-doc:
aliases:
- l
desc: Build and watch the documentation (http://localhost:3000)
cmds:
- cd "{{.USER_WORKING_DIR}}" && cd $(${pkgs'.git}/bin/git rev-parse --show-toplevel) && ${pkgs'.mdbook}/bin/mdbook serve documentation/manual/de
silent: true
update-changelog:
aliases:
- j
desc: Update the changelog
cmds:
- ${scriptUpdateChangelog}/bin/update-changelog
silent: true
env:
USER_WORKING_DIR: "{{.USER_WORKING_DIR}}"
tool-dbeaver:
aliases:
- k
- dbeaver
desc: Open DBeaver
cmds:
- cd "{{.USER_WORKING_DIR}}" && cd $(${pkgs'.git}/bin/git rev-parse --show-toplevel) && ${pkgs'.dbeaver-bin}/bin/dbeaver -data .temp/dbeaver -con "driver=mysql|host=localhost|port=3306|user=root|password=secret" 2>&1 > /dev/null
silent: true
env:
USER_WORKING_DIR: "{{.USER_WORKING_DIR}}"
'';
};
in
pkgs.writeShellScriptBin "task" ''
${pkgs.go-task}/bin/task -t "${taskfile}" "$@"
pkgs'.writeShellScriptBin "task" ''
${pkgs'.go-task}/bin/task -t "${taskfile}" "$@"
''
{pkgs', ...}: let
bashFktScript = import ./bash-fkt.nix {
inherit pkgs';
};
updateChangelogScript = import ./update-changelog.nix {
inherit pkgs';
};
in
pkgs'.writeShellScriptBin "release" ''
source ${pkgs'.common}/bin/common
${bashFktScript}
echo_header "Release "
if [ -z "$CI_REPOSITORY_URL" ]; then
echo_fail "Error: CI_REPOSITORY_URL environment variable is not set."
exit 1
fi
if [ -z "$CI_PROJECT_DIR" ]; then
echo_fail "Error: CI_PROJECT_DIR environment variable is not set."
exit 1
fi
cd $CI_PROJECT_DIR || exit 1
${pkgs'.git}/bin/git remote set-url origin https://''${CI_REPOSITORY_URL#*@}
${pkgs'.git}/bin/git fetch --all --tags --unshallow
${pkgs'.git}/bin/git reset --hard origin/master
${pkgs'.git}/bin/git clean -fd
${pkgs'.git}/bin/git checkout $CI_COMMIT_REF_NAME
${pkgs'.git}/bin/git pull origin $CI_COMMIT_REF_NAME
if ! ${pkgs'.git}/bin/git --no-pager log --decorate=short --pretty=oneline -n 30
then
echo_fail "Error: Could not get git log."
exit 1
fi
${pkgs'.git}/bin/git fetch --prune --prune-tags
echo_step "Bumping version"
gitVersion=$(${pkgs'.version}/bin/version predict --exit-code-if-no-bump)
if [ -z "$gitVersion" ]; then
echo_ok "There is no version bump."
echo_ok "done"
exit 0
fi
gitVersion=v$gitVersion
echo_step "Write project version"
export VERSION=$gitVersion
export COMMIT="$CI_COMMIT_SHA"
export NAME=$(basename $(pwd) | sed 's/./\U&/' | sed 's/-//g')
export MNEMONIC=$(echo $NAME | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]//g')
${pkgs'.envsubst}/bin/envsubst < ./nix/config/release.nix.template > ./nix/config/release.nix
${pkgs'.git}/bin/git tag -a $gitVersion -m"chore: bump version to $gitVersion"
${updateChangelogScript}/bin/update-changelog
cd $CI_PROJECT_DIR || exit 1
${pkgs'.git}/bin/git tag -d "$gitVersion"
${pkgs'.git}/bin/git commit -m "chore: release $gitVersion" CHANGELOG.md ./nix/config/release.nix
${pkgs'.git}/bin/git tag -a $gitVersion -m"chore: bump version to $gitVersion"
${pkgs'.git}/bin/git --no-pager log --decorate=short --pretty=oneline -n 5
${pkgs'.git}/bin/git remote set-url origin https://pad:''${GITLAB_TOKEN}@''${CI_REPOSITORY_URL#*@}
${pkgs'.git}/bin/git push -o ci.skip origin "$CI_COMMIT_REF_NAME" --tags
echo_ok "done"
''
{
pkgs,
lib,
...
}: let
common = pkgs.callPackage ./common.nix {};
{pkgs', ...}: let
bashFktScript = import ./bash-fkt.nix {
inherit pkgs';
};
in
pkgs.writeShellScriptBin "run-ci-tests" ''
pkgs'.writeShellScriptBin "run-ci-tests" ''
${common}
source ${pkgs'.common}/bin/common
${bashFktScript}
echo_header "Running CI tests"
download_test_images
setup_go_env
if [[ -f "assets/test.env" ]]; then
echo_hint "Loading test environment variables"
set -a
source "assets/test.env"
set +a
fi
echo_section "Running tests"
if ! ${pkgs.go}/bin/go test -tags "runOnTask" ./...
cd ${./../..} || (echo_fail "Failed to cd to application source" && exit 1)
if ! CGO_CFLAGS="-Wno-format-security" ${pkgs'.go}/bin/go test -tags "runOnTask" ./...
then
echo_fail "Failed to run tests"
exit 1
fi
''
{
pkgs,
lib,
...
}: let
common = pkgs.callPackage ./common.nix {};
{pkgs', ...}: let
bashFktScript = import ./bash-fkt.nix {
inherit pkgs';
};
in
pkgs.writeShellScriptBin "run-extended-tests" ''
pkgs'.writeShellScriptBin "run-extended-tests" ''
${common}
source ${pkgs'.common}/bin/common
${bashFktScript}
echo_header "Running extended tests"
echo_hint "The command is executed in the current working directory and not in a nix derivation."
cd_working_dir
download_test_images
setup_go_env
cd_working_dir
echo_step "Running tests"
if ! ${pkgs.go}/bin/go test -tags "runOnTask" -cover ./...
if ! ${pkgs'.go}/bin/go test -tags "runOnTask" -cover ./...
then
echo_fail "Failed to run tests"
exit 1
......@@ -24,7 +23,7 @@ in
echo_ok "All tests passed"
echo_step "Running benchmarks"
if ! ${pkgs.go}/bin/go test -tags "runOnTask,bench" -bench ./...
if ! ${pkgs'.go}/bin/go test -tags "runOnTask,bench" -bench ./...
then
echo_fail "Failed to run benchmarks"
exit 1
......@@ -32,7 +31,7 @@ in
echo_ok "Benchmarks passed"
echo_step "Running race tests"
if ! ${pkgs.go}/bin/go test -tags "runOnTask,race" -race ./...
if ! ${pkgs'.go}/bin/go test -tags "runOnTask,race" -race ./...
then
echo_fail "Failed to run race tests"
exit 1
......@@ -40,7 +39,7 @@ in
echo_ok "race tests passed"
echo_step "Running fuzz tests"
if ! ${pkgs.go}/bin/go test -tags "runOnTask,fuzz" -fuzz ./...
if ! ${pkgs'.go}/bin/go test -tags "runOnTask,fuzz" -fuzz ./...
then
echo_fail "Failed to run fuzz tests"
exit 1
......
{
pkgs,
lib,
...
}: let
common = pkgs.callPackage ./common.nix {};
{pkgs', ...}: let
bashFktScript = import ./bash-fkt.nix {
inherit pkgs';
};
in
pkgs.writeShellScriptBin "run-tests" ''
pkgs'.writeShellScriptBin "run-tests" ''
${common}
source ${pkgs'.common}/bin/common
${bashFktScript}
echo_header "Running tests"
echo_hint "The command is executed in the current working directory and not in a nix derivation."
cd_working_dir
setup_go_env
selection=$(${pkgs.gum}/bin/gum choose "run all tests" "run specific test" "Cancel")
echo_section "Select test to run"
selection=$(${pkgs'.gum}/bin/gum choose "run all tests" "run specific test" "Cancel")
if [[ "$selection" == "Cancel" ]]; then
echo_ok "Exiting."
exit 0
fi
download_test_images
setup_go_env
cd_working_dir
if [[ -f "assets/test.env" ]]; then
echo_hint "Loading test environment variables"
set -a
source "assets/test.env"
set +a
fi
if [[ "$selection" == "run all tests" ]]; then
echo_ok "Running all tests"
if ! ${pkgs.go}/bin/go test -tags runOnTask -v -failfast ./...
if ! CGO_CFLAGS="-Wno-format-security" ${pkgs'.go}/bin/go test -tags runOnTask -v -failfast ./...
then
echo_fail "ERROR: Tests failed, check your Go!"
exit 1
......@@ -33,11 +40,11 @@ in
exit 0
fi
test_files=$(${pkgs.findutils}/bin/find . -name "*_test.go")
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}')
names=$(${pkgs'.gnugrep}/bin/grep -oP 'func (Test\w+)' $file | ${pkgs'.gawk}/bin/gawk '{print $2}')
test_names+="$names "
done
......@@ -46,14 +53,14 @@ in
exit 1
fi
selected_tests=$(echo "$test_names" | ${pkgs.coreutils}/bin/tr ' ' '\n' | ${pkgs.gum}/bin/gum filter --no-limit )
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 -tags runOnTask -run "$(echo $selected_tests)"
if ! CGO_CFLAGS="-Wno-format-security" ${pkgs'.go}/bin/go test -tags runOnTask -run "$(echo $selected_tests)"
then
echo_fail "ERROR: Tests failed, check your Go!"
exit 1
......
{pkgs', ...}: let
bashFktScript = import ./bash-fkt.nix {
inherit pkgs';
};
in
pkgs'.writeShellScriptBin "update-changelog" ''
source ${pkgs'.common}/bin/common
${bashFktScript}
echo_section "Update Changelog"
echo_hint "This script will update the changelog."
echo_hint "The command is executed in the current working directory and not in a nix derivation."
cd_working_dir
echo_step "Updating changelog"
CHANGELOG_PATH="./CHANGELOG.md"
latestDocumentedVersion=$(${pkgs'.gnugrep}/bin/grep '## \[' $CHANGELOG_PATH | sed -E 's/## \[([0-9]+\.[0-9]+\.[0-9]+).*/\1/' | head -1)
if [ -z "$latestDocumentedVersion" ]; then
echo_fail "Could not find latest documented version in changelog"
echo_hint "Please add a version entry in the file $CHANGELOG_PATH"
exit 1
fi
currentVersion=$(${pkgs'.version}/bin/version print -g)
if [ "$latestDocumentedVersion" = "$currentVersion" ]; then
echo_ok "changelog already up to date"
else
tags=$(${pkgs'.git}/bin/git tag --sort=creatordate)
tags_array=($tags)
position=$(${pkgs'.coreutils}/bin/printf "%s\n" "''${tags_array[@]}" | ${pkgs'.gnugrep}/bin/grep -n "^$latestDocumentedVersion$" | ${pkgs'.coreutils}/bin/cut -d: -f1)
if [ -z "$position" ]; then
echo_fail "Could not find latest documented version in git tags"
echo_hint "Please check the git tags"
exit 1
fi
next_position=$((position + 1))
if [ $next_position -le ''${#tags_array[@]} ]; then
next_tag=''${tags_array[''$next_position - 1]}
else
echo_fail "Could not find next tag"
echo_hint "Please check the git tags"
exit 1
fi
echo_step "Generating changelog"
tmpChangelog=$(${pkgs'.mktemp}/bin/mktemp)
if ! ${pkgs'.git-chglog}/bin/git-chglog --config ./.config/chglog/config.yml -o $tmpChangelog $next_tag..
then
echo_fail "git-chglog failed"
${pkgs'.coreutils}/bin/rm $tmpChangelog
exit 1
fi
newChanges=$(${pkgs'.coreutils}/bin/cat $tmpChangelog)
${pkgs'.coreutils}/bin/rm $tmpChangelog
if [ -n "$newChanges" ]; then
${pkgs'.gnused}/bin/sed -i '/^# Changelog/d' $CHANGELOG_PATH
${pkgs'.coreutils}/bin/mv $CHANGELOG_PATH ''${CHANGELOG_PATH}.old
echo -e "# Changelog\n\n" > $CHANGELOG_PATH
echo "$newChanges" >> $CHANGELOG_PATH
${pkgs'.coreutils}/bin/cat "''${CHANGELOG_PATH}.old" >> $CHANGELOG_PATH
${pkgs'.coreutils}/bin/rm ''${CHANGELOG_PATH}.old
echo_ok "changelog updated"
fi
fi
echo_ok "Change log updated"
''
{pkgs', ...}: let
bashFktScript = import ./bash-fkt.nix {
inherit pkgs';
};
in
pkgs'.writeShellScriptBin "update-inputs" ''
source ${pkgs'.common}/bin/common
${bashFktScript}
echo_header "Update inputs"
echo_hint "The command is executed in the current working directory and not in a nix derivation."
cd_working_dir
echo_section "Updating inputs for the following packages:"
selection=$(${pkgs'.gum}/bin/gum choose --no-limit "Version")
exitCode=$?
if [[ $exitCode -ne 0 ]]; then
echo_ok "Exiting."
exit 0
fi
packages=($selection)
echo "Updating inputs for the following packages: ''${packages[@]}"
if [[ "''${packages[@]}" == "" || $exitCode -ne 0 ]]; then
echo_ok "Exiting."
exit 0
fi
for package in "''${packages[@]}"; do
echo_step "$package updating"
## pck is the package name (to lower with flake suffix
pck=$(echo "$package" | tr '[:upper:]' '[:lower:]' | sed 's/ /-/g')
if ! ${pkgs'.nix}/bin/nix flake lock --update-input "$pck"Flake; then
echo_fail "$package failed to update"
else
echo_ok "$package updated"
fi
done
''
{pkgs', ...}: let
bashFktScript = import ./bash-fkt.nix {
inherit pkgs';
};
in
pkgs'.writeShellScriptBin "update-manual-summary" ''
source ${pkgs'.common}/bin/common
${bashFktScript}
echo_section "Update manual summary"
echo_hint "This script will update the SUMMARY.md file with the files in the manual directory."
echo_hint "The command is executed in the current working directory and not in a nix derivation."
cd_working_dir
echo_step "Updating summary file..."
doc_dir="documentation/manual/de/source/"
summary_file="''${doc_dir}SUMMARY.md"
echo "# Summary" > "$summary_file"
echo "" >> "$summary_file"
extract_first_h1() {
local file_path="$1"
${pkgs'.gnused}/bin/sed -n '/^# /{
s/^# //;
s/[()]//g;
s/\\n//g;
s/\\r//g;
s/\\t//g;
p;
q;
}' "$file_path"
}
generate_summary() {
local path="$1"
local indent="$2"
local rel_path="''${path#$doc_dir}"
for item in "$path"/*; do
if [ -d "$item" ]; then
# Es ist ein Verzeichnis#
dirname=$(${pkgs'.coreutils}/bin/basename "$item")
md_files=$(${pkgs'.findutils}/bin/find "$item" -maxdepth 1 -type f -name '*.md')
subdir_count=$(${pkgs'.findutils}/bin/find "$item" -mindepth 1 -maxdepth 1 -type d | wc -l)
if [ ! -z "$md_files" ] || [ $subdir_count -gt 0 ]; then
main_doc=$(${pkgs'.findutils}/bin/find "$item" -maxdepth 1 -type f \( -name 'index.md' -o -name 'README.md' \) | ${pkgs'.coreutils}/bin/head -n 1)
if [ -n "$main_doc" ]; then
main_doc_filename=$(${pkgs'.coreutils}/bin/basename "$main_doc")
echo "''${indent}* [''${dirname^}](''${rel_path#/}/''${dirname}/''${main_doc_filename})" >> "$summary_file"
else
echo "''${indent}* [''${dirname^}]()" >> "$summary_file"
fi
generate_summary "$item" "''${indent} "
fi
elif [[ "$item" == *.md ]]; then
filename=$(${pkgs'.coreutils}/bin/basename "$item")
title="''${filename%.*}"
h1=$(extract_first_h1 "$item")
if [ -n "$h1" ]; then
title="$h1"
fi
echo "''${indent}* [''${title}](''${rel_path#/}/''${filename})" >> "$summary_file"
fi
done
}
generate_summary "$doc_dir" ""
## remopve all lines with imprint.md and privacy.md and 404.md
${pkgs'.gnused}/bin/sed -i '/\(imprint\.md\|privacy\.md\|404\.md\|SUMMARY.md\)/d' "$summary_file"
echo "---" >> "$summary_file"
echo "* [imprint](imprint.md)" >> "$summary_file"
echo_ok "SUMMARY.md updated successfully."
echo_hint "Use task watch-manual to check the manual for errors."
echo_hint "Please check the file for correctness and commit the changes."
''