Merge branch 'test' into 'master'

Second container deployment on test branch

See merge request fradrive/fradrive!20
This commit is contained in:
Sarah Vaupel 2023-07-17 14:16:07 +00:00
commit 15ab17aeca
24 changed files with 183 additions and 92 deletions

View File

@ -7,6 +7,7 @@ workflow:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_MERGE_REQUEST_ID
- if: $CI_COMMIT_TAG =~ /^v/
- if: $CI_COMMIT_TAG =~ /^t/
default:
image:
@ -33,8 +34,7 @@ stages:
node dependencies:
stage: frontend:build
script:
- source .gitlab-ci/construct-flake-url.sh
- nix -L build -o result "${FLAKE}#uniworxNodeDependencies"
- nix -L build -o result ".#uniworxNodeDependencies"
- nix-store --export $(nix-store -qR result) | xz -T0 -2 > node-dependencies.nar.xz
before_script: &nix-before
- git config --global init.defaultBranch master
@ -55,8 +55,7 @@ well known:
stage: frontend:build
script:
- xzcat node-dependencies.nar.xz | nix-store --import
- source .gitlab-ci/construct-flake-url.sh
- nix -L build -o result "${FLAKE}#uniworxWellKnown"
- nix -L build -o result ".#uniworxWellKnown"
- nix-store --export $(nix-store -qR result) | xz -T0 -2 > well-known.nar.xz
before_script: *nix-before
needs:
@ -75,8 +74,7 @@ frontend:
script:
- xzcat node-dependencies.nar.xz | nix-store --import
- xzcat well-known.nar.xz | nix-store --import
- source .gitlab-ci/construct-flake-url.sh
- nix -L build -o result "${FLAKE}#uniworxFrontend"
- nix -L build -o result ".#uniworxFrontend"
- nix-store --export $(nix-store -qR result) | xz -T0 -2 > frontend.nar.xz
before_script: *nix-before
needs:
@ -96,8 +94,7 @@ uniworx:lib:uniworx:
stage: backend:build
script:
- xzcat frontend.nar.xz | nix-store --import
- source .gitlab-ci/construct-flake-url.sh
- nix -L build -o result "${FLAKE}#uniworx:lib:uniworx"
- nix -L build -o result ".#uniworx:lib:uniworx"
- nix-store --export $(nix-store -qR result) | xz -T0 -2 > uniworx:lib:uniworx.nar.xz
before_script: *nix-before
needs:
@ -119,8 +116,7 @@ uniworx:exe:uniworx:
stage: backend:build
script:
- xzcat uniworx:lib:uniworx.nar.xz | nix-store --import
- source .gitlab-ci/construct-flake-url.sh
- nix -L build -o result "${FLAKE}#uniworx:exe:uniworx"
- nix -L build -o result ".#uniworx:exe:uniworx"
- nix-store --export $(nix-store -qR result) | xz -T0 -2 > uniworx:exe:uniworx.nar.xz
before_script: *nix-before
needs:
@ -144,8 +140,7 @@ uniworx:exe:uniworxdb:
stage: backend:build
script:
- xzcat uniworx:lib:uniworx.nar.xz | nix-store --import
- source .gitlab-ci/construct-flake-url.sh
- nix -L build -o result "${FLAKE}#uniworx:exe:uniworxdb"
- nix -L build -o result ".#uniworx:exe:uniworxdb"
- nix-store --export $(nix-store -qR result) | xz -T0 -2 > uniworx:exe:uniworxdb.nar.xz
before_script: *nix-before
needs:
@ -169,8 +164,7 @@ uniworx:exe:uniworxload:
stage: backend:build
script:
- xzcat uniworx:lib:uniworx.nar.xz | nix-store --import
- source .gitlab-ci/construct-flake-url.sh
- nix -L build -o result "${FLAKE}#uniworx:exe:uniworxload"
- nix -L build -o result ".#uniworx:exe:uniworxload"
- nix-store --export $(nix-store -qR result) | xz -T0 -2 > uniworx:exe:uniworxload.nar.xz
before_script: *nix-before
needs:
@ -195,8 +189,7 @@ check:
script:
- xzcat frontend.nar.xz | nix-store --import
- xzcat uniworx:lib:uniworx.nar.xz | nix-store --import
- source .gitlab-ci/construct-flake-url.sh
- nix -L flake check ${FLAKE}
- nix -L flake check .
before_script: *nix-before
needs:
- job: node dependencies # transitive
@ -214,8 +207,7 @@ container:
stage: container:build
script:
- xzcat uniworx:exe:uniworx.nar.xz | nix-store --import
- source .gitlab-ci/construct-flake-url.sh
- cp -pr --reflink=auto -L $(nix build --print-out-paths "${FLAKE}#uniworxDocker") uniworx.tar.gz
- cp -pr --reflink=auto -L $(nix build --print-out-paths ".#uniworxDocker") uniworx.tar.gz
before_script: *nix-before
needs:
- job: node dependencies # transitive
@ -239,6 +231,34 @@ container:
interruptible: true
rules: &release-rules
- if: $CI_COMMIT_TAG =~ /^v/
test container:
stage: container:build
script:
- xzcat uniworx:exe:uniworx.nar.xz | nix-store --import
- cp -pr --reflink=auto -L $(nix build --print-out-paths ".#uniworxTestDocker") uniworx.tar.gz
before_script: *nix-before
needs:
- job: node dependencies # transitive
artifacts: false
- job: well known # transitive
artifacts: false
- job: frontend # tranitive
artifacts: false
- job: uniworx:lib:uniworx # transitive
artifacts: false
- job: uniworx:exe:uniworx
artifacts: true
- job: check # sanity
artifacts: false
artifacts:
paths:
- uniworx.tar.gz
name: "${CI_JOB_NAME}-${CI_COMMIT_SHORT_SHA}"
expire_in: "1 day"
retry: 2
interruptible: true
rules: &test-release-rules
- if: $CI_COMMIT_TAG =~ /^t/
parse changelog:
stage: prepare release
@ -249,9 +269,30 @@ parse changelog:
before_script: *nix-before
script:
- xzcat node-dependencies.nar.xz | nix-store --import
- source .gitlab-ci/construct-flake-url.sh
- nix -L run "${FLAKE}#jqChangelogJson" -- -r '.versions[0].version' > .current-version
- nix -L run "${FLAKE}#jqChangelogJson" -- -r '.versions[0].body' > .current-changelog.md
- nix -L run ".#jqChangelogJson" -- -r '.versions[0].version' > .current-version
- nix -L run ".#jqChangelogJson" -- -r '.versions[0].body' > .current-changelog.md
- echo "VERSION=$(cat .current-version)" >> build.env
artifacts:
reports:
dotenv: build.env
paths:
- .current-version
- .current-changelog.md
name: "changelog-${CI_COMMIT_SHORT_SHA}"
expire_in: "1 day"
retry: 2
interruptible: true
parse test changelog:
stage: prepare release
needs:
- job: node dependencies
artifacts: true
rules: *test-release-rules
before_script: *nix-before
script:
- xzcat node-dependencies.nar.xz | nix-store --import
- nix -L run ".#jqChangelogJson" -- -r '.versions[0].version' > .current-version
- nix -L run ".#jqChangelogJson" -- -r '.versions[0].body' > .current-changelog.md
- echo "VERSION=$(cat .current-version)" >> build.env
artifacts:
reports:
@ -291,6 +332,33 @@ upload container:
artifacts: false
rules: *release-rules
retry: 2
upload test container:
variables:
GIT_STRATEGY: none
stage: release
image: quay.io/skopeo/stable:latest
script:
- skopeo --insecure-policy copy --dest-creds "${CI_REGISTRY_USER}:${CI_JOB_TOKEN}" docker-archive://$(pwd)/uniworx.tar.gz docker://${CI_REGISTRY}/fradrive/fradrive/test:${CI_COMMIT_REF_NAME}
- skopeo --insecure-policy copy --src-creds "${CI_REGISTRY_USER}:${CI_JOB_TOKEN}" --dest-creds "${CI_REGISTRY_USER}:${CI_JOB_TOKEN}" docker://${CI_REGISTRY}/fradrive/fradrive/test:${CI_COMMIT_REF_NAME} docker://${CI_REGISTRY}/fradrive/fradrive/test:latest
needs:
- job: node dependencies # transitive
artifacts: false
- job: well known # transitive
artifacts: false
- job: frontend # tranitive
artifacts: false
- job: uniworx:lib:uniworx # transitive
artifacts: false
- job: uniworx:exe:uniworx # transitive
artifacts: false
- job: test container
artifacts: true
- job: parse test changelog
artifacts: true
- job: check # sanity
artifacts: false
rules: *test-release-rules
retry: 2
release:
variables:
@ -309,3 +377,20 @@ release:
artifacts: false
- job: parse changelog
artifacts: true
test release:
variables:
GIT_STRATEGY: none
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
rules: *test-release-rules
script:
- echo "Will create test release ${VERSION}-test..."
release:
name: "${VERSION}-test"
tag_name: '$CI_COMMIT_TAG'
description: .current-changelog.md
needs:
- job: check # sanity
artifacts: false
- job: parse test changelog
artifacts: true

