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: Reconfigure CodeCov action to ensure stability #1414

Conversation

shahzadlone
Copy link
Member

@shahzadlone shahzadlone commented Apr 27, 2023

Relevant issue(s)

Resolves #1413

Description

Note: The first 3 commits are house keeping stuff that I didn't want to open a separate issue for.

  • Ensures Codecov doesn't run on every push (code coverage reports will only generate for every PR, or pushes on master and develop). This also means contributors don't need to have codecov to have a build run successfully on their fork pushes.
  • If for whatever reason the code cov token doesn't exist, still run the action (but might be flakey - so retry until passes upto 5 times).

Future: Should probably rework this to do the pull_request -> trigger a workflow_run that will be passed the code coverage report that will then have the secrets in the second privileged action run. But until then hopefully this can get us by.

How has this been tested?

Fork pushes and this PR pushes.

@shahzadlone shahzadlone added the ci/build This is issue is about the build or CI system, and the administration of it. label Apr 27, 2023
@shahzadlone shahzadlone added this to the DefraDB v0.5.1 milestone Apr 27, 2023
@shahzadlone shahzadlone requested a review from a team April 27, 2023 16:03
@shahzadlone shahzadlone self-assigned this Apr 27, 2023
@codecov
Copy link

codecov bot commented Apr 27, 2023

Codecov Report

Merging #1414 (e795702) into develop (b04c423) will decrease coverage by 0.20%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1414      +/-   ##
===========================================
- Coverage    72.17%   71.98%   -0.20%     
===========================================
  Files          185      185              
  Lines        18295    18295              
===========================================
- Hits         13204    13169      -35     
- Misses        4050     4076      +26     
- Partials      1041     1050       +9     

see 7 files with indirect coverage changes

@AndrewSisley
Copy link
Contributor

Partial hits are considered hits, we tried to find a way to do this a while back but this feature didn't exist.

This sounds like us fudging the numbers, prioritising marketing over engineering - what are your reasons for wanting to do this?

Copy link
Contributor

@AndrewSisley AndrewSisley left a comment

Choose a reason for hiding this comment

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

I have two questions, one major, one minor that need resolving before merge please :)

.github/codecov.yml Outdated Show resolved Hide resolved
@shahzadlone shahzadlone added the action/no-benchmark Skips the action that runs the benchmark. label Apr 27, 2023
@shahzadlone
Copy link
Member Author

Partial hits are considered hits, we tried to find a way to do this a while back but this feature didn't exist.

This sounds like us fudging the numbers, prioritising marketing over engineering - what are your reasons for wanting to do this?

I disagree that this is fudging the numbers, I would argue that our test coverage right now as it stands is numbers fudged against us. I can share more thoughts in a discord thread as this seems like a good discussion point. It's probably also best to do this in a separate PR.

Note: Code cov actions might need to be reworked slightly before this PR can merge even if this is the only blocker. Will ping once the changes have been made.

@shahzadlone shahzadlone force-pushed the lone/ci/make-code-cov-less-flakey branch from 55d0a9e to 51c4286 Compare May 1, 2023 12:12
@AndrewSisley
Copy link
Contributor

I disagree that this is fudging the numbers, I would argue that our test coverage right now as it stands is numbers fudged against us. I can share more thoughts in a discord thread as this seems like a good discussion point. It's probably also best to do this in a separate PR.

Good call, can you please remove this from this PR? Even if we all agreed this is what we want I think it would be very good for it to have its own commit, and documentation on why we want to do this (if we do). A discord thread would also be good to figure out where the team stands on this.

@shahzadlone
Copy link
Member Author

I disagree that this is fudging the numbers, I would argue that our test coverage right now as it stands is numbers fudged against us. I can share more thoughts in a discord thread as this seems like a good discussion point. It's probably also best to do this in a separate PR.

Good call, can you please remove this from this PR? Even if we all agreed this is what we want I think it would be very good for it to have its own commit, and documentation on why we want to do this (if we do). A discord thread would also be good to figure out where the team stands on this.

Yup totally aligned with that

@shahzadlone shahzadlone force-pushed the lone/ci/make-code-cov-less-flakey branch 3 times, most recently from d84ecb0 to bd02af6 Compare May 3, 2023 09:28
@shahzadlone shahzadlone requested review from AndrewSisley and a team May 3, 2023 09:33
@shahzadlone
Copy link
Member Author

