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

feat(ci): run unit test jobs on arm64 machines additionally #12864

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

galargh
Copy link
Contributor

@galargh galargh commented Feb 3, 2025

Related Issues

Resolves #12860

Proposed Changes

Start running unit-* jobs on arm64 machines in addition to x86_64 ones.

Additional Info

In order to accommodate this change, I moved the test discovery code to a dedicated Go CLI. The important change in the structure of metadata is that now each test group can be associated with many target runners.

What's more, I split the test group discovery into part 1 which lists all the test groups, and part 2 which returns the metadata (e.g. runner information, etc.) for a given test group name. Thanks to this the outputs of the discovery job can be smaller and we minimise the risk of hitting the maximum output size limit.

Checklist

Before you mark the PR ready for review, please make sure that:

@galargh galargh changed the title GitHub actions arm64 Run Unit test jobs on arm64 machines additionally Feb 3, 2025
@galargh galargh changed the title Run Unit test jobs on arm64 machines additionally feat(ci): run unit test jobs on arm64 machines additionally Feb 3, 2025
@BigLep
Copy link
Member

BigLep commented Feb 3, 2025

@galargh : I assume you'll mark it ready for review when it is.

@galargh galargh marked this pull request as ready for review February 4, 2025 09:27
@galargh galargh requested review from rvagg and BigLep February 4, 2025 09:27
@galargh galargh added the skip/changelog This change does not require CHANGELOG.md update label Feb 4, 2025
@galargh
Copy link
Contributor Author

galargh commented Feb 4, 2025

@galargh : I assume you'll mark it ready for review when it is.

Yes, it is ready for review now :)

cmd/ci/main.go Outdated
return [][]string{{"ubuntu-latest"}}
}

namesToRunners := map[string][][]string{
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure how much I like this TBH. Editing yaml for this kind of data seems much more convenient than string hardcoded into map[string][][]string.

From a design perspective, the code here is entirely CI specific. It should live somewhere inside .github folder?

I do think the long term goal is to desolve this into itests themselves in form of annotations or struct tags on "Test Suit" (see testify).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do think the long term goal is to desolve this into itests themselves in form of annotations or struct tags on "Test Suit" (see testify).

I'd treat this as a mid-step towards that desired goal. It's going to be much easier to parse and manipulate the data from itests here. And then, the hardcoded info inside this tool will disappear.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I'd love to see more of this metadata live closer to the tests themselves with annotations, but I understand that is a bigger step. This to me has better readability than jq commands in yaml files we have now. I don't see this making things worse and is actually improving what we have now, so 👍 from me.

The idea of moving this into the .github directory seems good/reasonable.

Copy link
Member

Choose a reason for hiding this comment

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

@galargh : any thoughts on moving this to .github?

Copy link
Member

@BigLep BigLep left a comment

Choose a reason for hiding this comment

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

I took some time coming up to speed on how lotus tests are working within CI. Apologies if I'm raising points that were covered in previous PRs. My comments are partly coming from trying to get my head around the data model and structuring how the tests. Feel free to disregard if my comments are off or don't make sense.

cmd/ci/main.go Outdated Show resolved Hide resolved
cmd/ci/main.go Outdated Show resolved Hide resolved
cmd/ci/main.go Outdated Show resolved Hide resolved
cmd/ci/main.go Outdated Show resolved Hide resolved
cmd/ci/main.go Outdated Show resolved Hide resolved
.github/workflows/test.yml Outdated Show resolved Hide resolved
SKIP_CONFORMANCE: ${{ fromJson(steps.group.outputs.metadata).skip_conformance && '1' || '0' }}
TEST_RUSTPROOFS_LOGS: ${{ fromJson(steps.group.outputs.metadata).test_rustproofs_logs && '1' || '0' }}
FORMAT: ${{ fromJson(steps.group.outputs.metadata).format || 'standard-verbose' }}
PACKAGES: ${{ join(fromJson(steps.group.outputs.metadata).packages, ' ') }}
Copy link
Member

Choose a reason for hiding this comment

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

Why do we set an environment variable when it is also referenced below as a param to gotestsum? Basically I'm wondering if we should inline this to the gotestsum call.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't matter much here because we literally execute a script to get these values, but it's a good security practice for some types of workflows so I tend to stick with it in general.

Copy link
Member

Choose a reason for hiding this comment

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

Got it - makes sense. I'm good to practice the right behavior here.

Should we adjust this line below to be consistent?

-- ${{ fromJson(steps.group.outputs.metadata).go_test_flags || '' }}

.github/workflows/test.yml Outdated Show resolved Hide resolved
cmd/ci/main.go Outdated Show resolved Hide resolved
cmd/ci/main.go Show resolved Hide resolved
Copy link
Member

@BigLep BigLep left a comment

Choose a reason for hiding this comment

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

This is seeming good to me, and certainly not making anything worse. My remaining comments are small nits.

I resolved all previous conversations that I believe are resolved now.

Before merging, it would be good to get input on #12864 (comment)

Also, is there an easy way to sanity check that we aren't reducing our coverage with this change (i.e., we didn't accidentally miss a test group execution context)?

}

type Runner []string
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add the explanatory comment for why Runner is []string rather than just string?

},
}

if strings.HasPrefix(name, "itest-") {
return []string{strings.Join([]string{".", "itests", strings.Join([]string{strings.TrimPrefix(name, "itest-"), "test.go"}, "_")}, string(os.PathSeparator))}
if strings.HasPrefix(testGroupName, "itest-") {
Copy link
Member

Choose a reason for hiding this comment

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

(nit) but maybe move this if to the top of the function to avoid the interleaving of concerns that we have now

nonItest map declaration
itest handling
nonItest handling

return []Runner{linux_x64}
}

testGroupNamesToRunners := map[string][]Runner{
Copy link
Member

Choose a reason for hiding this comment

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

nit: testGroupNameToRunner (since the map key is a single test group name?

.github/workflows/test.yml Outdated Show resolved Hide resolved
cmd/ci/main.go Show resolved Hide resolved
runs-on: ${{ matrix.runner }}
strategy:
matrix:
runner: [ubuntu-latest, ubuntu-24.04-arm]
Copy link
Member

Choose a reason for hiding this comment

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

Got it. So this job needs to run on x86_64 and arm, which is accomplished by [ubuntu-latest, ubuntu-24.04-arm]. Sounds good.

Suggested change
runner: [ubuntu-latest, ubuntu-24.04-arm]
# We need to cache for each architecture we support: x86_64 and arm
runner: [ubuntu-latest, ubuntu-24.04-arm]

SKIP_CONFORMANCE: ${{ fromJson(steps.group.outputs.metadata).skip_conformance && '1' || '0' }}
TEST_RUSTPROOFS_LOGS: ${{ fromJson(steps.group.outputs.metadata).test_rustproofs_logs && '1' || '0' }}
FORMAT: ${{ fromJson(steps.group.outputs.metadata).format || 'standard-verbose' }}
PACKAGES: ${{ join(fromJson(steps.group.outputs.metadata).packages, ' ') }}
Copy link
Member

Choose a reason for hiding this comment

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

Got it - makes sense. I'm good to practice the right behavior here.

Should we adjust this line below to be consistent?

-- ${{ fromJson(steps.group.outputs.metadata).go_test_flags || '' }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip/changelog This change does not require CHANGELOG.md update
Projects
Status: ✔️ Approved by reviewer
Development

Successfully merging this pull request may close these issues.

Add CI runners for linux and mac arm64
3 participants