-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
fix: github test workflow #10325
fix: github test workflow #10325
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @robert-zaremba for the prompt fix! I believe the problem might be in the xargs being super shallow and not actually invoking go test ./...
I think we don't even need to have pkgs.txt, we just need to invoke go test ./... and that should traverse the entire tree.
.github/workflows/test.yml
Outdated
run: go list ./... > pkgs.txt | ||
- name: Append ./db packages | ||
run: cd db; go list ./... >> ../pkgs.txt; cd .. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have thought that this would handle the case of db. I think what's missing is the ellipsis for go test ./...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean? ./...
is there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was running go list ./...
locally, and /db
package was not there. I was then trying to import it in the main module (/
), and it was still not reported by go list ./...
- it seams the go list only reports packages in the current module (excluding dependencies)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly! What I mean is that instead of trying to invoke go list ./...
then getting the name of each package, we just literally remove all of it and just invoke go test ./...
as the sole command and we'll be gucci forever, without all the hoops or hardcoding and having packages missed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe go test ./...
will also exclude the nested /db
module
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
go test
won't execute db
for the very same reason go list
won't print it.
@odeke-em we want to have a list of all packages to test in order to execute tests in parallel. We are spawning 4 processes which execute tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
other idea would be to find all go.mod
files, cd there and rung go list
to merge in a single file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, good idea @robert-zaremba! I think that'll work best because otherwise we have to play catch up to every single Go module that gets added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@robert-zaremba how about this
find . -type f -name "go.mod" | while read F;do dirname $F;done
to list out the packages with go modules in them and then invoke go test ./...
on each of them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the packages don't have an even test distribution. For example - the SDK has probably 95% of the tests.
Again - we want to put the packages to tests in a matrix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add to the contributing, if a new go.mod is added, this needs to be modified. Otherwise having a script to merge all the files would be useful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this change @robert-zaremba, almost LGTM, but I had suggested before this pattern
find . -name "go.mod" | grep -v cosmovisor | while read F;do cd $(dirname $F);go list ./... >> $pkgsfile;cd $OLDPWD;done
.github/workflows/test.yml
Outdated
- name: Create a file with all the pkgs | ||
run: go list ./... > pkgs.txt | ||
- name: Create a file with all core Cosmos SDK pkgs | ||
run: pkgsfile=`pwd`/pkgs.txt; find -name go.mod -not -path "./cosmovisor/*" -execdir go list ./... >> $pkgsfile \; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am not sure about this pattern but as I had suggested before
find . -name "go.mod" | grep -v cosmovisor | while read F;do cd $(dirname $F);go list ./... >> $pkgsfile;cd $OLDPWD;done
should cut the deal properly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will do the same effect to what I have implemented. Is there any advantage of your approach?
Unfortunately it doesn't work - see the CI result (I was writing about it somewhere in Discord). Basically, you can't test package of module B while being in module A. For example, the following doesn't work if you are in the repo root: go test ./db/
.
I think the only way to fix it is to modify this step:
cat pkgs.txt.part.${{ matrix.part }} | xargs go test -mod=readonly -timeout 30m -coverprofile=${{ matrix.part }}profile.out -covermode=atomic -tags='norace ledger test_ledger_mock'
We have another problem: from one module we can't test other module. For example, this doesn't work:
|
For the code coverage problem, I think we should merge all profiles in a single file. |
After thinking a little more about it: we are planning to break x/modules in separate go modules -> so the current matrix test won't make sense. Hence, for the sake of the current problem I propose (and going to implement) the following change:
Later, once we break the SDK in the modules we will remove the current test matrix job and integrate matrix into the module testing job |
Codecov Report
@@ Coverage Diff @@
## master #10325 +/- ##
==========================================
+ Coverage 64.20% 64.85% +0.65%
==========================================
Files 581 594 +13
Lines 55206 56380 +1174
==========================================
+ Hits 35446 36568 +1122
+ Misses 17742 17725 -17
- Partials 2018 2087 +69
|
@marbar3778 , @odeke-em , @AmauryM could you make a re-review? I've added a script to handle the problems mentioned above. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, but utACK. We can merge this, and closely observe a following PR which modifies a submodule.
I will create a new issue to rework this flow once we will break down the core module into submodules. |
@alessio , @marbar3778, @AmauryM , @aaronc , do you know how to configure the expected tests ? I removed |
Fixed this now. But I think we should refine this a bit more. Let's discuss in #10446 |
Definitely there is more work to do. |
## Description Closes: #10319 @odeke-em reported that `db/memdb` doesn't build: #10319 The problem is not detected by the Github CI. Here we try to fix this. --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [x] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] provided a link to the relevant issue or specification - [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [x] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [x] added a changelog entry to `CHANGELOG.md` - [x] included comments for [documenting Go code](https://blog.golang.org/godoc) - [x] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
Description
Closes: #10319
@odeke-em reported that
db/memdb
doesn't build: #10319The problem is not detected by the Github CI. Here we try to fix this.
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
to the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!
in the type prefix if API or client breaking change