Skip to content

Conversation

@tienvx
Copy link
Contributor

@tienvx tienvx commented Dec 14, 2022

This is 2nd pull request in a series of "small" pull requests I split from #210

This pull request depend on #278, please review it first.

There are number of reasons why I choose this approach:

  • Update installers to downloads more files require adding quite a mount of code (see pull request above)
    • Need download at least 4 files
      • Pact Ruby Standalone
      • Pact FFI header
      • Pact FFI shared library
      • Pact stub server
    • If we want supports plugins, 2 more for each plugin
      • csv
        • json meta file
        • executable file
      • protobuf
        • json meta file
        • executable file
    • Each file has different url/file-name/destination-path depend on OS and architecture.
    • Extracting zip or tar.gz file is easy, but extracting gzip file require more work, and we need to move the target file to the correct destination. *.gz don't restore the original file name.
    • Mark files as executable after downloading
    • Delete downloaded archived file after extracting
    • Determine correct path to scripts for each OS
  • Maintain custom code does not look right to me
    • Download on runtime, not on running composer install/update
    • Need to re-download all files after installing/updating
    • No caching support

After looking for alternate solution, I found this library civicrm/composer-downloads-plugin. But the author is also busy, he don't have time review my pull requests.

That's why I maintain my own fork. After making some changes, I released version 1.1, which is used by this pull request. This library has some features:

  • Support all kind of files that composer suppport
  • Download on composer install/update command
  • Support caching from composer
  • Don't need to re-download files if already downloaded
  • Support variables for different url/path depend on OS and architecture.

I think this pull request also solve this ticket #276

@tienvx tienvx force-pushed the offload-installers branch from 37b5c92 to 21267c1 Compare December 14, 2022 16:12
Comment on lines +93 to +96
"config": {
"allow-plugins": {
"tienvx/composer-downloads-plugin": true
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add this config to make running test easier. I think each project depend on this library also need to define this config again in composer.json

Copy link
Contributor Author

@tienvx tienvx Jan 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will update README.md and/or CHANGELOG.md and/or UPGRADE-9.0.md about this change

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if we can provide support for a user to support the ffi being provided by them in their own location (which should be fine as we can have to provide a path to the library loader) we can support users who dont want to, or cant enable scripts to download.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with it.

This feature can be useful for plugins. See this link for explanation.

Currently I don't have any idea on how to do it. Can you create a ticket so we can look at it later?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

of course buddy 👍🏾 shall do now

private static function getSuffix(): string
{
return $this->pactMessage;
return (PHP_OS_FAMILY === 'Windows' ? '.bat' : '');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we use symfony/process, I think we don't have to do this.

We can discuss this again in the future pull request (maybe the 4th pull request)

Copy link
Contributor Author

@tienvx tienvx Jan 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pull request for using symfony/process #284


hub pull-request --browse --message "feat: update standalone to ${STANDALONE_VERSION}"

git checkout master
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we only need to update 1 number in composer.json. That's why I think this script is not needed.

@tienvx tienvx mentioned this pull request Dec 26, 2022
Copy link
Collaborator

@cfmack cfmack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good, I ran this locally and it passed, all tests in Github actions pass.

@cfmack cfmack merged commit fbb50d9 into pact-foundation:master Jan 11, 2023
@tienvx tienvx deleted the offload-installers branch January 11, 2023 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants