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

Add GitHub actions for test and linting #62

Merged
merged 2 commits into from
Jan 18, 2023

Conversation

thaJeztah
Copy link
Contributor

No description provided.

@thaJeztah thaJeztah changed the title [testing] Add GitHub actions for test and linting Add GitHub actions for test and linting Jan 13, 2023
@thaJeztah thaJeztah force-pushed the enable_gha branch 4 times, most recently from c7fbc03 to 6a4e2bc Compare January 13, 2023 16:48
.github/workflows/validate.yml Outdated Show resolved Hide resolved
.github/workflows/validate.yml Outdated Show resolved Hide resolved
.github/workflows/test.yml Outdated Show resolved Hide resolved
@thaJeztah thaJeztah marked this pull request as ready for review January 13, 2023 16:51
@thaJeztah
Copy link
Contributor Author

@jeffwidman @dims @pacoxu @aboch PTAL

Copy link
Collaborator

@jeffwidman jeffwidman left a comment

Choose a reason for hiding this comment

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

Thanks!

.github/workflows/test.yml Outdated Show resolved Hide resolved
.github/workflows/validate.yml Outdated Show resolved Hide resolved
.github/workflows/validate.yml Outdated Show resolved Hide resolved
@jeffwidman
Copy link
Collaborator

Since this adds github actions that are versioned, we should probably also add a stanza to https://github.com/vishvananda/netns/blob/master/.github/dependabot.yml to monitor/bump the actions.

Feel free to include as part of this PR (albeit in a separate commit), but if you're not sure how to do that, I can handle it in a separate PR.

@thaJeztah
Copy link
Contributor Author

Ah, interesting; looks like go1.12 is actually an issue with the updated golang.org/x/sys.

Error: ../../../go/pkg/mod/golang.org/x/sys@v0.2.0/unix/syscall.go:83:16: undefined: unsafe.Slice
Error: ../../../go/pkg/mod/golang.org/x/sys@v0.2.0/unix/syscall_linux.go:2256:9: undefined: unsafe.Slice
Error: ../../../go/pkg/mod/golang.org/x/sys@v0.2.0/unix/syscall_unix.go:118:7: undefined: unsafe.Slice
Error: ../../../go/pkg/mod/golang.org/x/sys@v0.2.0/unix/sysvshm_unix.go:33:7: undefined: unsafe.Slice

Maybe it's time now to update to something newer (I think I saw some projects are still on go1.15, let me try if that works)

@thaJeztah thaJeztah force-pushed the enable_gha branch 2 times, most recently from b178c5d to 54471b1 Compare January 13, 2023 19:34
@thaJeztah
Copy link
Contributor Author

I opened #64 to update the minimum go version 👍 (I'll rebase this PR once that's merged to remove the extra commit; CI is happy on thaJeztah#1)

@thaJeztah
Copy link
Contributor Author

Alright; rebased; this one should be ready for review (thaJeztah#1 is still happy)

@thaJeztah
Copy link
Contributor Author

Feel free to include as part of this PR (albeit in a separate commit), but if you're not sure how to do that, I can handle it in a separate PR.

Oh! I forgot about that one; I'd have to look up how to set that up, so if you have time to handle that, that'd be appreciated 🤗 ❤️

Copy link
Collaborator

@jeffwidman jeffwidman left a comment

Choose a reason for hiding this comment

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

A few small suggestions/questions

# using newer versions than that, so we can drop the old version if
# it becomes too much of a burden.
go-version: [1.17.x, 1.19.x]
os: [ubuntu-20.04, ubuntu-22.04]
Copy link
Collaborator

@jeffwidman jeffwidman Jan 16, 2023

Choose a reason for hiding this comment

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

Should we also test on windows? To ensure no runtime errors in the future?

I realize today there's no tests that will run on windows, but still seems best to set it in the matrix proactively for if/when there might be some down the road... it'll also catch compile errors even w/o any tests I think??

# currently not much of a burden. Most projects using this module are
# using newer versions than that, so we can drop the old version if
# it becomes too much of a burden.
go-version: [1.17.x, 1.19.x]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
go-version: [1.17.x, 1.19.x]
go-version: [1.17.x, 'stable']

This lets us always default to the latest release: https://github.com/actions/setup-go#using-stableoldstable-aliases

Given the extremely low activity on this repo, I'd much rather use stable than having to bump the pins, because we're more likely to catch issues that way...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Interestingly, they also support picking up the version from go.mod, but doesn't like like it's possibly to cleanly do this as part of a matrix: https://github.com/actions/setup-go#getting-go-version-from-the-gomod-file

matrix:
# We only run on the latest version of go, as some linters may be
# version-dependent (for example gofmt can change between releases).
go-version: [1.19.x]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
go-version: [1.19.x]
go-version: ['stable']

Again, I realize it's non-deterministic, but I think for this particular repo it's probably the better way to go...

@jeffwidman
Copy link
Collaborator

jeffwidman commented Jan 16, 2023

Feel free to include as part of this PR (albeit in a separate commit), but if you're not sure how to do that, I can handle it in a separate PR.

Oh! I forgot about that one; I'd have to look up how to set that up, so if you have time to handle that, that'd be appreciated 🤗 ❤️

Handled in:

@jeffwidman
Copy link
Collaborator

jeffwidman commented Jan 18, 2023

@thaJeztah I left some minor feedback, I know we're both involved with a lot of projects, so any chance of getting this across the line while it's still fresh in our minds?

@thaJeztah
Copy link
Contributor Author

Doh! Saw your comments, and then forgot about them. Thanks for the ping; yes, let me look at those 👍

Test against the "oldest" supported version and the current version
of go. Go 1.17 is kept in this matrix as it is the minimum version
specified in go.mod, and maintaining compatibility with go 1.17 is
currently not much of a burden. Most projects using this module are
using newer versions than that, so we can drop the old version if
it becomes too much of a burden.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Linting is disabled on Windows, as the current build-tags do not
properly exclude non-unix platforms;

    level=info msg="[runner/filename_unadjuster] Pre-built 0 adjustments in 1.0348ms"
    Error: level=error msg="[linters_context] typechecking error: D:\\a\\netns\\netns\\netns.go:28:18: Stat_t not declared by package unix"
    Error: level=error msg="[linters_context] typechecking error: D:\\a\\netns\\netns\\netns.go:29:17: Fstat not declared by package unix"
    Error: level=error msg="[linters_context] typechecking error: D:\\a\\netns\\netns\\netns.go:32:17: Fstat not declared by package unix"
    Error: level=error msg="[linters_context] typechecking error: D:\\a\\netns\\netns\\netns.go:43:13: Stat_t not declared by package unix"
    Error: level=error msg="[linters_context] typechecking error: D:\\a\\netns\\netns\\netns.go:44:17: Fstat not declared by package unix"
    Error: level=error msg="[linters_context] typechecking error: D:\\a\\netns\\netns\\netns.go:56:13: Stat_t not declared by package unix"
    Error: level=error msg="[linters_context] typechecking error: D:\\a\\netns\\netns\\netns.go:57:17: Fstat not declared by package unix"
    Error: level=error msg="[linters_context] typechecking error: D:\\a\\netns\\netns\\netns.go:71:17: Close not declared by package unix"

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
git diff --exit-code
- name: Test
run: |
go test -exec "sudo -n" -v ./...
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm. Somewhat surprised this worked on Windows (with the sudo), but perhaps because there's currently no tests. Looks like Ci is happy (thaJeztah#1), so worst case, it'll explode if we would add non-linux tests 😂

@thaJeztah
Copy link
Contributor Author

Okay; updated. I think this should be ready for another review 👍

Copy link
Collaborator

@jeffwidman jeffwidman left a comment

Choose a reason for hiding this comment

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

Looks great, thanks!

@jeffwidman jeffwidman merged commit 1104d96 into vishvananda:master Jan 18, 2023
@thaJeztah
Copy link
Contributor Author

Thanks!

@thaJeztah thaJeztah deleted the enable_gha branch January 18, 2023 22:27
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.

3 participants