Merge pull request #2 from bnema/ci-fix
ci: run checks in an Arch container, once per change
3 files · +44 -9
M .github/workflows/ci.yml +29 -7
| @@ -1,17 +1,39 @@ | |||
| 1 | 1 | name: CI | |
| 2 | - | on: [push, pull_request] | |
| 2 | + | on: | |
| 3 | + | push: | |
| 4 | + | branches: [main] | |
| 5 | + | pull_request: | |
| 6 | + | concurrency: | |
| 7 | + | group: ci-${{ github.ref }} | |
| 8 | + | cancel-in-progress: true | |
| 3 | 9 | jobs: | |
| 10 | + | # Arch matches the development system: libwayland, glslc and Go versions | |
| 11 | + | # change protocol behavior and SPIR-V bytes. | |
| 4 | 12 | check: | |
| 5 | 13 | runs-on: ubuntu-latest | |
| 14 | + | container: | |
| 15 | + | image: archlinux:latest | |
| 16 | + | # An init process reaps killed children, as on a real session. | |
| 17 | + | options: --init | |
| 18 | + | env: | |
| 19 | + | XDG_RUNTIME_DIR: /tmp/xdg-runtime | |
| 6 | 20 | steps: | |
| 21 | + | # Libraries loaded at runtime through purego; vulkan-swrast (lavapipe) | |
| 22 | + | # gives tests a Vulkan device; gcc is for the race detector. | |
| 23 | + | - run: >- | |
| 24 | + | pacman -Syu --noconfirm --needed | |
| 25 | + | git go make gcc shaderc wayland libxkbcommon libinput seatd | |
| 26 | + | vulkan-icd-loader vulkan-swrast | |
| 7 | 27 | - uses: actions/checkout@v4 | |
| 8 | - | - uses: actions/setup-go@v5 | |
| 9 | - | with: | |
| 10 | - | go-version: '1.27' | |
| 11 | - | - run: go install github.com/bnema/hexcheck@latest | |
| 12 | - | - run: go install github.com/vektra/mockery/v3@v3.8.0 | |
| 28 | + | - run: | | |
| 29 | + | git config --global --add safe.directory "$GITHUB_WORKSPACE" | |
| 30 | + | install -d -m 700 "$XDG_RUNTIME_DIR" | |
| 31 | + | - run: | | |
| 32 | + | go install github.com/bnema/hexcheck/cmd/hexcheck@v0.2.0 | |
| 33 | + | go install github.com/vektra/mockery/v3@v3.8.0 | |
| 34 | + | go install honnef.co/go/tools/cmd/staticcheck@latest | |
| 13 | 35 | - run: make check | |
| 14 | 36 | - run: make race | |
| 15 | 37 | - run: make mocks-check | |
| 16 | - | - run: sudo apt-get install -y glslc | |
| 17 | 38 | - run: make spv-check | |
| 39 | + | - run: ~/go/bin/staticcheck ./... | |
| @@ -1,17 +1,39 @@ | |||||
| 1 | name: CI | 1 | name: CI | ||
| 2 | - | on: [push, pull_request] | 2 | + | on: |
| 3 | + | push: | |||
| 4 | + | branches: [main] | |||
| 5 | + | pull_request: | |||
| 6 | + | concurrency: | |||
| 7 | + | group: ci-${{ github.ref }} | |||
| 8 | + | cancel-in-progress: true | |||
| 3 | jobs: | 9 | jobs: | ||
| 10 | + | # Arch matches the development system: libwayland, glslc and Go versions | |||
| 11 | + | # change protocol behavior and SPIR-V bytes. | |||
| 4 | check: | 12 | check: | ||
| 5 | runs-on: ubuntu-latest | 13 | runs-on: ubuntu-latest | ||
| 14 | + | container: | |||
| 15 | + | image: archlinux:latest | |||
| 16 | + | # An init process reaps killed children, as on a real session. | |||
| 17 | + | options: --init | |||
| 18 | + | env: | |||
| 19 | + | XDG_RUNTIME_DIR: /tmp/xdg-runtime | |||
| 6 | steps: | 20 | steps: | ||
| 21 | + | # Libraries loaded at runtime through purego; vulkan-swrast (lavapipe) | |||
| 22 | + | # gives tests a Vulkan device; gcc is for the race detector. | |||
| 23 | + | - run: >- | |||
| 24 | + | pacman -Syu --noconfirm --needed | |||
| 25 | + | git go make gcc shaderc wayland libxkbcommon libinput seatd | |||
| 26 | + | vulkan-icd-loader vulkan-swrast | |||
| 7 | - uses: actions/checkout@v4 | 27 | - uses: actions/checkout@v4 | ||
| 8 | - | - uses: actions/setup-go@v5 | 28 | + | - run: | |
| 9 | - | with: | 29 | + | git config --global --add safe.directory "$GITHUB_WORKSPACE" |
| 10 | - | go-version: '1.27' | 30 | + | install -d -m 700 "$XDG_RUNTIME_DIR" |
| 11 | - | - run: go install github.com/bnema/hexcheck@latest | 31 | + | - run: | |
| 12 | - | - run: go install github.com/vektra/mockery/v3@v3.8.0 | 32 | + | go install github.com/bnema/hexcheck/cmd/hexcheck@v0.2.0 |
| 33 | + | go install github.com/vektra/mockery/v3@v3.8.0 | |||
| 34 | + | go install honnef.co/go/tools/cmd/staticcheck@latest | |||
| 13 | - run: make check | 35 | - run: make check | ||
| 14 | - run: make race | 36 | - run: make race | ||
| 15 | - run: make mocks-check | 37 | - run: make mocks-check | ||
| 16 | - | - run: sudo apt-get install -y glslc | |||
| 17 | - run: make spv-check | 38 | - run: make spv-check | ||
| 39 | + | - run: ~/go/bin/staticcheck ./... | |||
M internal/adapters/wayland/clipboard_test.go +9 -1
| @@ -1,6 +1,7 @@ | |||
| 1 | 1 | package wayland | |
| 2 | 2 | ||
| 3 | 3 | import ( | |
| 4 | + | "errors" | |
| 4 | 5 | "testing" | |
| 5 | 6 | "time" | |
| 6 | 7 | ||
| @@ -180,7 +181,14 @@ func TestClipboardFollowsFocus(t *testing.T) { | |||
| 180 | 181 | } | |
| 181 | 182 | } | |
| 182 | 183 | buf := make([]byte, 16) | |
| 183 | - | n, _ := unix.Read(fds[0], buf) | |
| 184 | + | // Go runtime signals (preemption) can interrupt the raw read: retry. | |
| 185 | + | n, err := unix.Read(fds[0], buf) | |
| 186 | + | for errors.Is(err, unix.EINTR) { | |
| 187 | + | n, err = unix.Read(fds[0], buf) | |
| 188 | + | } | |
| 189 | + | if err != nil { | |
| 190 | + | t.Fatal(err) | |
| 191 | + | } | |
| 184 | 192 | if string(buf[:n]) != "pasted" { | |
| 185 | 193 | t.Fatalf("pasted %q", buf[:n]) | |
| 186 | 194 | } | |
| @@ -1,6 +1,7 @@ | |||||
| 1 | package wayland | 1 | package wayland | ||
| 2 | 2 | ||||
| 3 | import ( | 3 | import ( | ||
| 4 | + | "errors" | |||
| 4 | "testing" | 5 | "testing" | ||
| 5 | "time" | 6 | "time" | ||
| 6 | 7 | ||||
| @@ -180,7 +181,14 @@ func TestClipboardFollowsFocus(t *testing.T) { | |||||
| 180 | } | 181 | } | ||
| 181 | } | 182 | } | ||
| 182 | buf := make([]byte, 16) | 183 | buf := make([]byte, 16) | ||
| 183 | - | n, _ := unix.Read(fds[0], buf) | 184 | + | // Go runtime signals (preemption) can interrupt the raw read: retry. |
| 185 | + | n, err := unix.Read(fds[0], buf) | |||
| 186 | + | for errors.Is(err, unix.EINTR) { | |||
| 187 | + | n, err = unix.Read(fds[0], buf) | |||
| 188 | + | } | |||
| 189 | + | if err != nil { | |||
| 190 | + | t.Fatal(err) | |||
| 191 | + | } | |||
| 184 | if string(buf[:n]) != "pasted" { | 192 | if string(buf[:n]) != "pasted" { | ||
| 185 | t.Fatalf("pasted %q", buf[:n]) | 193 | t.Fatalf("pasted %q", buf[:n]) | ||
| 186 | } | 194 | } | ||
M internal/adapters/xwayland/xwayland_test.go +6 -1
| @@ -80,7 +80,12 @@ func TestRunDropsClientsOfFailedSatellite(t *testing.T) { | |||
| 80 | 80 | if err := unix.SetsockoptTimeval(fd, unix.SOL_SOCKET, unix.SO_RCVTIMEO, &unix.Timeval{Sec: 3}); err != nil { | |
| 81 | 81 | t.Fatal(err) | |
| 82 | 82 | } | |
| 83 | - | if n, err := unix.Read(fd, make([]byte, 1)); n != 0 || err != nil { | |
| 83 | + | // Go runtime signals (preemption) can interrupt the raw read: retry. | |
| 84 | + | n, err := unix.Read(fd, make([]byte, 1)) | |
| 85 | + | for errors.Is(err, unix.EINTR) { | |
| 86 | + | n, err = unix.Read(fd, make([]byte, 1)) | |
| 87 | + | } | |
| 88 | + | if n != 0 || err != nil { | |
| 84 | 89 | t.Fatalf("read %d %v, want EOF", n, err) | |
| 85 | 90 | } | |
| 86 | 91 | cancel() | |
| @@ -80,7 +80,12 @@ func TestRunDropsClientsOfFailedSatellite(t *testing.T) { | |||||
| 80 | if err := unix.SetsockoptTimeval(fd, unix.SOL_SOCKET, unix.SO_RCVTIMEO, &unix.Timeval{Sec: 3}); err != nil { | 80 | if err := unix.SetsockoptTimeval(fd, unix.SOL_SOCKET, unix.SO_RCVTIMEO, &unix.Timeval{Sec: 3}); err != nil { | ||
| 81 | t.Fatal(err) | 81 | t.Fatal(err) | ||
| 82 | } | 82 | } | ||
| 83 | - | if n, err := unix.Read(fd, make([]byte, 1)); n != 0 || err != nil { | 83 | + | // Go runtime signals (preemption) can interrupt the raw read: retry. |
| 84 | + | n, err := unix.Read(fd, make([]byte, 1)) | |||
| 85 | + | for errors.Is(err, unix.EINTR) { | |||
| 86 | + | n, err = unix.Read(fd, make([]byte, 1)) | |||
| 87 | + | } | |||
| 88 | + | if n != 0 || err != nil { | |||
| 84 | t.Fatalf("read %d %v, want EOF", n, err) | 89 | t.Fatalf("read %d %v, want EOF", n, err) | ||
| 85 | } | 90 | } | ||
| 86 | cancel() | 91 | cancel() | ||