-
Notifications
You must be signed in to change notification settings - Fork 402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Further Optimizations #2092
Further Optimizations #2092
Conversation
add comments in package step
test reads the same file. only one place to maintain
dont install resolvconf as it will fail in containers
Pull Request Test Coverage Report for Build 6805930329
💛 - Coveralls |
649d42e
to
850eaf8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
I currently don't have any setup available to test.
My suggestions are not blocking to integrate, but would make the code more readable.
shift | ||
|
||
# read line from the file and remove comments. Pass it over xargs as arguments to the given command. | ||
sed 's/#.*//g' ${package_file} | xargs "$@" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it better understandable, if you call here the apt-get command instead of using the passed arguments?!
I mean:
sed 's/#.*//g' ${package_file} | xargs ${apt_get} install
The name of the function already implies, that something with apt will happen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep could be done. I just wanted it to be in sync with the install and test script (see below) to not have the same logic solved in multiple ways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renamed the function to call_with_args_from_file
and added a function usage comment
shift | ||
|
||
# read line from the file and remove comments. Pass it over xargs as arguments to the given command. | ||
sed 's/#.*//g' ${package_file} | xargs "$@" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it better understandable, if you call here the apt-get command instead of using the passed arguments?!
I mean:
sed 's/#.*//g' ${package_file} | xargs ${apt_get} install
The name of the function already implies, that something with apt will happen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't want to define apt_get and allow_downgrades again as these are still used in the install_main function. And making them script wide available doesn't seem right either, as its only used in install_main.
The function body is used the same way in the test_installation script, only with the echo command.
Inthe test_installation script it named it "apt" mainly to distinguish from the function for the "pip" packages and carried over the name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shell scripts being shell scripts, maybe document the expected parameter(s) and that one should call this with a variant of sudo apt get install
or something else that can take 1 parameter that takes a package name? (Obvious example: echo
would just print the package and do nothing, but equally valid)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renamed the function to call_with_args_from_file
and added a function usage comment
@@ -327,7 +334,7 @@ check_existing() { | |||
|
|||
# The install will be in the home dir of user pi | |||
# Move to home directory now to check | |||
cd ~ || exit | |||
cd "${home_dir}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is not your fault, but using now the same name for a local variable is confusing.
I would rename it within the function to local_home_dir
or something similar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i just used the already existing variable home_dir
to get rid of ~
.
But i get your point. I renamed it to local_home_dir
shift | ||
|
||
# read line from the file and remove comments. Pass it over xargs as arguments to the default echo command. | ||
sed 's/#.*//g' ${package_file} | xargs "$@" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it better understandable, if you call here the apt-get command instead of using the passed arguments?!
I mean:
sed 's/#.*//g' ${package_file} | xargs ${apt_get} install
The name of the function already implies, that something with apt will happen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I named it "apt" mainly to distinguish from the function for the "pip" packages.
Also the command given here is not apt-get install
but echo
, as the test only reads the file content.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh right. That was just a copy paste fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merged "pip" and "apt" function into one. renamed the function to call_with_args_from_file
and added a function usage comment
I would make an additional change: The proposed change: This strategie will take a few minutes longer to run (upload) but is much safer in regards of health and time saving from using the cache properly. |
@AlvinSchiller, I just mergend #2084, so now your PR has some conflicts. Can you fix this? |
Fixed also the mpd service enablement for Spotify Installations -> Develop: https://github.com/MiczFlor/RPi-Jukebox-RFID/actions/runs/6804326866/job/18501808766#step:6:2496 |
Sorry, I think the merge of the docs PR caused also conflicts again. |
* optimize check for installed packages (apt, pip) * fix jukebox_dir * remove package optimization from dockerfile add comments in package step * add package installation from file test reads the same file. only one place to maintain * install internal packages in Dockerfile dont install resolvconf as it will fail in containers * added textfile for arm sepcific packages * removed as already part of install script * add package textfile for autohotspot setup * correct variable usage. * check homedir as prerequisite * some fixes * read modules to test from file * renamed package txt for raspberry pi specifics * update sed call * renamed local variable * save images as artifact * clarify function name. add function comment * fixed mpd service enablement * fix unnecessary rebuild of unrelated package files
This introduces further optimizations for maintenance and test runtime.
--- downside: image size in cache increases! from 300 MB to around 500 MB per debian version
Runtime summary:
after the first workflow run, which takes longer as it creates the docker image which is then cached, the subsequent runs finish in about 10 min (before around 25 min).