View File

@ -1,12 +0,0 @@
#!/usr/bin/env bash
# SPDX-FileCopyrightText: 2022 Gregor Kleen <gregor.kleen@ifi.lmu.de>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
if [ -n "${CI_COMMIT_TAG}" ]; then
ref="refs/tags/${CI_COMMIT_TAG}"
else
ref="refs/heads/${CI_COMMIT_BRANCH}"
fi
export FLAKE="git+${CI_REPOSITORY_URL}?rev=${CI_COMMIT_SHA}&ref=${ref}"

View File

@ -1,3 +1,3 @@
SPDX-FileCopyrightText: 2022 Gregor Kleen <gregor.kleen@ifi.lmu.de>
SPDX-FileCopyrightText: 2022-2023 Sarah Vaupel <sarah.vaupel@uniworx.de>, Gregor Kleen <gregor.kleen@ifi.lmu.de>
SPDX-License-Identifier: AGPL-3.0-or-later

View File

@ -127,7 +127,7 @@
inherit (pkgs.lib) recursiveUpdate;
in {
packages = haskellFlake.packages // {
inherit (pkgs) uniworxNodeDependencies uniworxWellKnown uniworxFrontend uniworxDemoDocker uniworxDocker changelogJson;
inherit (pkgs) uniworxNodeDependencies uniworxWellKnown uniworxFrontend uniworxTestDocker uniworxDocker changelogJson;
};
apps = haskellFlake.apps // {

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
# SPDX-FileCopyrightText: 2022 Gregor Kleen <gregor.kleen@ifi.lmu.de>
# SPDX-FileCopyrightText: 2022-2023 Sarah Vaupel <sarah.vaupel@uniworx.de>, Gregor Kleen <gregor.kleen@ifi.lmu.de>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
@ -13,15 +13,17 @@ if [ -n "$(git status --porcelain)" ]; then
exit 1
fi
if [ "$(git rev-parse --abbrev-ref HEAD)" != "master" ]; then
echo "Not on master" >&2
branch="$(git rev-parse --abbrev-ref HEAD)"
if [[ $branch != "master" && $branch != "test" ]]; then
echo "Not on master or test" >&2
exit 1
fi
ourHash=$(git rev-parse HEAD)
theirHash=$(git ls-remote origin -h refs/heads/master | awk '{ print $1; }')
theirHash=$(git ls-remote origin -h refs/heads/$branch | awk '{ print $1; }')
if [ "$theirHash" != "$ourHash" ]; then
echo "Local HEAD is not up to date with remote master" >&2
echo "Local HEAD is not up to date with remote $branch" >&2
exit 1
fi

View File

@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022-2023 Gregor Kleen <gregor@kleen.consulting>, Sarah Vaupel <sarah.vaupel@ifi.lmu.de>, Steffen Jost <jost@tcs.ifi.lmu.de>
# SPDX-FileCopyrightText: 2022-2023 Sarah Vaupel <sarah.vaupel@uniworx.de>, Gregor Kleen <gregor@kleen.consulting>, Steffen Jost <jost@tcs.ifi.lmu.de>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
@ -14,11 +14,11 @@ let
'');
in if self ? lastModified then fromDate else "1970-01-01T00:00:01Z";
mkUniworxDocker = { isDemo }: prev.dockerTools.buildImage {
name = "uniworx${optionalString isDemo "-demo"}";
mkUniworxDocker = { isTest }: prev.dockerTools.buildImage {
name = "uniworx${optionalString isTest "-test"}";
tag =
let
versionFile = if isDemo then ./demo-version.json else ./version.json;
versionFile = if isTest then ./test-version.json else ./version.json;
in (builtins.fromJSON (prev.lib.readFile versionFile)).version;
inherit created;
@ -44,7 +44,7 @@ let
curl wget netcat openldap
unixtools.netstat htop gnugrep
locale
] ++ optionals isDemo [ postgresql_12 memcached uniworx.uniworx.components.exes.uniworxdb ];
];
runAsRoot = ''
#!${final.stdenv.shell}
@ -62,18 +62,6 @@ let
# just to see how to create directories here
mkdir -p /testdir
${optionalString isDemo ''
install -d -g uniworx -o uniworx -m 0750 /var/lib/postgres
install -d -g uniworx -o uniworx -m 0750 /var/lib/memcached
install -d -g uniworx -o uniworx -m 0755 /var/log/postgres
install -d -g uniworx -o uniworx -m 0755 /var/log/memcached
mkdir -p /run
install -d -g uniworx -o uniworx -m 0755 /run/postgres
''}
'';
config =
@ -83,27 +71,6 @@ let
cTime=$(date -Is)
${optionalString isDemo ''
pgDir=/var/lib/postgres
pgSockDir=/run/postgres
pgLogFile=/var/log/postgres/''${cTime}.log
export PGHOST=''${pgSockDir}
export PGLOG=''${pgLogFile}
pgNew=
if [[ -n "$(find ''${pgDir} -maxdepth 0 -type d -empty 2>/dev/null)" ]]; then
pgNew=1
fi
[[ -z "''${pgNew}" ]] || initdb --no-locale --encoding=UTF8 --username postgres --pgdata ''${pgDir}
pg_ctl start -D ''${pgDir} -l ''${pgLogFile} -w -o "-k ''${pgSockDir} -c listen_addresses= -c hba_file=${postgresHba} -c unix_socket_permissions=0777 -c max_connections=9990 -c shared_preload_libraries=pg_stat_statements -c auto_explain.log_min_duration=100ms"
[[ -z "''${pgNew}" ]] || psql -f ${postgresSchema} postgres postgres
( cd /var/lib/memcached; memcached -p 11212 ) &>/var/log/memcached/''${cTime}.log &
export SESSION_MEMCACHED_HOST=localhost
export SESSION_MEMCACHED_PORT=11212
''}
# export LOGDEST=/var/log/uniworx/''${cTime}.log # kubernetes prefers log via stdout
typeset -a configs
configs=()
@ -115,9 +82,6 @@ let
fi
configs+=('${uniworxConfig}')
cd /var/lib/uniworx
${optionalString isDemo ''
[[ -z "''${pgNew}" ]] || uniworxdb -f ''${configs}
''}
exec -- uniworx ''${configs}
'';
postgresSchema = prev.writeText "schema.sql" ''
@ -142,13 +106,11 @@ let
Volumes = {
"/var/lib/uniworx" = {};
"/var/log" = {};
} // optionalAttrs isDemo {
"/var/lib/postgres" = {};
};
};
};
in
mapAttrs (_name: mkUniworxDocker) {
uniworxDemoDocker = { isDemo = true; };
uniworxDocker = { isDemo = false; };
uniworxTestDocker = { isTest = true; };
uniworxDocker = { isTest = false; };
}

