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

Implement sync proxy metadata command #224

Merged
merged 1 commit into from
Jul 17, 2020

Conversation

akondas
Copy link
Member

@akondas akondas commented Jul 17, 2020

No description provided.

@akondas akondas requested a review from karniv00l July 17, 2020 13:09
@codecov
Copy link

codecov bot commented Jul 17, 2020

Codecov Report

Merging #224 into static-proxy will increase coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@                Coverage Diff                 @@
##             static-proxy     #224      +/-   ##
==================================================
+ Coverage           99.82%   99.87%   +0.05%     
- Complexity           1401     1417      +16     
==================================================
  Files                 233      234       +1     
  Lines                4030     4069      +39     
==================================================
+ Hits                 4023     4064      +41     
+ Misses                  7        5       -2     
Impacted Files Coverage Δ Complexity Δ
src/Command/ProxySyncMetadataCommand.php 100.00% <100.00%> (ø) 4.00 <4.00> (?)
src/Service/Downloader/NativeDownloader.php 100.00% <100.00%> (ø) 11.00 <3.00> (+3.00)
src/Service/Proxy.php 98.70% <100.00%> (+1.97%) 34.00 <8.00> (+9.00)
src/Service/Dist.php 100.00% <0.00%> (+5.55%) 7.00% <0.00%> (ø%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ea14b9a...2faec66. Read the comment docs.

if ($version === $packageData['version']) {
$this->filesystem->write($this->distPath($package, $lastDist['reference'], $lastDist['type']), $this->downloader->getContents($lastDist['url'])
$path = $this->distPath($package, $lastDist['reference'], $lastDist['type']);
if ($version === $packageData['version'] && !$this->filesystem->has($path)) {
Copy link
Member Author

Choose a reason for hiding this comment

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

added check if version already exist (without this $this->filesystem->write will throw exception)

@@ -9,8 +9,14 @@

final class FakeDownloader implements Downloader
{
// todo: remove this and allow only for in-memory content to explicit control
Copy link
Member Author

Choose a reason for hiding this comment

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

yup, this class is to magical, while rewriting the tests, I was able to be surprised more than once, because the file system is not defined in the code

{
$dist = new Dist('repo', 'package', 'dev-master/feature', '123456', 'zip');

self::assertEquals(md5('dev-master/feature'), $dist->version());
Copy link
Member Author

Choose a reason for hiding this comment

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

more coverage 💪

@@ -71,6 +71,7 @@
"ekino/phpstan-banned-code": "^0.3.1",
"friendsofphp/php-cs-fixer": "^2.16",
"fzaninotto/faker": "^1.9",
"league/flysystem-memory": "^1.0",
Copy link
Member Author

Choose a reason for hiding this comment

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

this will allow to write cleaner and faster tests

foreach ($files as $file) {
$url = sprintf('%s://%s', parse_url($this->url, PHP_URL_SCHEME), $file['path']);
// todo: what if proxy do not return `Last-Modified` header?
if ($this->downloader->getLastModified($url)->getOrElse(0) > ($file['timestamp'] ?? time())) {
Copy link
Member Author

Choose a reason for hiding this comment

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

slow performance, maybe we can speed this up with @reactphp 😎

@karniv00l karniv00l merged commit 8bfbde1 into repman-io:static-proxy Jul 17, 2020
@akondas akondas mentioned this pull request Jul 20, 2020
8 tasks
@akondas akondas deleted the static-proxy branch July 20, 2020 09:54
akondas added a commit that referenced this pull request Jul 21, 2020
karniv00l pushed a commit that referenced this pull request Jul 21, 2020
* Serve static proxy metadata and use v2 endpoint for dist lookup (#222)

* Move all proxy logic to Proxy class (#223)

* Implement sync proxy metadata command (#224)

* Use async and stream for downloading metadata and distibutions (#226)

* Create migration to better auto upgrade to 0.5.0 (#227)
@karniv00l karniv00l added this to the 0.5.0 milestone Aug 4, 2020
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.

2 participants