From 87232a6e2c88e13e46d3f388b9fbcbf245717d3a Mon Sep 17 00:00:00 2001 From: Martin Tournoij Date: Wed, 1 May 2024 17:47:17 +0100 Subject: [PATCH] Fix CI --- .editorconfig | 5 --- .github/ISSUE_TEMPLATE.md | 9 ---- .github/PULL_REQUEST_TEMPLATE.md | 8 ---- .github/workflows/test.yml | 70 ++++++++++++-------------------- AUTHORS | 22 ---------- LICENSE | 2 +- example/main.go | 4 +- fsevents.go | 21 +++++----- fsevents_test.go | 20 ++++----- wrap.go | 1 - wrap_test.go | 1 - 11 files changed, 47 insertions(+), 116 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .github/ISSUE_TEMPLATE.md delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 AUTHORS diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index ba49e3c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,5 +0,0 @@ -root = true - -[*] -indent_style = tab -indent_size = 4 diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index 0d76be3..0000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,9 +0,0 @@ -Before reporting an issue, please ensure you are using the latest release of fsevents. - -### Which version of macOS are you using? - -Replace this line with the output of running sw_vers on the command line. - -### Please describe the issue that occurred. - -### Are you able to reproduce the issue? Please provide steps to reproduce and a code sample if possible. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 64ddf7c..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,8 +0,0 @@ -#### What does this pull request do? - - -#### Where should the reviewer start? - - -#### How should this be manually tested? - diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ccf8613..c90776c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,55 +1,37 @@ -name: test -on: [push] +name: 'test' +on: ['push', 'pull_request'] jobs: test: strategy: fail-fast: false matrix: - os: - - macos-10.15 - - macos-latest - go: - - '1.18.0-beta1' - - '1.17' - - '1.16' + os: ['macos-12', 'macos-latest'] + go: ['1.17', '1.22'] runs-on: ${{ matrix.os }} steps: - - name: setup Go - uses: actions/setup-go@v2 + - uses: 'actions/checkout@v4' + - uses: 'actions/setup-go@v5' with: - stable: 'false' - go-version: ${{ matrix.go }} + go-version: '${{ matrix.go }}' + - name: 'test' + run: 'go test --race ./...' - - name: checkout - uses: actions/checkout@v2 - - - name: test - run: | - go test --race ./... - - lint: - runs-on: macos-latest + staticcheck: + name: 'staticcheck' + runs-on: 'macos-latest' steps: - - name: setup Go - uses: actions/setup-go@v2 - with: - go-version: '1.17' - - - name: checkout - uses: actions/checkout@v2 - - - name: gofmt - run: | - test -z "$(gofmt -s -d . | tee /dev/stderr)" - - - name: vet - run: | - go vet ./... - - - name: golangci-lint - uses: golangci/golangci-lint-action@v2 - continue-on-error: true + - uses: 'actions/checkout@v4' + - uses: 'actions/setup-go@v5' with: - version: latest - skip-go-installation: true - + go-version: '1.22' + - uses: 'actions/cache@v4' + with: + key: '${{ runner.os }}-staticcheck' + path: | + ${{ runner.temp }}/staticcheck + ${{ steps.install_go.outputs.GOCACHE || '' }} + + - run: | + export STATICCHECK_CACHE="${{ runner.temp }}/staticcheck" + go install honnef.co/go/tools/cmd/staticcheck@latest + $(go env GOPATH)/bin/staticcheck ./... diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index e5d8d72..0000000 --- a/AUTHORS +++ /dev/null @@ -1,22 +0,0 @@ -# Names should be added to this file as -# Name or Organization -# The email address is not required for organizations. - -# You can update this list using the following command: -# -# $ git shortlog -se | awk '{print $2 " " $3 " " $4}' - -# Please keep the list sorted. - -Adrian Serrano -Andrew Metcalf -Drew Wells -Jeremy Jay -Koichi Shiraishi -Lachlan Donald -Matthias Kadenbach -Nathan Youngman -Sam Jacobson -Scott Albertson -Wade Simmons -alessandrozucca diff --git a/LICENSE b/LICENSE index cb53e5f..47a2bd9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2014 The fsevents Authors. All rights reserved. +Copyright © The fsevents Authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are diff --git a/example/main.go b/example/main.go index cf56c06..ca3e079 100644 --- a/example/main.go +++ b/example/main.go @@ -1,11 +1,9 @@ //go:build darwin -// +build darwin package main import ( "bufio" - "io/ioutil" "log" "os" "runtime" @@ -15,7 +13,7 @@ import ( ) func main() { - path, err := ioutil.TempDir("", "fsexample") + path, err := os.TempDir("", "fsexample") if err != nil { log.Fatalf("Failed to create TempDir: %v", err) } diff --git a/fsevents.go b/fsevents.go index b3430aa..72ea28c 100644 --- a/fsevents.go +++ b/fsevents.go @@ -1,5 +1,4 @@ //go:build darwin -// +build darwin // Package fsevents provides file system notifications on macOS. package fsevents @@ -16,7 +15,7 @@ type Event struct { // to its device's root. // Use DeviceForPath to determine the absolute path that's // being referred to. - Path string + Path string // Flags holds details what has happened. Flags EventFlags @@ -33,7 +32,7 @@ type Event struct { // and resume processing them later from a newly-created // EventStream, this is the value you would pass for the // EventStream.EventID along with Resume=true. - ID uint64 + ID uint64 } // DeviceForPath returns the device ID for the specified volume. @@ -49,10 +48,10 @@ func DeviceForPath(path string) (int32, error) { // You can provide your own event channel if you wish (or one will be // created on Start). // -// es := &EventStream{Paths: []string{"/tmp"}, Flags: 0} -// es.Start() -// es.Stop() -// ... +// es := &EventStream{Paths: []string{"/tmp"}, Flags: 0} +// es.Start() +// es.Stop() +// ... type EventStream struct { stream fsEventStreamRef rlref cfRunLoopRef @@ -62,19 +61,19 @@ type EventStream struct { // Events holds the channel on which events will be sent. // It's initialized by EventStream.Start if nil. - Events chan []Event + Events chan []Event // Paths holds the set of paths to watch, each // specifying the root of a filesystem hierarchy to be // watched for modifications. - Paths []string + Paths []string // Flags specifies what events to receive on the stream. - Flags CreateFlags + Flags CreateFlags // Resume specifies that watching should resume from the event // specified by EventID. - Resume bool + Resume bool // EventID holds the most recent event ID. // diff --git a/fsevents_test.go b/fsevents_test.go index 3f7bc6e..23d6c5e 100644 --- a/fsevents_test.go +++ b/fsevents_test.go @@ -1,11 +1,9 @@ //go:build darwin -// +build darwin package fsevents import ( "fmt" - "io/ioutil" "os" "path/filepath" "testing" @@ -13,7 +11,7 @@ import ( ) func TestBasicExample(t *testing.T) { - path, err := ioutil.TempDir("", "fsexample") + path, err := os.TempDir("", "fsexample") if err != nil { t.Fatal(err) } @@ -52,7 +50,7 @@ func TestBasicExample(t *testing.T) { } }() - err = ioutil.WriteFile(filepath.Join(path, "example.txt"), []byte("example"), 0700) + err = os.WriteFile(filepath.Join(path, "example.txt"), []byte("example"), 0700) if err != nil { t.Fatal(err) } @@ -67,7 +65,7 @@ func TestIssue48(t *testing.T) { // FSEvents fails to start when watching >4096 paths // This test validates that limit and checks that the error is propagated - path, err := ioutil.TempDir("", "fsmanyfiles") + path, err := os.TempDir("", "fsmanyfiles") if err != nil { t.Fatal(err) } @@ -86,7 +84,7 @@ func TestIssue48(t *testing.T) { var filenames []string for i := 0; i < 4096; i++ { newFilename := filepath.Join(path, fmt.Sprint("test", i)) - err = ioutil.WriteFile(newFilename, []byte("test"), 0700) + err = os.WriteFile(newFilename, []byte("test"), 0700) if err != nil { t.Fatal(err) } @@ -118,7 +116,7 @@ func TestIssue48(t *testing.T) { }() // write some new contents to test42 in the watchlist - err = ioutil.WriteFile(filenames[42], []byte("special"), 0700) + err = os.WriteFile(filenames[42], []byte("special"), 0700) if err != nil { t.Fatal(err) } @@ -129,23 +127,23 @@ func TestIssue48(t *testing.T) { ///// // create one more file that puts it over the edge newFilename := filepath.Join(path, fmt.Sprint("test", 4096)) - err = ioutil.WriteFile(newFilename, []byte("test"), 0700) + err = os.WriteFile(newFilename, []byte("test"), 0700) if err != nil { t.Fatal(err) } filenames = append(filenames, newFilename) // create an all-new instances to avoid problems - es = &EventStream{ + es2 := &EventStream{ Paths: filenames, Latency: 500 * time.Millisecond, Device: 0, //dev, Flags: FileEvents, } - err = es.Start() + err = es2.Start() if err == nil { - es.Stop() + es2.Stop() t.Fatal("eventstream error was not detected on >4096 files in watchlist") } } diff --git a/wrap.go b/wrap.go index 29629a4..6b8fe60 100644 --- a/wrap.go +++ b/wrap.go @@ -1,5 +1,4 @@ //go:build darwin -// +build darwin package fsevents diff --git a/wrap_test.go b/wrap_test.go index 8c743aa..3ee78e3 100644 --- a/wrap_test.go +++ b/wrap_test.go @@ -1,5 +1,4 @@ //go:build darwin -// +build darwin package fsevents