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
[Tools] Ubuntu production environment "bootstrap" script #3981
Conversation
Makefile
Outdated
npm run compile | ||
git describe --tags --always > VERSION | ||
|
||
dev: |
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.
This functionality is preserved by setup
and bootstrap
; one can add a 'dev' argument upon invoking these scripts and have composer do the appropriate thing.
script/bootstrap
Outdated
/** | ||
* Prints a list of missing apt packages and prompts user to install them. | ||
* | ||
* @param array $requirements Required packages determined missing earlier |
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.
since other lines end with a dot, this line should also end with a dot
same of other doc block
Replacing a simple < 10 line Makefile with hundreds of lines of bespoke PHP scripts in order to adopt a third party's internal procedures is not a step forward. If you want to simplify running the setup add some standard targets like |
hmmm, let's see:
the way I see it, if LORIS is WAY TOO ATTACHED to makefiles, then just create makefiles and have them called FROM the scripts to rule them all, i dont care as long as I dont have to explain to each and every new developer how to run a test, how to run phpcs, how to run phan, ... a quick read https://www.jefframnani.com/project-build-protocol/ |
I'm just going to copy and paste the blog post that you linked to here which applies to this repo:
At 9 lines which don't branch or loop, you can't even claim we're at the "pretty hair, pretty quickly" point that would necessitate delegating to an external script inside of the Makefile. The complexity in this PR is added by removing the Makefile and attempting to rewrite the functionality in another language that isn't well suited to the task of building software. The other scenerio in the blog post (which is a little tortured to say applies to LORIS, although arguably does with Loris-MRI) doesn't provide any rational for abandoning that approach rather than just standardizing the makefile targets across the projects. Here are a list of standard Makefile targets used by GNU: https://www.gnu.org/prep/standards/html_node/Standard-Targets.html (not all apply to LORIS. I'm also surprised that "test" isn't included.) Adopting a real standard that's been standardized for building software for decades rather than a blog post standard would have a number of benefits such as making it trivial to build packages for any supported OS using their standard procedures. |
Call me cynic but I think
applies to us rather well. I think that even though it is using
As far as the standards are concerned, you wanna choose the make standards over the scripts to rule them all, by all means do, but no one has taken initiative to do that and I don't see anyone doing it... (test is included in the make check btw) like I said earlier we gonna appreciate the fact that the work has been done !!! I'm not saying to merge this blindly but it's at least worth a discussion and some testing. I would like to see a comparison between the GNU way that's been used for "decades" vs the github way that might be used in the next decades ?? who knows maybe we'd actually be on to something futuristic there |
Just to be clear this PR wasn't written for the purpose of replacing the Makefile. I did the development toward creating these scripts and realized that they covered what the Makefile did (and a bunch more, obviously). I'm not opposed to having both live side-by-side. It's no trouble to add the file back and do something like below if we want Makefiles. test:
script/test I do believe that the |
TODO:
|
Pretty sure this is resolved
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.
almost there!
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.
Other than all the references to "bash", this isn't conforming to the discussion we had last year about how this should be approached. This is still trying to install everything, when what we need is a script which verifies dependencies and reports the missing/incorrect versions of things that are installed before any attempt is made to install anything.
The PR itself should also be closed and re-sent when it's ready so that the discussion doesn't get confused with previous discussions from before major refactoring.
<?php | ||
|
||
/** | ||
* Use bash to determine if certain unix tools are installed. Which is used for |
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.
This isn't using bash, it's using the shell
{ | ||
// `which` returns empty if a tool is not installed. | ||
// shell_exec captures this output. | ||
if (shell_exec("which $tool")) { |
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 would be more reliable if it used exec and checked the shell return code, rather than trying to parse stdout.
if (shell_exec("which $tool")) { | ||
return true; | ||
} | ||
// check installed pacakages with dpkg. Returns 0 if installed. |
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.
Are you sure about that? dpkg(1) says:
EXIT STATUS top
0 The requested action was successfully performed. Or a check
or assertion command returned true.
1 A check or assertion command returned false.
2 Fatal or unrecoverable error due to invalid command-line
usage, or interactions with the system, such as accesses to
the database, memory allocations, etc.
(but doesn't really clarify what "a check or assertion command" is)
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.
Hmm well I mean the -s
flag gives the status of a package and returns 1 when not found so I think it works in this case.
"ERROR: LORIS requires Apache v$required_apache or higher." | ||
. PHP_EOL | ||
. "This must be done manually as it has possible security ramifications." | ||
. PHP_EOL |
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.
The second sentence is unnecessary.
@@ -0,0 +1,214 @@ | |||
#!/usr/bin/env php | |||
# This script verifies a development installation of LORIS by ensuring that | |||
# the system has all of the required dependencies such as the correct PHP and |
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.
What if PHP isn't installed?
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'll add a check for it
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 mean the script is written in PHP, so how can it check that?
Co-Authored-By: johnsaigle <4022790+johnsaigle@users.noreply.github.com>
add dave's suggestion Co-Authored-By: johnsaigle <4022790+johnsaigle@users.noreply.github.com>
Co-Authored-By: johnsaigle <4022790+johnsaigle@users.noreply.github.com>
Closing this PR and will re-open a fresh one. |
This pull request has been heavily refactored so a lot of the discussion may not make sense.
Brief summary of changes
bootstrap
verifies loris dependencies such as Apache/PHP versions and misc system tools and optionally installs them. This is meant to be run only on development environments as production environments will in the future have all of this handled by a packaged release.PHP_CLI_Helper
consists of helper functions to make it easier to write PHP scripts for the command line.Further work
To test this change...
tools/bootstrap
and let me know if there are any errors!