From 55d6f36091cb5baea87c08d3faf7790c26a2d7d9 Mon Sep 17 00:00:00 2001 From: Christophe Fergeau Date: Thu, 16 May 2024 11:38:52 +0200 Subject: [PATCH 1/5] ghactions: Don't use pre-release golang 1.22 We can use 1.22.x instead Signed-off-by: Christophe Fergeau --- .github/workflows/go.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index c484837e7..0c37add0f 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false matrix: - go-version: ["1.20.x", "1.21.x", "1.22.0-rc.1"] + go-version: ["1.20.x", "1.21.x", "1.22.x"] steps: - uses: actions/checkout@v4 with: From 39f9fd75649f9f308a751968e7f501230b86d7f4 Mon Sep 17 00:00:00 2001 From: Christophe Fergeau Date: Thu, 16 May 2024 12:14:14 +0200 Subject: [PATCH 2/5] test: Rework qemuExecutable The current implementation hardcodes that the binary name is qemu-system-x86_64 on macOS, and qemu-kvm otherwise. Otherwise, on an ubuntu runner, the binary name will be qemu-system-x86_64. This commit makes use of exec.LookPath() to detect the correct binary name. Signed-off-by: Christophe Fergeau --- test/suite_test.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/suite_test.go b/test/suite_test.go index 5c08d5f12..028470d1e 100644 --- a/test/suite_test.go +++ b/test/suite_test.go @@ -150,10 +150,15 @@ outer: }) func qemuExecutable() string { - if runtime.GOOS == "darwin" { - return "qemu-system-x86_64" + qemuBinaries := []string{"qemu-kvm", "qemu-system-x86_64"} + for _, binary := range qemuBinaries { + path, err := exec.LookPath(binary) + if err == nil && path != "" { + return path + } } - return "qemu-kvm" + + return "" } func qemuArgs() string { From 42174819e3fbd9e5367fd578a08798d399934fe8 Mon Sep 17 00:00:00 2001 From: Christophe Fergeau Date: Thu, 16 May 2024 16:50:18 +0200 Subject: [PATCH 3/5] test: Always set QEMU machine type and accel This is needed when running `qemu-system-x86_64` instead of `qemu-kvm` Signed-off-by: Christophe Fergeau --- test/suite_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/suite_test.go b/test/suite_test.go index 028470d1e..d55967eee 100644 --- a/test/suite_test.go +++ b/test/suite_test.go @@ -162,10 +162,11 @@ func qemuExecutable() string { } func qemuArgs() string { + accel := "kvm" if runtime.GOOS == "darwin" { - return "-machine q35,accel=hvf:tcg -smp 4 -cpu host" + accel = "hvf" } - return "-cpu host" + return fmt.Sprintf("-machine q35,accel=%s:tcg -smp 4 -cpu host", accel) } func createSSHKeys() (string, error) { From 647723a5467a9e5089c5f1146df374e36434b598 Mon Sep 17 00:00:00 2001 From: Christophe Fergeau Date: Thu, 16 May 2024 17:33:39 +0200 Subject: [PATCH 4/5] ghactions: setup-go: Use go version from go.mod This commit changes uses of actions/setup-go to pick the go version required in go.mod. This means we'll be using the same go version everywhere, and since there is no major version hardcoded (such as '1.20.x'), this means we don't need to remember to update it once in a while. Signed-off-by: Christophe Fergeau --- .github/workflows/go.yml | 8 ++++---- .github/workflows/golangci-lint.yml | 5 ++--- .github/workflows/release.yml | 2 ++ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 0c37add0f..9933d91ec 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -52,7 +52,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.20.x + go-version-file: 'go.mod' - name: Test run: make test @@ -72,12 +72,12 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.20.x + go-version-file: 'go.mod' - - name: Build + - name: Build run: make win-sshproxy - - name: Test + - name: Test run: go test -v .\test-win-sshproxy diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index d48f12e9a..86964a972 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -11,11 +11,10 @@ jobs: name: lint runs-on: ubuntu-latest steps: + - uses: actions/checkout@v4 - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.20.x - - - uses: actions/checkout@v4 + go-version-file: 'go.mod' - name: golangci-lint uses: golangci/golangci-lint-action@v6 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fa14d1add..b83b0d0e2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,6 +25,8 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' - name: Build run: | From 923f48c447d188604523b2ba399df6059d00c9b2 Mon Sep 17 00:00:00 2001 From: Christophe Fergeau Date: Thu, 16 May 2024 11:39:18 +0200 Subject: [PATCH 5/5] ghactions: Use ubuntu runner for tests M1 macos runners can't build our test code, and the M1 runners don't support nested virt, which is required by `make test` Since I expect in the future the x86_64 macos runners to go away, and since the ubuntu runners now support nested virt, this commit uses an ubuntu runner to run `make test`. This fixes https://github.com/containers/gvisor-tap-vsock/issues/358 Signed-off-by: Christophe Fergeau --- .github/workflows/go.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 9933d91ec..18fe992eb 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -38,16 +38,16 @@ jobs: path: bin/* tests: - runs-on: macos-latest # Only Mac runners support nested virt + runs-on: ubuntu-latest # The runner must support nested virt needs: build # Don't bother testing if cross arch build fails timeout-minutes: 30 steps: - uses: actions/checkout@v4 - - name: Install + - name: Install qemu run: | - brew install qemu - touch continue + sudo apt install qemu-kvm + sudo usermod -a -G kvm $USER - name: Set up Go uses: actions/setup-go@v5 @@ -55,7 +55,8 @@ jobs: go-version-file: 'go.mod' - name: Test - run: make test + run: | + sudo -s -u ${USER} bash -c 'make test' - uses: actions/upload-artifact@v4 if: always()