Skip to content
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

Add GH action to build library artifacts #188

Closed
wants to merge 4 commits into from

Conversation

stloyd
Copy link
Contributor

@stloyd stloyd commented Sep 15, 2023

Generated artifacts can be downloaded & re-used instead of built locally.

Example of curl library pre-build for osx: https://github.com/stloyd/static-php-build/actions/runs/6198320093

Extracted locally to buildroot dir:

stloyd@MacBook-Pro-2 static-php-cli % bin/spc build curl --build-micro    
     _        _   _                 _           
 ___| |_ __ _| |_(_) ___      _ __ | |__  _ __  
/ __| __/ _` | __| |/ __|____| '_ \| '_ \| '_ \ 
\__ \ || (_| | |_| | (_|_____| |_) | | | | |_) |
|___/\__\__,_|\__|_|\___|    | .__/|_| |_| .__/   v2.0-rc6
                             |_|         |_|    
[13:30:27] [INFO] [EXEC] sysctl -n hw.ncpu
[13:30:27] [INFO] Build target: micro
[13:30:27] [INFO] Enabled extensions: curl
[13:30:27] [INFO] Required libraries: zlib, openssl, curl
[13:30:29] [NOTI] lib [zlib] already built
[13:30:29] [NOTI] lib [openssl] already built
[13:30:29] [NOTI] lib [curl] already built
[13:30:29] [INFO] patching before-configure for curl checks
[13:30:29] [INFO] Extension [curl] patched before buildconf
[13:30:29] [INFO] Entering dir: /Users/stloyd/Documents/static-php-cli/source/php-src
[13:30:29] [INFO] [EXEC] ./buildconf --force
[13:30:35] [INFO] Extension [curl] patched before configure
[13:30:35] [INFO] Entering dir: /Users/stloyd/Documents/static-php-cli/source/php-src
[13:30:35] [INFO] Using configure: --with-curl
(...)

@crazywhalecc
Copy link
Owner

crazywhalecc commented Sep 15, 2023

This is a good idea, but we may not do it at the moment. Because each compiled extension only includes the libraries it must depend on, ignoring optional dependencies. I know we could include all suggested libs, but it will make it impossible to compile without suggesting libs, we lost flexibility. Additionally there are some lib-suggests not working very well and some libraries have almost identical build results.

Also, the current build system is not perfect. Some libraries or extensions using the C++ language can only be compiled under Alpine. At least now, we cannot directly use the spc binary to call Docker for compilation.

@crazywhalecc crazywhalecc added enhancement New feature or request kind/workflow Issues related to workflow or environment labels Sep 15, 2023
@stloyd
Copy link
Contributor Author

stloyd commented Sep 15, 2023

  1. Suggested libraries are already included when doing a build of libraries: https://github.com/crazywhalecc/static-php-cli/blob/main/src/SPC/util/DependencyUtil.php#L115,
  2. If something will fail on actions, we can exclude it for now,
  3. I'm aware that we need to skip some builds, but OSX / Ubuntu ones work quite well,
  4. Future improvement may include direct usage of such pre-built binaries directly in commands, so we can have new options like --no-cache which will always build a library, and cache link can be also directly included in config/lib.json

I think we need to start somewhere ;)

@crazywhalecc
Copy link
Owner

crazywhalecc commented Sep 15, 2023

  1. No, it just for sorting. The final sorted libraries that will be compiled depends on the libraries passed by arguments during compilation.
  2. Yeah.
  3. I'm working on it: example: ./spc build bcmath --build-cli --docker will automatically find docker and call spc itself in alpine docker (replace spc-alpine-docker).
  4. I prefer --from-cache instead of --no-cache at the moment. I don't want to change the default behavior for spc. This is a builder, and the most important thing is to successfully and flexibly build standalone PHP. Using cache, or I want to call it pre-built libraries, is more like a bonus feature.

@stloyd
Copy link
Contributor Author

stloyd commented Sep 16, 2023

Reworked the action & it now uses pre-generated binary 😮‍💨

Tested on my repo: https://github.com/stloyd/static-php-build/actions/runs/6208292912 (workflow is a little bit different cause it needed to access external repository)

@crazywhalecc
Copy link
Owner

crazywhalecc commented Nov 5, 2023

I have the following questions to figure out.

For Actions, what is the scope of its cache? Assuming others use uses: static-php/setup-static-php, how do you end up using this compiled cache to speed things up?

Because there are too many libraries now with optional dependencies. Optional dependencies for compilation are always dynamic and can be combined in too many ways.

Also, I think it would be better to set up a separate setup-static-php-deps Actions.

  1. setup-static-php also depends on it.
  2. setup-static-php-deps will first check the build cache for the current combination of extensions and libraries.
  3. If there is a cache of the incoming combination in setup-static-php-deps, use it directly, otherwise build it.
  4. setup-static-php continues building PHP.

@stloyd stloyd closed this Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request kind/workflow Issues related to workflow or environment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants