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

Adding build constraints #1340

Merged
merged 2 commits into from
Apr 5, 2022
Merged

Adding build constraints #1340

merged 2 commits into from
Apr 5, 2022

Conversation

helsaawy
Copy link
Contributor

@helsaawy helsaawy commented Mar 30, 2022

Adding windows build constraints to code to allow tests and benchmarks to be run on Linux, and to limit compiler/linter/language server errors in general about code base.

Now, go test ./.. will successfully run on both Windows and Linux, and only run the appropriate tests.

Added doc.go to modules (with doc string, where appropriate) to prevent compiler/linter errors about broken imports.
(Ie, if an entire package is only available on one OS, then its import statements will error on the other OS since the compiler/language server cannot find any code to satisfy the import.)
In some cases (ie, winapi and wclayer), the package already had an OS-agnostic file of the same name, along with a doc string. A doc.go file was added to preempt situations where windows-specific code is added to that file in the future.

go-winio/pkg/guid was updated to be OS-agnostic, but until the version is updated in go.mod, then cow/cow.go, gcs/protocol.gcs, hcs/schema1/schema1.go, wclayer/wclayer.go, and winapi/devices.go are restricted to beings Windows specific.

Renamed files in test\cri-containerd to end with _test.go so they can include variables and functions defined in other _test.go. For example, gmsa.go imports gmsaAccount, which is defined in main_test.go.

PR also fixes minor linter issues with extra whitespace and misspelled words.

Signed-off-by: Hamza El-Saawy hamzaelsaawy@microsoft.com

@helsaawy helsaawy requested a review from a team as a code owner March 30, 2022 19:31
@helsaawy helsaawy marked this pull request as draft March 30, 2022 19:33
Adding windows build constraints to code to allow tests and benchmarks
to be run on Linux.

Added doc.go to modules (with doc string, where appropriate) to prevent
compiler/linter errors about broken imports.
In some cases (ie, winapi and wclayer), the package already had an
OS-agnostic file of the same name, along with a doc string. A doc.go
file was added to preempt situations where windows-specific code is
added to that file in the future.

Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
@dcantah
Copy link
Contributor

dcantah commented Mar 30, 2022

My hero 😆. Whenever this is out of draft please assign me.

Renaming files in `test\cri-containerd` to end with `_test.go` so they
can include variables and functions defined in other `_test.go`. For
example, `gmsa.go` imports `gmsaAccount`, which is defined in
`main_test.go`.

Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
@dcantah
Copy link
Contributor

dcantah commented Apr 4, 2022

This is going to take a while :)

Copy link
Contributor

@katiewasnothere katiewasnothere left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -0,0 +1,3 @@
// Package hcn is a shim for the Host Compute Networking (HCN) service, which manages networking for Windows Server
// containers and Hyper-V containers. Previous to RS5, HCN was referred to as Host Networking Service (HNS).
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Prior*

@@ -1,3 +1,5 @@
//go:build windows
Copy link
Contributor

Choose a reason for hiding this comment

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

[Not blocking this pr in anyway] I can only comment on changed lines, but @katiewasnothere it'd be worth splitting the hcn networking from the ncproxynetworking implementations into _windows and _linux files most likely (at least that's what my memory is telling me the github.com/Microsoft/hcsshim/internal/ncproxy/networking definitions were for).

We also use winio in this file as well for DialPipe, which I guess on Linux we could use a Unix domain socket instead.

Copy link
Contributor

@dcantah dcantah left a comment

Choose a reason for hiding this comment

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

lgtm. Was it just go test./.. that you wanted to unlock with this (or future work)? I think our linux specific tests just amounted to things in /internal/guest (which we run in the build_gcs CI step), unless I'm forgetting some

@helsaawy
Copy link
Contributor Author

helsaawy commented Apr 5, 2022

lgtm. Was it just go test./.. that you wanted to unlock with this (or future work)? I think our linux specific tests just amounted to things in /internal/guest (which we run in the build_gcs CI step), unless I'm forgetting some

There's actually a bunch of tests in .\ext4\internal\compactext4 that seem to consistently fail.
But it was go test ./... and getting the test/guest directories to not error and raise issues from the linter

@helsaawy helsaawy merged commit 949e46a into microsoft:master Apr 5, 2022
@helsaawy helsaawy deleted the he/lcowbench branch April 5, 2022 05:07
anmaxvl pushed a commit that referenced this pull request Feb 7, 2023
KenGordon pushed a commit to KenGordon/hcsshim that referenced this pull request May 17, 2024
This reverts commit 949e46a.

Signed-off-by: Daniel Canter <dcanter@microsoft.com>
princepereira pushed a commit to princepereira/hcsshim that referenced this pull request Aug 28, 2024
* Adding build constraints

Adding windows build constraints to code to allow tests and benchmarks
to be run on Linux.

Added doc.go to modules (with doc string, where appropriate) to prevent
compiler/linter errors about broken imports.
In some cases (ie, winapi and wclayer), the package already had an
OS-agnostic file of the same name, along with a doc string. A doc.go
file was added to preempt situations where windows-specific code is
added to that file in the future.

Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>

* Renaming test files

Renaming files in `test\cri-containerd` to end with `_test.go` so they
can include variables and functions defined in other `_test.go`. For
example, `gmsa.go` imports `gmsaAccount`, which is defined in
`main_test.go`.

Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
princepereira pushed a commit to princepereira/hcsshim that referenced this pull request Aug 29, 2024
* Adding build constraints

Adding windows build constraints to code to allow tests and benchmarks
to be run on Linux.

Added doc.go to modules (with doc string, where appropriate) to prevent
compiler/linter errors about broken imports.
In some cases (ie, winapi and wclayer), the package already had an
OS-agnostic file of the same name, along with a doc string. A doc.go
file was added to preempt situations where windows-specific code is
added to that file in the future.

Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>

* Renaming test files

Renaming files in `test\cri-containerd` to end with `_test.go` so they
can include variables and functions defined in other `_test.go`. For
example, `gmsa.go` imports `gmsaAccount`, which is defined in
`main_test.go`.

Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
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