Introducing a retry mechanic to get by for now, seems like codcov team is aware of this bug that happens without a token. Until they push it we can rely on this retry mechanic.

In future should probably rework using a 2 step workflow where first work is not privileged and generates the report, then the report is passed to a privileged workflow run action that has the secrets to upload using the token.

env:
codecov_secret: ${{ secrets.CODECOV_TOKEN }}
if: env.codecov_secret == ''
uses: Wandalen/[email protected]
Copy link
Contributor

Choose a reason for hiding this comment

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

todo: Can we please at least use a more popular dependency if we are going to introduce one? The one currently on this line only has 35 stars, whereas this one has 245 and was built at/for a well known company whereas wandalens appears to be purely a personal project.

Copy link
Member Author

Choose a reason for hiding this comment

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

Which one are you recommending? I just saw many people use this one to fix the code cov flakey stuff. Happy to look into another one that might be more reputable.

Copy link
Contributor

Choose a reason for hiding this comment

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

lol, I forgot to link it. I had it open and ready for you sorry. This is the one I meant to suggest: https://github.com/marketplace/actions/retry-step

Copy link
Member Author

Choose a reason for hiding this comment

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

It seems to be intended to replace the run step commands not action uses. LMK if you see an example for retries upon an action use.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

You should be able to run the code cov action as a command no?

I'm just very uncomfortable introducing such an unused personal project into our CI system, and I think if I had to choose between using that action, or having a flaky code cov action, I would probably go for the flaky code cov action.

Copy link
Member Author

@shahzadlone shahzadlone May 4, 2023

Choose a reason for hiding this comment

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

I would rather use the official codecov github action than the shell command as it takes into account some built-in github metadata when it uploads the data to codcov.

I disagree that it is an unused personal project as it has thousands of uses already: https://github.com/search?q=Wandalen%2Fwretry.action+path%3A.github%2Fworkflows%2F+language%3AYAML&type=Code&s=indexed&o=desc

Some of the users are shopify, open-metadata, Isar Database, Airbyte, Immich

We shouldn't not solve the problem just because we have to use a 3rd party action. We already use a lot of 3rd party actions, even when we weren't open-sourced.

Copy link
Member Author

Choose a reason for hiding this comment

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

Also keep in mind, this will mostly be a fallback case when a token isn't available (ASFAIK it will always be there). So majority of times this won't even be hit or used once the rework of this action is done.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's pretty safe to use the one Shahzad has at the moment. Specially that it's set on a version so future changes won't affect us unless we update without checking what the changes are.

@shahzadlone shahzadlone force-pushed the lone/ci/make-code-cov-less-flakey branch 2 times, most recently from 32b6306 to 3d1632e Compare May 3, 2023 22:36
@shahzadlone shahzadlone requested a review from a team May 3, 2023 22:55
Copy link
Collaborator

@fredcarle fredcarle left a comment

Choose a reason for hiding this comment

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

LGTM!

@shahzadlone shahzadlone force-pushed the lone/ci/make-code-cov-less-flakey branch from 3d1632e to 3024d50 Compare May 15, 2023 19:18
@shahzadlone shahzadlone force-pushed the lone/ci/make-code-cov-less-flakey branch from 3024d50 to e795702 Compare May 17, 2023 14:36
@shahzadlone shahzadlone merged commit 0621856 into sourcenetwork:develop May 17, 2023
@shahzadlone shahzadlone deleted the lone/ci/make-code-cov-less-flakey branch May 18, 2023 18:46
shahzadlone added a commit to shahzadlone/defradb that referenced this pull request Feb 23, 2024
## Relevant issue(s)
Resolves sourcenetwork#1413

## Description
- Ensures Codecov doesn't run on every push (code coverage reports will
only generate for every PR, or pushes on `master` and `develop`). This
also means contributors don't need to have codecov to have a build run
successfully on their fork pushes.
- If for whatever reason the code cov token doesn't exist, still run the
action (but might be flakey - so retry until passes up to 5 times).

Future: Should probably rework this to do the `pull_request` -> trigger
a `workflow_run` that will be passed the code coverage report that will
then have the secrets in the second privileged action run. But until
then hopefully this can get us by.

## How has this been tested?
Fork pushes and this PR pushes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action/no-benchmark Skips the action that runs the benchmark. ci/build This is issue is about the build or CI system, and the administration of it.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix code covs flakey fails and don't run on fork pushes
3 participants