View File

@ -1,3 +0,0 @@
SPDX-FileCopyrightText: 2022 Gregor Kleen <gregor.kleen@ifi.lmu.de>,Steffen Jost <jost@tcs.ifi.lmu.de>
SPDX-License-Identifier: AGPL-3.0-or-later

View File

@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2022-2023 Sarah Vaupel <sarah.vaupel@uniworx.de>, Gregor Kleen <gregor.kleen@ifi.lmu.de>, Steffen Jost <jost@tcs.ifi.lmu.de>
SPDX-License-Identifier: AGPL-3.0-or-later

View File

@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2022-2023 Sarah Vaupel <sarah.vaupel@uniworx.de>, Gregor Kleen <gregor@kleen.consulting>
SPDX-License-Identifier: AGPL-3.0-or-later

View File

@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2022-2023 Sarah Vaupel <sarah.vaupel@uniworx.de>, Gregor Kleen <gregor@kleen.consulting>
SPDX-License-Identifier: AGPL-3.0-or-later

View File

@ -23,9 +23,9 @@
"frontend:build": "webpack --progress",
"frontend:build:watch": "webpack --watch --progress",
"i18n:test": "./missing-translations.sh",
"prerelease": "npm run test",
"release": "standard-version -a",
"postrelease": "git push --follow-tags origin master",
"prerelease": "./is-clean.sh && npm run test",
"release": "./release.sh",
"postrelease": "git push --follow-tags",
"parse-changelog": "changelog-parser ./CHANGELOG.md > changelog.json"
},
"husky": {

View File

@ -1,3 +1,3 @@
SPDX-FileCopyrightText: 2022 Felix Hamann <felix.hamann@campus.lmu.de>,Gregor Kleen <gregor.kleen@ifi.lmu.de>,Sarah Vaupel <sarah.vaupel@ifi.lmu.de>,Steffen Jost <jost@tcs.ifi.lmu.de>
SPDX-FileCopyrightText: 2022-2023 Sarah Vaupel <sarah.vaupel@uniworx.de>, Felix Hamann <felix.hamann@campus.lmu.de>, Gregor Kleen <gregor.kleen@ifi.lmu.de>, Steffen Jost <jost@tcs.ifi.lmu.de>
SPDX-License-Identifier: AGPL-3.0-or-later

20
release.sh Executable file
View File

@ -0,0 +1,20 @@
#!/usr/bin/env bash
# SPDX-FileCopyrightText: 2023 Sarah Vaupel <sarah.vaupel@uniworx.de>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
set -e
case "$(git rev-parse --abbrev-ref HEAD)" in
"master" | "main")
standard-version -a
;;
"test")
standard-version -a -t t
;;
*)
echo "Current branch not supported for release!"
exit 1
;;
esac

