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

CI improvements #2080

Merged
merged 3 commits into from
Apr 8, 2024
Merged

CI improvements #2080

merged 3 commits into from
Apr 8, 2024

Conversation

moukoublen
Copy link
Member

@moukoublen moukoublen commented Apr 2, 2024

Summary of your changes

  • Move opa ci to new ci workflow Update: reverted to move to separate PR.
  • Upload cloudbeat logs on fail or debug
  • Delete docker images from artifact only on success run (but put retention-days to 2)

Screenshot/Data

Related Issues

Checklist

  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary README/documentation (if appropriate)

Introducing a new rule?

@moukoublen moukoublen self-assigned this Apr 2, 2024
Copy link

mergify bot commented Apr 2, 2024

This pull request does not have a backport label. Could you fix it @moukoublen? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v./d./d./d is the label to automatically backport to the 8./d branch. /d is the digit
    NOTE: backport-skip has been added to this pull request.

@mergify mergify bot added the backport-skip label Apr 2, 2024
Copy link

github-actions bot commented Apr 2, 2024

📊 Allure Report - 💚 No failures were reported.

Result Count
🟥 Failed 0
🟩 Passed 359
⬜ Skipped 33

@moukoublen moukoublen force-pushed the move_opa_ga_ci branch 2 times, most recently from 9fa9fdc to beeaa52 Compare April 3, 2024 09:06
@moukoublen moukoublen changed the title Move opa ci to new ci workflow CI improvements Apr 3, 2024
@moukoublen moukoublen force-pushed the move_opa_ga_ci branch 6 times, most recently from 97debbb to 3d624d1 Compare April 3, 2024 13:14
@moukoublen moukoublen marked this pull request as ready for review April 3, 2024 13:15
@moukoublen moukoublen requested a review from a team as a code owner April 3, 2024 13:15
@@ -0,0 +1,39 @@
name: 'OPA CI'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why change workflow name?

Suggested change
name: 'OPA CI'
Test OPA Policies

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 is mainly because it's not just testing; it involves fmt check, bundle building, test, opa check, and lint with Regal. So, I thought CI better describes the steps.

But I could change it to Test OPA Policies.

Copy link
Collaborator

Choose a reason for hiding this comment

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

No that's what I thought, sounds good. I just want to avoid more workflows in our actions logs, which are already pretty packed, and to avoid confusion, but I agree with you image

@moukoublen moukoublen force-pushed the move_opa_ga_ci branch 2 times, most recently from 6df73da to b1f64bf Compare April 8, 2024 10:35
name: Upload cloudbeat logs
uses: actions/upload-artifact@v4
with:
name: cloubeat-logs-ci-aws
path: logs/
if-no-files-found: warn
retention-days: 5
Copy link
Collaborator

Choose a reason for hiding this comment

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

@moukoublen I'm not sure if we need to store debug logs for more than a day. Enabling debug mode in the workflow and generating logs is usually a proactive action, and typically, you'll use those logs on the same day.

Copy link
Member Author

@moukoublen moukoublen Apr 8, 2024

Choose a reason for hiding this comment

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

Changed it to 1.

@@ -51,15 +51,19 @@ runs:
run: poetry run pytest -k "aws" --alluredir=./allure/results/ --clean-alluredir

- name: Upload test results
if: ${{ success() || failure() }}
if: ${{ always() }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Several consecutive commits will cancel the workflow run, and in such cases, we don't need to upload test results. So, we can use !cancelled() instead of always().

Copy link
Member Author

@moukoublen moukoublen Apr 8, 2024

Choose a reason for hiding this comment

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

It used to be like that (success() || failure() == !cancelled() ), and I specifically changed it because when we have missing results, then pytest retries, and it gets eventually canceled, so the job is marked as canceled.

In this case, we want the logs/results. That's why I changed it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not entirely clear on the scenario. Are you referring to situations where pytest is running and the results are incomplete when the job gets canceled? If the job is interrupted or canceled, I'm not convinced we need to retain the incomplete results.

Copy link
Member Author

Choose a reason for hiding this comment

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

Lets say that because of some bug in code or testcase, or cloud resource configuration, we end up with some expected results to be missing.

Pytest retries trying to find the expected rule with the expected status.

In that case, the job's timeout might be reached before the pytest ends with an exit code that indicates an error.

If this happens, we must upload the test results to identify which test case didn't pass.

I don't remember the specific CI that this happened I could search.

Perhaps we could better sync pytest timeout vs job timeout?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not necessary to search for the specific run, I understand now. In this case, using always() will address the issue, but it might introduce noise when the job is canceled due to a new commit being submitted.
Okay, let's try using always() and see if it behaves as expected for our needs.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, unfortunately, it introduces a bit of noise and a small delay on consecutive commits. 😞

Let's see if it becomes a bummer we can revert back to not canceled.

@@ -306,7 +328,7 @@ jobs:
timeout-minutes: 60
permissions:
pull-requests: write
if: ${{ success() || failure() }}
if: ${{ always() }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

The same applies here; I believe using !cancelled() is better than always()

Copy link
Collaborator

@gurevichdmitry gurevichdmitry left a comment

Choose a reason for hiding this comment

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

Added some comments

@moukoublen moukoublen merged commit 84229c2 into main Apr 8, 2024
23 checks passed
@moukoublen moukoublen deleted the move_opa_ga_ci branch April 8, 2024 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants