Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bitia-cli
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bitia
bitia-cli
Commits
2fbc934c
Commit
2fbc934c
authored
2 years ago
by
dilawar
Browse files
Options
Downloads
Patches
Plain Diff
feat: add uuid1 when command line is used.
parent
a6bce64d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2
version 0.2.0
Pipeline
#3755
failed with stages
Stage:
Stage:
in 1 minute and 55 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bitia/helper.py
+11
-2
11 additions, 2 deletions
bitia/helper.py
tests/test_cli.py
+4
-1
4 additions, 1 deletion
tests/test_cli.py
with
15 additions
and
3 deletions
bitia/helper.py
+
11
−
2
View file @
2fbc934c
...
...
@@ -5,9 +5,11 @@ __email__ = "dilawar@subcom.tech"
import
hashlib
import
sys
import
uuid
import
zipfile
import
shutil
from
pathlib
import
Path
from
datetime
import
datetime
import
tempfile
import
typing
as
T
...
...
@@ -84,7 +86,9 @@ def create_pipeline_from_single_script(script: Path) -> Path:
return
prepare_archive
(
pipeline_dir
)
def
create_pipeline_from_command
(
cmd
:
str
)
->
Path
:
def
create_pipeline_from_command
(
cmd
:
str
,
add_timestamp
:
bool
=
True
,
add_uuid1
:
bool
=
True
)
->
Path
:
"""
Create a pipeline from user input.
Returns
...
...
@@ -94,7 +98,12 @@ def create_pipeline_from_command(cmd: str) -> Path:
pipeline_dir
=
Path
(
tempfile
.
mkdtemp
(
prefix
=
"
bitia_
"
))
pipeline_file
=
pipeline_dir
/
bconfig
.
BITIA_MAIN_SCRIPT_NAME
with
pipeline_file
.
open
(
"
w
"
,
newline
=
"
\n
"
)
as
outf
:
outf
.
write
(
f
"
#!/bin/sh
\n\n
{
cmd
}
"
)
outf
.
writeline
(
"
#!/bin/sh
"
)
if
add_timestamp
:
outf
.
writeline
(
f
"
# timestamp=
{
datetime
.
now
().
isoformat
()
}
"
)
if
add_uuid1
:
outf
.
writeline
(
f
"
# uuid=
{
uuid
.
uuid1
()
}
"
)
outf
.
writeline
(
f
"
{
cmd
}
"
)
logger
.
info
(
"
Wrote pipeline %s
"
,
pipeline_file
.
read_text
())
return
prepare_archive
(
pipeline_dir
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_cli.py
+
4
−
1
View file @
2fbc934c
...
...
@@ -2,8 +2,11 @@ from bitia.__main__ import run_pipeline
def
test_cli_sanity
():
nlines
=
0
for
line
in
run_pipeline
(
"
ls -ltr /
"
):
print
(
line
)
nlines
+=
1
print
(
11
,
line
)
assert
nlines
>
10
,
"
Too few lines
"
if
__name__
==
"
__main__
"
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment