Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
alice
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
trinitas
alice
Commits
05857155
Commit
05857155
authored
Mar 31, 2022
by
gyulaid
Browse files
Options
Downloads
Patches
Plain Diff
Change detection via git
parent
4cdc162d
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
alice-ci/setup.cfg
+1
-1
1 addition, 1 deletion
alice-ci/setup.cfg
alice-ci/src/alice/cli.py
+2
-2
2 additions, 2 deletions
alice-ci/src/alice/cli.py
alice-ci/src/alice/utils.py
+37
-4
37 additions, 4 deletions
alice-ci/src/alice/utils.py
ci-examples/full.yaml
+4
-0
4 additions, 0 deletions
ci-examples/full.yaml
with
44 additions
and
7 deletions
alice-ci/setup.cfg
+
1
−
1
View file @
05857155
[metadata]
[metadata]
name
=
alice-ci
name
=
alice-ci
version
=
0.0.
5
version
=
0.0.
6
author
=
Daniel Gyulai
author
=
Daniel Gyulai
description
=
Alice CI framework
description
=
Alice CI framework
long_description
=
file: README.md
long_description
=
file: README.md
...
...
This diff is collapsed.
Click to expand it.
alice-ci/src/alice/cli.py
+
2
−
2
View file @
05857155
...
@@ -30,8 +30,8 @@ def parse_jobs(args):
...
@@ -30,8 +30,8 @@ def parse_jobs(args):
print
(
"
Begin pipeline steps...
"
)
print
(
"
Begin pipeline steps...
"
)
for
step
in
args
.
steps
:
for
step
in
args
.
steps
:
if
step
in
jobParser
.
jobs
:
if
step
in
jobParser
.
jobs
:
jobParser
.
execute_job
(
step
)
status
=
jobParser
.
execute_job
(
step
)
print
(
f
"
[Step]
{
step
}
:
SUCCESS
"
)
print
(
f
"
[Step]
{
step
}
:
{
status
}
"
)
else
:
else
:
print
(
f
"
Step
{
step
}
not found in
{
args
.
input
}
"
)
print
(
f
"
Step
{
step
}
not found in
{
args
.
input
}
"
)
exit
(
1
)
exit
(
1
)
...
...
This diff is collapsed.
Click to expand it.
alice-ci/src/alice/utils.py
+
37
−
4
View file @
05857155
import
os
import
subprocess
import
yaml
import
yaml
from
alice.exceptions
import
ConfigException
from
alice.exceptions
import
ConfigException
...
@@ -44,10 +46,41 @@ class ConfigParser:
...
@@ -44,10 +46,41 @@ class ConfigParser:
print
(
f
"
[Alice] Parsed jobs:
{
'
,
'
.
join
(
jobs
.
keys
())
}
"
)
print
(
f
"
[Alice] Parsed jobs:
{
'
,
'
.
join
(
jobs
.
keys
())
}
"
)
return
jobs
return
jobs
else
:
else
:
raise
ConfigException
(
"
[Alice] No jobs defined in config
"
)
raise
ConfigException
(
"
No jobs defined in config
"
)
def
__is_changed
(
self
,
changes
):
try
:
target
=
changes
[
"
branch
"
]
paths
=
[]
for
path
in
changes
[
"
paths
"
]:
paths
.
append
(
os
.
path
.
abspath
(
path
))
print
(
paths
)
# TODO: Error handling
command
=
[
"
git
"
,
"
diff
"
,
"
--name-only
"
,
target
]
with
subprocess
.
Popen
(
command
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
as
p
:
p
.
wait
()
for
line
in
p
.
stdout
:
change_path
=
os
.
path
.
abspath
(
line
.
decode
(
"
UTF-8
"
).
strip
())
for
path
in
paths
:
spec_path
=
os
.
path
.
abspath
(
path
)
if
change_path
.
startswith
(
spec_path
):
print
(
f
"
Modified file:
{
change_path
}
"
)
print
(
f
"
Path match:
{
path
}
"
)
return
True
except
KeyError
:
raise
ConfigException
(
f
"
Invalid
'
changes
'
config:
{
changes
}
"
)
return
False
def
execute_job
(
self
,
job_name
):
def
execute_job
(
self
,
job_name
):
if
job_name
in
self
.
jobs
:
if
job_name
in
self
.
jobs
:
# Pass the job_spec to a runner
job_spec
=
self
.
jobs
[
job_name
]
runner
=
self
.
factory
.
get_runner
(
self
.
jobs
[
job_name
][
"
type
"
])
should_run
=
True
runner
.
run
(
self
.
jobs
[
job_name
])
if
"
changes
"
in
job_spec
:
should_run
=
self
.
__is_changed
(
job_spec
[
"
changes
"
])
if
should_run
:
runner
=
self
.
factory
.
get_runner
(
job_spec
[
"
type
"
])
runner
.
run
(
job_spec
)
return
"
SUCCESS
"
else
:
print
(
"
SKIP, no change detected
"
)
This diff is collapsed.
Click to expand it.
ci-examples/full.yaml
+
4
−
0
View file @
05857155
...
@@ -18,6 +18,10 @@ runners:
...
@@ -18,6 +18,10 @@ runners:
jobs
:
jobs
:
-
name
:
env
-
name
:
env
type
:
python
type
:
python
changes
:
branch
:
origin/master
paths
:
-
"
docs"
env
:
env
:
-
name
:
B
-
name
:
B
value
:
E
value
:
E
...
...
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