]> go.fuhry.dev Git - fsnotify.git/commitdiff
Test some more things in CI (#469)
authorMartin Tournoij <martin@arp242.net>
Sun, 24 Jul 2022 09:22:52 +0000 (11:22 +0200)
committerGitHub <noreply@github.com>
Sun, 24 Jul 2022 09:22:52 +0000 (11:22 +0200)
* Test some more things in CI

- Test all GOOS/GOARCH combinations by looping over "go tool dist list";
this just tests if it compiles.

- Add a Vagrant box to test Debian 6 / Linux 2.6.32; this was adapted
from @horahoradev's patch at #434.

- Update the minimum version requirements: we test Linux 2.6.32 now and
  turns out that's also the minimum version [Go supports] in recent
  releases, so just set it to that.

  Need Go 1.16 for retract in go.mod. I don't know, maybe we can just
  remove the retract? Latest Debian ships with Go 1.15.

  [Go supports]: https://github.com/golang/go/issues/45964

- Test both Go 1.16 and 1.18 (the lowest supported version and newest
  version). I guess we could also test 1.17, but the CI already takes
  somewhat long and I can't recall ever having a situation where an
  intermediate version failed.

- Test macOS 11 and 12; macOS 10.15 will (probably) end support in
  November, so probably not worth supporting this. GitHub will [remove]
  support for this at the end of August.

  [remove]: https://github.blog/changelog/2022-07-20-github-actions-the-macos-10-15-actions-runner-image-is-being-deprecated-and-will-be-removed-by-8-30-22/

- Test OpenBSD, NetBSD.

- Move "lint" to its own YAML file.

Future work:

- Actually run tests for all systems Go supports. Bit pointless right
  now as many of these don't do anything. Currently untested are
  Solaris, illumios, plan9, AIX, Android, iOS, DragonflyBSD, WASM.

  Some of these might be difficult (AIX, iOS, Android), but haven't
  looked in to it. I tried setting up Solaris with the
  vmactions/solaris, but it doesn't seem to have an easy way to install
  Go.

- GitHub only [supports] Windows Server 2019 and 2022; probabably also
  want to test Server 2016, but GitHub dropped support for this. Can
  maybe use AppVeyor(?)

  [supports]: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#choosing-github-hosted-runners

- Could maybe test older versions of BSD, too. Not sure of it's worth
  it.

* Skip TestFsnotifyMultipleOperations on NetBSD

This test doesn't seem to work; I'm sure it passed at least once in the
CI, but locally I can't seem to get it to work.

Fails with:

=== RUN   TestFsnotifyMultipleOperations
     integration_test.go:114: event received: "/tmp/fsnotify2194826986/TestFsnotifySeq.testfile": CREATE
     integration_test.go:114: event received: "/tmp/fsnotify2194826986/TestFsnotifySeq.testfile": WRITE
     integration_test.go:114: event received: "/tmp/fsnotify2194826986/TestFsnotifySeq.testfile": REMOVE|RENAME
     integration_test.go:114: event received: "/tmp/fsnotify2194826986/TestFsnotifySeq.testfile": CREATE
     integration_test.go:186: incorrect number of rename+delete events received after 500 ms (2 vs 1)
     integration_test.go:114: event received: "/tmp/fsnotify2194826986/TestFsnotifySeq.testfile": REMOVE
     integration_test.go:114: event received: "/tmp/fsnotify2194826986": REMOVE|WRITE

For reference, this is the output on Linux and OpenBSD (the output is
identical):

=== RUN   TestFsnotifyMultipleOperations
     integration_test.go:114: event received: "/tmp/fsnotify989736723/TestFsnotifySeq.testfile": CREATE
     integration_test.go:114: event received: "/tmp/fsnotify989736723/TestFsnotifySeq.testfile": WRITE
     integration_test.go:114: event received: "/tmp/fsnotify989736723/TestFsnotifySeq.testfile": RENAME
     integration_test.go:114: event received: "/tmp/fsnotify989736723/TestFsnotifySeq.testfile": CREATE
     integration_test.go:190: calling Close()
     integration_test.go:192: waiting for the event channel to become closed...
     integration_test.go:195: event channel closed

* Fix "too many open files" on Debian 6, maybe

I guess this started failing after I rebased on main; let's see if a
small sleep works to clean up the file descriptors.

.github/workflows/Vagrantfile.debian6 [new file with mode: 0644]
.github/workflows/build.yml
.github/workflows/lint.yml [new file with mode: 0644]
.github/workflows/test.yml
.github/workflows/vagrant.yml [new file with mode: 0644]
README.md
integration_test.go

diff --git a/.github/workflows/Vagrantfile.debian6 b/.github/workflows/Vagrantfile.debian6
new file mode 100644 (file)
index 0000000..fbe8f08
--- /dev/null
@@ -0,0 +1,6 @@
+Vagrant.configure("2") do |config|
+  config.vm.box = "threatstack/debian6"
+  config.vm.box_version = "1.0.0"
+
+  config.vm.define 'debian6'
+end 
index b595c7e905b547c3225003cd7538b975e70d6f91..0d004c1c3d5b4d4cea28aafb3811adfedea547aa 100644 (file)
@@ -7,26 +7,21 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        goos:
-          - android
-          - darwin
-          - freebsd
-          - ios
-          - linux
-          - windows
-        goarch:
-          - amd64
-          - arm64
+        go:
+          - '1.16'
+          - '1.18'
     runs-on: ubuntu-latest
     steps:
       - name: setup Go
         uses: actions/setup-go@v3
         with:
-          go-version: '1.18'
+          go-version: ${{ matrix.go }}
 
       - name: checkout
         uses: actions/checkout@v3
 
-      - name: build-${{ matrix.goos }}-${{ matrix.goarch }}
+      - name: build
         run: |
-          GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build
+          for a in $(go tool dist list); do
+            GOOS=${a%%/*} GOARCH=${a#*/} go build
+          done
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
new file mode 100644 (file)
index 0000000..5df6527
--- /dev/null
@@ -0,0 +1,30 @@
+name: test
+on:
+  push:
+  pull_request:
+jobs:
+  lint:
+    runs-on: ubuntu-latest
+    steps:
+      - name: setup Go
+        uses: actions/setup-go@v3
+        with:
+          go-version: '1.18'
+
+      - name: checkout
+        uses: actions/checkout@v3
+
+      - name: gofmt
+        run: |
+          test -z "$(gofmt -s -d . | tee /dev/stderr)"
+
+      - name: vet
+        run: |
+          go vet ./...
+
+      - name: golangci-lint
+        uses: golangci/golangci-lint-action@v3
+        continue-on-error: true
+        with:
+          version: latest
+          skip-go-installation: true
index 94cc2c30e3c865fd533cffb3e688a8e961ee0ded..d6fa966106c8012ef73d3f546ede8117491296f9 100644 (file)
@@ -9,12 +9,12 @@ jobs:
       matrix:
         os:
           - ubuntu-latest
-          - macos-latest
+          - macos-11
+          - macos-12
           - windows-latest
         go:
-          - '1.18'
-          - '1.17'
           - '1.16'
+          - '1.18'
     runs-on: ${{ matrix.os }}
     steps:
       - name: setup Go
@@ -27,10 +27,10 @@ jobs:
 
       - name: test
         run: |
-          go test --race ./...
+          go test -race ./...
 
   testFreeBSD:
-    runs-on: macos-10.15
+    runs-on: macos-12
     name: test (freebsd, 1.18)
     steps:
       - uses: actions/checkout@v3
@@ -41,30 +41,41 @@ jobs:
           usesh: true
           prepare: pkg install -y go
           run: |
-            go test
+            go test -race ./...
 
-  lint:
-    runs-on: ubuntu-latest
+  testOpenBSD:
+    runs-on: macos-12
+    name: test (openbsd, 1.17)
     steps:
-      - name: setup Go
-        uses: actions/setup-go@v3
+      - uses: actions/checkout@v3
+      - name: test (openbsd, 1.17)
+        id: test
+        uses: vmactions/openbsd-vm@v0.0.6
         with:
-          go-version: '1.18'
-
-      - name: checkout
-        uses: actions/checkout@v3
-
-      - name: gofmt
-        run: |
-          test -z "$(gofmt -s -d . | tee /dev/stderr)"
+          prepare: pkg_add go
+          run: |
+            # Default of 512 leads to "too many open files".
+            ulimit -n 1024
 
-      - name: vet
-        run: |
-          go vet ./...
+            # No -race as the VM doesn't include the comp set.
+            #
+            # TODO: should probably add this, but on my local machine the tests
+            #       time out with -race as the waits aren't long enough (OpenBSD
+            #       is kind of slow), so should probably look into that first.
+            #       Go 1.19 is supposed to have a much faster race detector, so
+            #       maybe waiting until we have that is enough.
+            go test ./...
 
-      - name: golangci-lint
-        uses: golangci/golangci-lint-action@v3
-        continue-on-error: true
+  testNetBSD:
+    runs-on: macos-12
+    name: test (netbsd, 1.17)
+    steps:
+      - uses: actions/checkout@v3
+      - name: test (netbsd, 1.17)
+        id: test
+        uses: vmactions/netbsd-vm@v0.0.4
         with:
-          version: latest
-          skip-go-installation: true
+          prepare: pkg_add go
+          run: |
+            # TODO: no -race for the same reason as OpenBSD (the timing; it does run).
+            go117 test ./...
diff --git a/.github/workflows/vagrant.yml b/.github/workflows/vagrant.yml
new file mode 100644 (file)
index 0000000..0b63f05
--- /dev/null
@@ -0,0 +1,26 @@
+name: vagrant
+on:
+  push:
+  pull_request:
+jobs:
+  test:
+    strategy:
+      fail-fast: false
+      matrix:
+        image:
+          - debian6
+    runs-on: macos-12
+    steps:
+      - uses: actions/checkout@v3
+
+      - name: setup Go
+        uses: actions/setup-go@v3
+        with:
+          go-version: '1.18'
+
+      - name: test
+        run: |
+          cp -f .github/workflows/Vagrantfile.${{ matrix.image }} Vagrantfile
+          GOOS=linux GOARCH=amd64 go test -o fsnotify.test -c ./...
+          vagrant up
+          vagrant ssh -c "/vagrant/fsnotify.test"
index 1991381a897b065024cf88ec1a7020e01144feb2..01de753b3f363a8ac6685fdfff7d457f4da1b6b3 100644 (file)
--- a/README.md
+++ b/README.md
@@ -6,22 +6,26 @@
 
 `fsnotify` supports Windows, Linux, BSD and macOS with a common API.
 
-| Adapter               | OS                               | Status                                                                                                                          |
-| --------------------- | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
-| inotify               | Linux 2.6.27 or later, Android\* | Supported |
-| kqueue                | BSD, macOS, iOS\*                | Supported |
-| ReadDirectoryChangesW | Windows                          | Supported |
-| FSEvents              | macOS                            | [Planned](https://github.com/fsnotify/fsnotify/issues/11)                                                                       |
-| FEN                   | Solaris 11                       | [In Progress](https://github.com/fsnotify/fsnotify/pull/371)                                                                   |
-| fanotify              | Linux 2.6.37+                    | [Maybe](https://github.com/fsnotify/fsnotify/issues/114)                                                                      |
-| USN Journals          | Windows                          | [Maybe](https://github.com/fsnotify/fsnotify/issues/53)                                                                         |
-| Polling               | *All*                            | [Maybe](https://github.com/fsnotify/fsnotify/issues/9)                                                                          |
+| Adapter               | OS                       | Status                                                       |
+| --------------------- | -------------------------| -------------------------------------------------------------|
+| inotify               | Linux 2.6.32+, Android\* | Supported                                                    |
+| kqueue                | BSD, macOS, iOS\*        | Supported                                                    |
+| ReadDirectoryChangesW | Windows                  | Supported                                                    |
+| FSEvents              | macOS                    | [Planned](https://github.com/fsnotify/fsnotify/issues/11)    |
+| FEN                   | Solaris 11               | [In Progress](https://github.com/fsnotify/fsnotify/pull/371) |
+| fanotify              | Linux 2.6.37+            | [Maybe](https://github.com/fsnotify/fsnotify/issues/114)     |
+| USN Journals          | Windows                  | [Maybe](https://github.com/fsnotify/fsnotify/issues/53)      |
+| Polling               | *All*                    | [Maybe](https://github.com/fsnotify/fsnotify/issues/9)       |
 
 \* Android and iOS are untested.
 
-Please see [the documentation](https://pkg.go.dev/github.com/fsnotify/fsnotify) and consult the [FAQ](#faq) for usage information.
+fsnotify requires Go 1.16 or newer. Please see
+[the documentation](https://pkg.go.dev/github.com/fsnotify/fsnotify)
+and consult the [FAQ](#faq) for usage information.
 
-NOTE: fsnotify utilizes [`golang.org/x/sys`](https://pkg.go.dev/golang.org/x/sys) rather than [`syscall`](https://pkg.go.dev/syscall) from the standard library.
+NOTE: fsnotify utilizes
+[`golang.org/x/sys`](https://pkg.go.dev/golang.org/x/sys) rather than
+[`syscall`](https://pkg.go.dev/syscall) from the standard library.
 
 ## API stability
 
index fefae5ea3b7529cd4f5c7d059a40538bd9183d43..c4e1d3e68ecb87f5335d8955009a6f510eb12ef5 100644 (file)
@@ -14,6 +14,7 @@ import (
        "path"
        "path/filepath"
        "runtime"
+       "strings"
        "sync"
        "sync/atomic"
        "testing"
@@ -78,6 +79,10 @@ func addWatch(t *testing.T, watcher *Watcher, dir string) {
 }
 
 func TestFsnotifyMultipleOperations(t *testing.T) {
+       if runtime.GOOS == "netbsd" {
+               t.Skip("NetBSD behaviour is not fully correct") // TODO: investigate and fix.
+       }
+
        watcher := newWatcher(t)
 
        // Receive errors on the error channel on a separate goroutine
@@ -1251,6 +1256,10 @@ func TestCloseRace(t *testing.T) {
        for i := 0; i < 150; i++ {
                w, err := NewWatcher()
                if err != nil {
+                       if strings.Contains(err.Error(), "too many") { // syscall.EMFILE
+                               time.Sleep(100 * time.Millisecond)
+                               continue
+                       }
                        t.Fatal(err)
                }
                go w.Close()