diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a71158bc5..b0d3820eb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,8 +22,22 @@ jobs: cache: true - name: Test run: make test-ci + - name: Determine skip-codecov + id: skip-codecov + with: + script: | + const { repo, owner } = context.repo; + const { data: commit } = await github.rest.repos.getCommit({ + owner, + repo, + ref: '${{ github.event.pull_request.head.sha || github.event.after }}' + }); + const commitMesasge = commit.commit.message; + const skip = commitMessage.includes("[skip codecov]") || commitMessage.includes("[skip-codecov]"); + core.setOutput("skip", skip); - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 + if: steps.skip-codecov.outputs.skip != "true" with: file: covreport env: diff --git a/internal/filenotify/filenotify.go b/internal/filenotify/filenotify.go index 1a9bf4c5f..68527367a 100644 --- a/internal/filenotify/filenotify.go +++ b/internal/filenotify/filenotify.go @@ -48,10 +48,12 @@ func NewPollingWatcher(cfg Config) (FileWatcher, error) { wr: watcher.New(), events: make(chan fsnotify.Event), errors: make(chan error), + done: make(chan struct{}), } poller.wr.FilterOps(watcher.Create, watcher.Rename, watcher.Move) go poller.loop() + // Block until radovskyb's watcher is started. done := make(chan error) { go func() { diff --git a/internal/filenotify/poller.go b/internal/filenotify/poller.go index 9470d3ff5..6a4b78fd9 100644 --- a/internal/filenotify/poller.go +++ b/internal/filenotify/poller.go @@ -1,6 +1,9 @@ package filenotify import ( + "errors" + "time" + "github.com/fsnotify/fsnotify" "github.com/radovskyb/watcher" ) @@ -16,6 +19,9 @@ type filePoller struct { // errors is the channel to listen to for watch errors. errors chan error + + // done signals that the loop is done when the channel is closed. + done chan struct{} } // loop captures and transform radovskyb's watcher into fsnotify events. @@ -43,6 +49,7 @@ func (w *filePoller) loop() { case err := <-w.wr.Error: w.errors <- err case <-w.wr.Closed: + close(w.done) return } } @@ -70,5 +77,10 @@ func (w *filePoller) Errors() <-chan error { func (w *filePoller) Close() error { w.wr.Close() - return nil + select { + case <-w.done: + return nil + case <-time.After(time.Second * 5): + return errors.New("filePoller.Close timeout") + } }