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

[FEATURE] Implement concept for artifact migration #138

Merged
merged 15 commits into from
Jul 7, 2023

Conversation

eliashaeussler
Copy link
Member

@eliashaeussler eliashaeussler commented Mar 21, 2023

This PR implements aims to integrate a migration concept for versioned build artifacts.

Note

As this is an internal component, it currently does not need to be documented. However, once the relevant components for project migration (see #85) are implemented, we should add a small chapter explaining what is happening internally.

In this PR, three new components are added:

  1. Builder\ArtifactGenerator now takes care of artifact generation. The artifacts available at Builder\Artifact were rewritten to exclude every business-logic, making them easily restorable when it comes to artifact reconstitution. That said, the main artifact is no longer Builder\Artifact\BuildArtifact, but Builder\Artifact\Artifact which contains all sub-artifacts, including Builder\Artifact\BuilderArtifact and friends. In addition, the Builder\BuildResult does no longer store a prepared artifact. Instead, it holds a reference to the artifact file being generated later. For this, two new methods Builder\BuildResult::setArtifactFile() and Builder\BuildResult::getArtifactFile() were added.
  2. Builder\Artifact\Migration\Migration provides an interface for concrete artifact migrations. A class implementing this interface should provide the source artifact version, target artifact version and the concrete migration implementation. In addition, a Builder\Artifact\Migration\BaseMigration class is added which contains basic methods for usual artifact migrations.
  3. Builder\ArtifactReader is a brand-new component that is added next to the version component. It reads an artifact from a given file, migrates it to the current version using all registered migrations and maps the migrated artifact to an instance of Builder\Artifact\Artifact. This way, it is possible to restore a dumped artifact and reuse it, e.g. when implementing project synchronization as requested in [FEATURE] Sync existing projects #85.

💡 In addition to the new components, a silent migration for all v1 artifacts is added: The artifact.file path is silently migrated to artifact.path within Builder\Artifact\Migration\Migration1679497137. That's because this path was wrong implemented in the first place and differed from the configured property in the build artifact JSON schema.

Resolves: #117

@eliashaeussler eliashaeussler added the enhancement New feature or request label Mar 21, 2023
@eliashaeussler eliashaeussler self-assigned this Mar 21, 2023
@eliashaeussler eliashaeussler added this to the v2.0.0 milestone Mar 21, 2023
@codeclimate
Copy link

codeclimate bot commented Mar 21, 2023

Code Climate has analyzed commit 62a739a and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 99.6% (50% is the threshold).

This pull request will bring the total coverage in the repository to 96.5% (0.2% change).

View more on Code Climate.

@codecov
Copy link

codecov bot commented Mar 21, 2023

Codecov Report

Merging #138 (7a22509) into 3.x (31c02a6) will increase coverage by 0.54%.
The diff coverage is 99.74%.

@@             Coverage Diff              @@
##                3.x     #138      +/-   ##
============================================
+ Coverage     97.66%   98.21%   +0.54%     
- Complexity      692      774      +82     
============================================
  Files           101      111      +10     
  Lines          2186     2461     +275     
============================================
+ Hits           2135     2417     +282     
+ Misses           51       44       -7     
Impacted Files Coverage Δ
src/Builder/Config/ValueObject/FileCondition.php 100.00% <ø> (ø)
src/Builder/Config/ValueObject/Property.php 100.00% <ø> (ø)
src/Builder/Config/ValueObject/SubProperty.php 100.00% <ø> (ø)
src/Builder/Writer/GenericFileWriter.php 100.00% <ø> (ø)
src/Builder/Writer/TemplateWriter.php 100.00% <ø> (ø)
src/Template/Provider/PackagistProvider.php 50.00% <ø> (+10.00%) ⬆️
...rc/Builder/Generator/Step/ProcessingFilesTrait.php 97.72% <92.85%> (-2.28%) ⬇️
src/Builder/Artifact/Artifact.php 100.00% <100.00%> (ø)
src/Builder/Artifact/BuildArtifact.php 100.00% <100.00%> (ø)
src/Builder/Artifact/GeneratorArtifact.php 100.00% <100.00%> (ø)
... and 31 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@eliashaeussler eliashaeussler force-pushed the feature/artifact-migration branch 2 times, most recently from cd270ab to 8589ad5 Compare March 22, 2023 08:58
@eliashaeussler eliashaeussler force-pushed the feature/artifact-migration branch 5 times, most recently from c07aa8a to eb5bd75 Compare March 22, 2023 17:50
@eliashaeussler eliashaeussler marked this pull request as ready for review March 22, 2023 18:03
@mteu
Copy link
Collaborator

mteu commented Mar 22, 2023

Oh boy.

This implementation is similar to the one of Doctrine migrations.
@eliashaeussler
Copy link
Member Author

eliashaeussler commented Mar 24, 2023

🚨 The following issue needs to be resolved first in order to get this merged:

Schema not found: file:///Users/e.haeussler/test/pb-preview/resources/build-artifact.schema.json#

⬆️ This error occurs at the end when dumping the artifact. It happens because the schema file is no longer available due to the previous file mirroring.

@eliashaeussler eliashaeussler marked this pull request as draft March 24, 2023 22:40
@eliashaeussler eliashaeussler modified the milestones: v2.0.0, v3.0.0 Mar 24, 2023
@eliashaeussler eliashaeussler linked an issue Mar 24, 2023 that may be closed by this pull request
@eliashaeussler eliashaeussler removed the request for review from mteu July 7, 2023 08:50
@eliashaeussler eliashaeussler marked this pull request as ready for review July 7, 2023 09:23
@eliashaeussler eliashaeussler changed the base branch from develop to 3.x July 7, 2023 12:44
@eliashaeussler
Copy link
Member Author

🚨 The following issue needs to be resolved first in order to get this merged:

Schema not found: file:///Users/e.haeussler/test/pb-preview/resources/build-artifact.schema.json#

⬆️ This error occurs at the end when dumping the artifact. It happens because the schema file is no longer available due to the previous file mirroring.

Done ✅

@eliashaeussler eliashaeussler requested a review from mteu July 7, 2023 13:40
Copy link
Collaborator

@mteu mteu left a comment

Choose a reason for hiding this comment

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

OMG. I literally cannot wait to see this in action. 🌸

@eliashaeussler eliashaeussler merged commit 0604be7 into 3.x Jul 7, 2023
23 checks passed
@eliashaeussler eliashaeussler deleted the feature/artifact-migration branch July 7, 2023 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Migration concept for versioned build artifacts
2 participants