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

refactor: collect step artifacts immediately after step finish #718

Merged
merged 21 commits into from
Sep 20, 2022

Conversation

miltolstoy
Copy link
Collaborator

@miltolstoy miltolstoy commented May 9, 2022

This change was requested for conditional steps artifacts collections easier development.
Relates #717

Logic before:

  1. Whole artifacts list preprocessing
  2. Steps execution
  3. Whole artifacts list collection

Logic now:

  1. Whole artifacts list preprocessing (same)
  2. For each step:
    2.1. Step execution
    2.2. Step's artifacts collection

Log before:

5. Executing build steps
 |   5.1.  [ 1/4 ] Step with artifacts
 |      |   ==> Adding file /home/alelyak/Desktop/universum_test/artifacts/Step_with_artifacts_log.txt to artifacts...
 |      |   ==> Execution log is redirected to file
 |      |   $ /usr/bin/touch artifact1
 |      └ [Success]
 |
 |   5.2.  [ 2/4 ] Step with no artifacts
 |      |   ==> Adding file /home/alelyak/Desktop/universum_test/artifacts/Step_with_no_artifacts_log.txt to artifacts...
 |      |   ==> Execution log is redirected to file
 |      |   ==> No 'command' found. Nothing to execute
 |      └ [Success]
 |
 |   5.3.  [ 3/4 ] Failed step with artifacts
 |      |   ==> Adding file /home/alelyak/Desktop/universum_test/artifacts/Failed_step_with_artifacts_log.txt to artifacts...
 |      |   ==> Execution log is redirected to file
 |      |   $ /usr/bin/bash -c 'touch artifact4; exit 1'
 |      |   Error: Module sh got exit code 1
 |      └ [Failed]
 |
 |   Critical step failed. All further configurations will be skipped
 |   5.4. [ 4/4 ] 'Skipped step' skipped because of critical step failure
 └ [Failed]

6. Collecting artifacts
 |   6.1. Collecting 'artifact4'
 |      |   ==> Processing '/home/alelyak/Desktop/universum_test/temp/artifact4'
 |      └ [Success]
 |
 |   6.2. Collecting 'artifact1'
 |      |   ==> Processing '/home/alelyak/Desktop/universum_test/temp/artifact1'
 |      └ [Success]
 |
 └ [Success]

7. Reporting build result
 |   ==> Here is the summarized build result:
 |   ==> 5. Executing build steps
 |   ==>   5.1.  [ 1/4 ] Step with artifacts - Success
 |   ==>   5.2.  [ 2/4 ] Step with no artifacts - Success
 |   ==>   5.3.  [ 3/4 ] Failed step with artifacts - Failed
 |   ==>   5.4.  [ 4/4 ] 'Skipped step' - Skipped
 |   ==> 6. Collecting artifacts
 |   ==>   6.1. Collecting 'artifact4' - Success
 |   ==>   6.2. Collecting 'artifact1' - Success
 |   ==> Nowhere to report. Skipping...
 └ [Success]

Log now:

5. Executing build steps
 |   5.1.  [ 1/4 ] Step with artifacts
 |      |   ==> Adding file /home/alelyak/Desktop/universum_test/artifacts/Step_with_artifacts_log.txt to artifacts...
 |      |   ==> Execution log is redirected to file
 |      |   $ /usr/bin/touch artifact1
 |      └ [Success]
 |
 |   5.2. Collecting artifacts for the 'Step with artifacts' step
 |      |   ==> Processing '/home/alelyak/Desktop/universum_test/temp/artifact1'
 |      └ [Success]
 |
 |   5.3.  [ 2/4 ] Step with no artifacts
 |      |   ==> Adding file /home/alelyak/Desktop/universum_test/artifacts/Step_with_no_artifacts_log.txt to artifacts...
 |      |   ==> Execution log is redirected to file
 |      |   ==> No 'command' found. Nothing to execute
 |      └ [Success]
 |
 |   5.4. Collecting artifacts for the 'Step with no artifacts' step
 |      |   ==> Processing '/home/alelyak/Desktop/universum_test/temp/artifact4'
 |      |   Error: No artifacts found!
 |      |   Possible reasons of this error:
 |      |    * Artifact was not created while building the project due to some internal errors
 |      |    * Artifact path was not specified correctly in 'configs.py'
 |      └ [Failed]
 |
 |   5.5.  [ 3/4 ] Failed step with artifacts
 |      |   ==> Adding file /home/alelyak/Desktop/universum_test/artifacts/Failed_step_with_artifacts_log.txt to artifacts...
 |      |   ==> Execution log is redirected to file
 |      |   $ /usr/bin/bash -c 'touch artifact4; exit 1'
 |      |   Error: Module sh got exit code 1
 |      └ [Failed]
 |
 |   5.6. Collecting artifacts for the 'Failed step with artifacts' step
 |      |   ==> Processing '/home/alelyak/Desktop/universum_test/temp/artifact4'
 |      └ [Success]
 |
 |   Critical step failed. All further configurations will be skipped
 |   5.7. [ 4/4 ] 'Skipped step' skipped because of critical step failure
 └ [Failed]

6. Reporting build result
 |   ==> Here is the summarized build result:
 |   ==> 5. Executing build steps
 |   ==>   5.1.  [ 1/4 ] Step with artifacts - Success
 |   ==>   5.2. Collecting artifacts for the 'Step with artifacts' step - Success
 |   ==>   5.3.  [ 2/4 ] Step with no artifacts - Success
 |   ==>   5.4. Collecting artifacts for the 'Step with no artifacts' step - Failed
 |   ==>   5.5.  [ 3/4 ] Failed step with artifacts - Failed
 |   ==>   5.6. Collecting artifacts for the 'Failed step with artifacts' step - Success
 |   ==>   5.7.  [ 4/4 ] 'Skipped step' - Skipped
 |   ==> Nowhere to report. Skipping...
 └ [Success]

Background steps example:

5. Executing build steps
 |   5.1.  [ 1/2 ] Background step with artifacts
 |      |   ==> Adding file /home/alelyak/Desktop/universum_test/artifacts/Background_step_with_artifacts_log.txt to artifacts...
 |      |   ==> Execution log is redirected to file
 |      |   $ /usr/bin/bash -c 'sleep 2; touch artifact3'
 |      |   ==> This step is marked to be executed in background
 |      └ [Success]
 |
 |   5.2.  [ 2/2 ] Background step with no artifacts
 |      |   ==> Adding file /home/alelyak/Desktop/universum_test/artifacts/Background_step_with_no_artifacts_log.txt to artifacts...
 |      |   ==> Execution log is redirected to file
 |      |   $ /usr/bin/bash -c 'sleep 1'
 |      |   ==> This step is marked to be executed in background
 |      └ [Success]
 |
 |   5.3. Reporting background steps
 |      |   5.3.1. Waiting for background step 'Background step with artifacts' to finish...
 |      |        └ [Success]
 |      |
 |      |   5.3.2. Collecting artifacts for the 'Background step with artifacts' step
 |      |        |   ==> Processing '/home/alelyak/Desktop/universum_test/temp/artifact3'
 |      |        └ [Success]
 |      |
 |      |   5.3.3. Waiting for background step 'Background step with no artifacts' to finish...
 |      |        └ [Success]
 |      |
 |      |   5.3.4. Collecting artifacts for the 'Background step with no artifacts' step
 |      |        |   ==> Processing '/home/alelyak/Desktop/universum_test/temp/artifact1'
 |      |        |   Error: No artifacts found!
 |      |        |   Possible reasons of this error:
 |      |        |    * Artifact was not created while building the project due to some internal errors
 |      |        |    * Artifact path was not specified correctly in 'configs.py'
 |      |        └ [Failed]
 |      |
 |      |   ==> All ongoing background steps completed
 |      └ [Success]
 |
 └ [Success]

6. Reporting build result
 |   ==> Here is the summarized build result:
 |   ==> 5. Executing build steps
 |   ==>   5.1.  [ 1/2 ] Background step with artifacts - Success
 |   ==>   5.2.  [ 2/2 ] Background step with no artifacts - Success
 |   ==>   5.3. Reporting background steps
 |   ==>     5.3.1. Waiting for background step 'Background step with artifacts' to finish... - Success
 |   ==>     5.3.2. Collecting artifacts for the 'Background step with artifacts' step - Success
 |   ==>     5.3.3. Waiting for background step 'Background step with no artifacts' to finish... - Success
 |   ==>     5.3.4. Collecting artifacts for the 'Background step with no artifacts' step - Failed
 |   ==> Nowhere to report. Skipping...
 └ [Success]

@k-dovgan
Copy link
Contributor

Can it be transformed a little so that collecting artifacts after the step is displayed as a separate step or a substep?

@miltolstoy
Copy link
Collaborator Author

Can it be transformed a little so that collecting artifacts after the step is displayed as a separate step or a substep?

Let's discuss and choose the one.

Option 1: Collect artifacts at the end of the step (current one)

 |   5.1.  [ 1/2 ] Step with artifacts
 |      |   ==> Adding file /home/alelyak/Desktop/universum_test/artifacts/Step_with_artifacts_log.txt to artifacts...
 |      |   ==> Execution log is redirected to file
 |      |   $ /usr/bin/touch artifact1
 |      |   ==> Processing '/home/alelyak/Desktop/universum_test/temp/artifact1'
 |      └ [Success]
 |
 |   5.2.  [ 2/2 ] Step with no artifacts
 |      |   ==> Adding file /home/alelyak/Desktop/universum_test/artifacts/Step_with_no_artifacts_log.txt to artifacts...
 |      |   ==> Execution log is redirected to file
 |      |   ==> No 'command' found. Nothing to execute
 |      |   ==> Processing '/home/alelyak/Desktop/universum_test/temp/artifact4'
 |      |   Error: No artifacts found!
 |      |   Possible reasons of this error:
 |      |    * Artifact was not created while building the project due to some internal errors
 |      |    * Artifact path was not specified correctly in 'configs.py'
 |      └ [Failed]

Option 2: Collect artifacts in the substep

 |   5.1.  [ 1/2 ] Step with artifacts
 |      |   ==> Adding file /home/alelyak/Desktop/universum_test/artifacts/Step_with_artifacts_log.txt to artifacts...
 |      |   ==> Execution log is redirected to file
 |      |   $ /usr/bin/touch artifact1
 |      |   5.1.1. Collecting 'artifact1'
 |      |        |   ==> Processing '/home/alelyak/Desktop/universum_test/temp/artifact1'
 |      |        └ [Success]
 |      |
 |      └ [Success]
 |
 |   5.2.  [ 2/2 ] Step with no artifacts
 |      |   ==> Adding file /home/alelyak/Desktop/universum_test/artifacts/Step_with_no_artifacts_log.txt to artifacts...
 |      |   ==> Execution log is redirected to file
 |      |   ==> No 'command' found. Nothing to execute
 |      |   5.2.1. Collecting 'artifact4'
 |      |        |   ==> Processing '/home/alelyak/Desktop/universum_test/temp/artifact4'
 |      |        |   Error: No artifacts found!
 |      |        |   Possible reasons of this error:
 |      |        |    * Artifact was not created while building the project due to some internal errors
 |      |        |    * Artifact path was not specified correctly in 'configs.py'
 |      |        └ [Failed]
 |      |
 |      └ [Success]

Option 3: Collect artifacts in the separate step
Can be also modified to count "artifact collection" steps like regular ones in steps numeration

 |   5.1.  [ 1/2 ] Step with artifacts
 |      |   ==> Adding file /home/alelyak/Desktop/universum_test/artifacts/Step_with_artifacts_log.txt to artifacts...
 |      |   ==> Execution log is redirected to file
 |      |   $ /usr/bin/touch artifact1
 |      └ [Success]
 |
 |   5.2. Collecting 'artifact1'
 |      |   ==> Processing '/home/alelyak/Desktop/universum_test/temp/artifact1'
 |      └ [Success]
 |
 |   5.3.  [ 2/2 ] Step with no artifacts
 |      |   ==> Adding file /home/alelyak/Desktop/universum_test/artifacts/Step_with_no_artifacts_log.txt to artifacts...
 |      |   ==> Execution log is redirected to file
 |      |   ==> No 'command' found. Nothing to execute
 |      └ [Success]
 |
 |   5.4. Collecting 'artifact4'
 |      |   ==> Processing '/home/alelyak/Desktop/universum_test/temp/artifact4'
 |      |   Error: No artifacts found!
 |      |   Possible reasons of this error:
 |      |    * Artifact was not created while building the project due to some internal errors
 |      |    * Artifact path was not specified correctly in 'configs.py'
 |      └ [Failed]

@k-dovgan
Copy link
Contributor

I myself prefer the option 3. It seems the most readable to me. But this way step numeration may be more confusing to the user.

@miltolstoy
Copy link
Collaborator Author

PR description was updated according to changes in the last commit.

@i-keliukh
Copy link
Contributor

Please also update the documentation to reflect the changes.

try:
step_process = self.run_in_block(self.execute_one_step, step_name, False,
item, step_executor, obj_a.critical)
if not item.background:
Copy link
Contributor

@k-dovgan k-dovgan Jun 28, 2022

Choose a reason for hiding this comment

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

I also kinda don't like the

if not item.background:
    self._run_artifact_collection_step(item.name, step_process.collect_artifacts)
<one line>
if not item.background:
    self._run_artifact_collection_step(item.name, e.step_process.collect_artifacts)

part. These lines seem a little too similar. Are we sure this cannot be fixed somehow?

@a-osipov-toxa
Copy link

Please note that this is breaking change. Some configs expect that artifacts will be collected at the end of all steps.
Probably, Universum release must be tested with these projects before delivery on build servers
Thanks

@miltolstoy
Copy link
Collaborator Author

Log examples in the PR description were extended.

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.

4 participants