View File

@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2023 Steffen Jost <S.Jost@Fraport.de>
SPDX-License-Identifier: LicenseRef-Fraport-Corporate-Design

View File

@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2023 Steffen Jost <S.Jost@Fraport.de>
SPDX-License-Identifier: LicenseRef-Fraport-Corporate-Design

View File

@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2023 Steffen Jost <S.Jost@Fraport.de>
SPDX-License-Identifier: LicenseRef-Fraport-Corporate-Design

View File

@ -1,3 +1,4 @@
-- SPDX-FileCopyrightText: 2022-2023 Sarah Vaupel <sarah.vaupel@uniworx.de>, Steffen Jost <S.Jost@Fraport.de>
--
-- SPDX-License-Identifier: AGPL-3.0-or-later

View File

@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2023 Steffen Jost <S.Jost@Fraport.de>
SPDX-License-Identifier: LicenseRef-Fraport-Corporate-Design

View File

@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2023 Steffen Jost <S.Jost@Fraport.de>
SPDX-License-Identifier: LicenseRef-Fraport-Corporate-Design

View File

@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2023 Steffen Jost <S.Jost@Fraport.de>
SPDX-License-Identifier: LicenseRef-Fraport-Corporate-Design

View File

@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2023 Steffen Jost <S.Jost@Fraport.de>
SPDX-License-Identifier: LicenseRef-Fraport-Corporate-Design

View File

@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2023 Steffen Jost <S.Jost@Fraport.de>
SPDX-License-Identifier: LicenseRef-Fraport-Corporate-Design

View File

@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2023 Steffen Jost <S.Jost@Fraport.de>
SPDX-License-Identifier: LicenseRef-Fraport-Corporate-Design