Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
epm-docker-test
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
epm-docker-test
Commits
f6173497
Commit
f6173497
authored
Apr 02, 2026
by
Ivan Mazhukin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup; add color output
parent
d259f1f6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
41 deletions
+44
-41
epm-docker-test.sh
epm-docker-test.sh
+44
-41
No files found.
epm-docker-test.sh
View file @
f6173497
...
...
@@ -3,9 +3,7 @@
set
-euo
pipefail
SCRIPT_REF
=
"
${
BASH_SOURCE
[0]-
$0
}
"
SCRIPT_NAME
=
"
$(
basename
"
$SCRIPT_REF
"
)
"
SCRIPT_PATH
=
"
$(
realpath
"
$SCRIPT_REF
"
2>/dev/null
||
printf
'%s\n'
"
$SCRIPT_REF
"
)
"
SCRIPT_DIR
=
"
$(
dirname
"
$SCRIPT_PATH
"
)
"
DEFAULT_REMOTE_HOST
=
"
${
EPM_DOCKER_TEST_REMOTE_HOST
:-
builder64
}
"
DEFAULT_REMOTE_USER
=
"
${
EPM_DOCKER_TEST_REMOTE_USER
:-
builder
-robot
}
"
DEFAULT_LOG_ROOT
=
"
${
XDG_STATE_HOME
:-
$HOME
/.local/state
}
/epm-docker-test"
...
...
@@ -28,6 +26,20 @@ REMOTE_ARGS=()
REMOTE_SYNC_DIR
=
""
RUN_TOKEN
=
"
$(
date
+%Y%m%d-%H%M%S
)
-
$$
"
COLOR_RESET
=
""
COLOR_WARN
=
""
COLOR_ERROR
=
""
COLOR_LOG_FATAL
=
""
COLOR_LOG_ERROR
=
""
if
[[
-t
2
&&
-z
"
${
NO_COLOR
:-}
"
]]
;
then
COLOR_RESET
=
$'
\0
33[0m'
COLOR_WARN
=
$'
\0
33[33m'
COLOR_ERROR
=
$'
\0
33[31m'
COLOR_LOG_FATAL
=
$'
\0
33[31m'
COLOR_LOG_ERROR
=
$'
\0
33[33m'
fi
usage
()
{
cat
<<
'
EOF
'
Usage:
...
...
@@ -60,11 +72,11 @@ info() {
}
warn
()
{
printf
'
[warn] %s\n'
"
$*
"
>
&2
printf
'
%s[warn]%s %s\n'
"
$COLOR_WARN
"
"
$COLOR_RESET
"
"
$*
"
>
&2
}
fatal
()
{
printf
'
[error] %s\n'
"
$*
"
>
&2
printf
'
%s[error]%s %s\n'
"
$COLOR_ERROR
"
"
$COLOR_RESET
"
"
$*
"
>
&2
exit
1
}
...
...
@@ -73,8 +85,9 @@ require_command() {
command
-v
"
$cmd
"
>
/dev/null 2>&1
||
fatal
"Required command not found:
$cmd
"
}
s
lugify
()
{
s
anitize_name
()
{
local
value
=
"
${
1
,,
}
"
#TODO сделать в одну строку и убрать башизм.
value
=
"
${
value
//[^a-z0-9]/-
}
"
value
=
"
${
value
##-
}
"
value
=
"
${
value
%%-
}
"
...
...
@@ -84,7 +97,7 @@ slugify() {
normalize_system_name
()
{
local
raw
=
"
$1
"
local
normalized
#TODO сделать в одну строку и убрать башизм.
normalized
=
"
${
raw
// /
}
"
normalized
=
"
${
normalized
,,
}
"
normalized
=
"
${
normalized
//\//
:
}
"
...
...
@@ -108,34 +121,6 @@ can_use_local_docker() {
docker info
>
/dev/null 2>&1
}
user_home_dir
()
{
local
user
=
"
$1
"
local
passwd_line
if
command
-v
getent
>
/dev/null 2>&1
;
then
passwd_line
=
"
$(
getent passwd
"
$user
"
||
true
)
"
if
[[
-n
"
$passwd_line
"
]]
;
then
printf
'%s\n'
"
${
passwd_line
##*
:
}
"
return
0
fi
fi
printf
'/home/%s\n'
"
$user
"
}
project_suffix_from_pwd
()
{
local
cwd marker
cwd
=
"
$(
pwd
-P
)
"
marker
=
"/Projects/"
if
[[
"
$cwd
"
==
*
"
$marker
"
*
]]
;
then
printf
'%s\n'
"
${
cwd
#*
"
$marker
"
}
"
return
0
fi
basename
"
$cwd
"
}
verify_eepm_tree
()
{
local
tree
=
"
$1
"
local
epm_path
...
...
@@ -161,7 +146,9 @@ resolve_local_source_path() {
candidate
=
"
${
SOURCE_PATH
:-$(
pwd
-P
)}
"
candidate
=
"
$(
realpath
"
$candidate
"
)
"
verify_eepm_tree
"
$candidate
"
printf
'%s\n'
"
$candidate
"
}
...
...
@@ -170,6 +157,7 @@ resolve_explicit_source_path() {
[[
-n
"
$candidate
"
]]
||
fatal
"Explicit source path is empty"
candidate
=
"
$(
realpath
"
$candidate
"
2>/dev/null
||
printf
'%s\n'
"
$candidate
"
)
"
verify_eepm_tree
"
$candidate
"
printf
'%s\n'
"
$candidate
"
}
...
...
@@ -179,6 +167,7 @@ default_builder_source_user() {
current_user
=
"
$(
id
-un
)
"
source_user
=
"
${
BUILDER_USER
:-
$current_user
}
"
printf
'%s\n'
"
$source_user
"
}
...
...
@@ -186,6 +175,7 @@ builder_source_candidates() {
local
source_user
source_user
=
"
$(
default_builder_source_user
)
"
printf
'/srv/%s/Projects/eepm\n'
"
$source_user
"
}
...
...
@@ -279,9 +269,9 @@ remote_sync_dir_for_source() {
local_user
=
"
$(
id
-un
)
"
base_name
=
"
$(
basename
"
$source_dir
"
)
"
printf
'/tmp/epm-docker-test-sync/%s-%s-%s\n'
\
"
$(
s
lugify
"
$local_user
"
)
"
\
"
$(
s
lugify
"
$base_name
"
)
"
\
"
$(
s
lugify
"
$RUN_TOKEN
"
)
"
"
$(
s
anitize_name
"
$local_user
"
)
"
\
"
$(
s
anitize_name
"
$base_name
"
)
"
\
"
$(
s
anitize_name
"
$RUN_TOKEN
"
)
"
}
sync_local_source_to_remote
()
{
...
...
@@ -332,8 +322,8 @@ create_log_file() {
mkdir
-p
"
$LOG_ROOT
"
||
fatal
"Could not create log root:
$LOG_ROOT
"
fi
safe_app
=
"
$(
s
lugify
"
$APP_NAME
"
)
"
safe_system
=
"
$(
s
lugify
"
$SYSTEM_IMAGE
"
)
"
safe_app
=
"
$(
s
anitize_name
"
$APP_NAME
"
)
"
safe_system
=
"
$(
s
anitize_name
"
$SYSTEM_IMAGE
"
)
"
timestamp
=
"
$(
date
+%Y%m%d-%H%M%S
)
"
log_name
=
"
${
safe_app
}
-
${
safe_system
}
-
${
timestamp
}
.log"
printf
'%s\n'
"
$LOG_ROOT
/
$log_name
"
...
...
@@ -341,6 +331,7 @@ create_log_file() {
print_failure_excerpt
()
{
local
matches
local
line
[[
-f
"
$LOG_FILE
"
]]
||
{
printf
'\nNo log file was captured.\n'
>
&2
return
0
...
...
@@ -349,7 +340,19 @@ print_failure_excerpt() {
printf
'\nCritical log lines:\n'
>
&2
matches
=
"
$(
grep
-nEi
'critical|fatal|error|failed|traceback|no such|permission denied'
"
$LOG_FILE
"
|
tail
-n
20
||
true
)
"
if
[[
-n
"
$matches
"
]]
;
then
printf
'%s\n'
"
$matches
"
>
&2
while
IFS
=
read
-r
line
;
do
case
"
$line
"
in
*
FATAL:
*
|
*
fatal:
*
)
printf
'%s%s%s\n'
"
$COLOR_LOG_FATAL
"
"
$line
"
"
$COLOR_RESET
"
>
&2
;;
*
ERROR:
*
|
*
error:
*
)
printf
'%s%s%s\n'
"
$COLOR_LOG_ERROR
"
"
$line
"
"
$COLOR_RESET
"
>
&2
;;
*
)
printf
'%s\n'
"
$line
"
>
&2
;;
esac
done
<<<
"
$matches
"
return
0
fi
...
...
@@ -431,7 +434,7 @@ run_container_locally() {
inner_script
=
"
$(
mktemp
"
${
TMPDIR
:-
/tmp
}
/epm-docker-test-inner.XXXXXX.sh"
)
"
build_container_script
"
$inner_script
"
container_name
=
"epm-test-
$(
s
lugify
"
$APP_NAME
"
)
-
$(
slugify
"
$SYSTEM_IMAGE
"
)
-
$$
"
container_name
=
"epm-test-
$(
s
anitize_name
"
$APP_NAME
"
)
-
$(
sanitize_name
"
$SYSTEM_IMAGE
"
)
-
$$
"
info
"Using eepm tree:
$resolved_source
"
info
"Target image:
$SYSTEM_IMAGE
"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment