diff --git a/.codecov.yml b/.codecov.yml index 6397d2b4..194d876f 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -45,6 +45,18 @@ coverage: <<: *projects flags: - "macos-1.15" + windows-1.13: + <<: *projects + flags: + - "windows-1.13" + windows-1.14: + <<: *projects + flags: + - "windows-1.14" + windows-1.15: + <<: *projects + flags: + - "windows-1.15" patch: default: false linux-1.13: @@ -59,6 +71,12 @@ coverage: <<: *patch macos-1.15: <<: *patch + windows-1.13: + <<: *patch + windows-1.14: + <<: *patch + windows-1.15: + <<: *patch changes: default: if_ci_failed: error @@ -73,6 +91,9 @@ coverage: - "macos-1.13" - "macos-1.14" - "macos-1.15" + - "windows-1.13" + - "windows-1.14" + - "windows-1.15" flags: linux-1.13: @@ -99,6 +120,18 @@ flags: paths: - / carryforward: true + windows-1.13: + paths: + - / + carryforward: true + windows-1.14: + paths: + - / + carryforward: true + windows-1.15: + paths: + - / + carryforward: true comment: behavior: default diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c7071cbe..cd35e678 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,6 +8,10 @@ on: pull_request: branches: "*" +defaults: + run: + shell: bash + jobs: test: strategy: @@ -17,6 +21,8 @@ jobs: - ubuntu-20.04 # https://github.com/actions/virtual-environments/blob/macOS-10.15/20201212.1/images/macos/macos-10.15-Readme.md - macos-10.15 + # https://github.com/actions/virtual-environments/blob/win19/20201210.0/images/win/Windows2019-Readme.md + - windows-2019 go-version: - 1.13.x - 1.14.x @@ -41,38 +47,56 @@ jobs: with: fetch-depth: 2 - - uses: actions/cache@v2 + - name: Cache Go module and build cache + uses: actions/cache@v2 with: + key: ${{ env.OS }}-go-${{ hashFiles('**/go.sum') }} path: | ~/go/pkg/mod # Module download cache ~/.cache/go-build # Build cache (Linux) ~/Library/Caches/go-build # Build cache (Mac) '%LocalAppData%\go-build' # Build cache (Windows) - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} restore-keys: | - ${{ runner.os }}-go- + ${{ env.OS }}-go- - - name: Install nvim binary for Linux - if: runner.os == 'Linux' - run: | - curl -SLO https://github.com/go-nvim/neovim/releases/download/nightly/nvim-linux64.tar.gz - tar xzf nvim-linux64.tar.gz - mv nvim-linux64 /home/runner/nvim - echo "/home/runner/nvim/bin" >> $GITHUB_PATH + - name: Cache nvim binary for linux and darwin + uses: actions/cache@v2 + id: cache-nvim + if: env.OS != 'windows' + with: + key: ${{ env.OS }}-nvim-${{ hashFiles('~/nvim/bin/nvim') }} + path: | + ~/nvim + restore-keys: | + ${{ env.OS }}-nvim- - - name: Install nvim binary for macOS - if: runner.os == 'MacOS' + - name: Cache nvim binary for Windows + uses: actions/cache@v2 + id: cache-nvim-windows + if: env.OS == 'windows' + with: + key: ${{ env.OS }}-nvim-${{ hashFiles('~/nvim/nvim.exe') }} + path: | + ~/nvim + restore-keys: | + ${{ env.OS }}-nvim- + + - name: Install nvim binary + uses: rhysd/action-setup-vim@v1 + if: steps.cache-nvim.outputs.cache-hit != 'true' || steps.cache-nvim-windows.outputs.cache-hit != 'true' + with: + neovim: true + version: nightly + + - name: gofmt + if: env.OS != 'windows' run: | - curl -SLO https://github.com/go-nvim/neovim/releases/download/nightly/nvim-macos.tar.gz - tar xzf nvim-macos.tar.gz - mv nvim-osx64 /Users/runner/nvim - echo "/Users/runner/nvim/bin" >> $GITHUB_PATH + diff -u <(echo -n) <(gofmt -s -d .) - name: Test and vet run: | - diff -u <(echo -n) <(gofmt -s -d .) go vet ./... - go test -v -race -covermode=atomic -coverpkg=./... -coverprofile=coverage.out ./... + go test -v -race -count=1 -covermode=atomic -coverpkg=./... -coverprofile=coverage.out ./... - uses: codecov/codecov-action@v1 with: diff --git a/nvim/nvim_test.go b/nvim/nvim_test.go index 901857e6..d1717a4b 100644 --- a/nvim/nvim_test.go +++ b/nvim/nvim_test.go @@ -9,6 +9,7 @@ import ( "os" "path/filepath" "reflect" + "runtime" "sort" "strings" "sync/atomic" @@ -20,11 +21,15 @@ func newChildProcess(tb testing.TB) (v *Nvim, cleanup func()) { tb.Helper() ctx := context.Background() - n, err := NewChildProcess( + opts := []ChildProcessOption{ ChildProcessArgs("-u", "NONE", "-n", "--embed", "--headless", "--noplugin"), ChildProcessContext(ctx), ChildProcessLogf(tb.Logf), - ) + } + if runtime.GOOS == "windows" { + opts = append(opts, ChildProcessCommand("nvim.exe")) + } + n, err := NewChildProcess(opts...) if err != nil { tb.Fatal(err) } @@ -1554,6 +1559,10 @@ func clearBuffer(tb testing.TB, v *Nvim, buffer Buffer) { } func TestDial(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip("not supported dial unix socket on windows GOOS") + } + t.Parallel() v1, cleanup := newChildProcess(t) diff --git a/nvim/plugin/register_test.go b/nvim/plugin/register_test.go index d3e1e54d..574c9175 100644 --- a/nvim/plugin/register_test.go +++ b/nvim/plugin/register_test.go @@ -2,6 +2,7 @@ package plugin_test import ( "os" + "runtime" "strings" "testing" @@ -14,10 +15,16 @@ func newEmbeddedPlugin(t *testing.T) (*plugin.Plugin, func()) { if v := os.Getenv("VIM"); v != "" { env = append(env, "VIM="+v) } - v, err := nvim.NewChildProcess( + + opts := []nvim.ChildProcessOption{ nvim.ChildProcessArgs("-u", "NONE", "-n", "--embed"), nvim.ChildProcessEnv(env), - nvim.ChildProcessLogf(t.Logf)) + nvim.ChildProcessLogf(t.Logf), + } + if runtime.GOOS == "windows" { + opts = append(opts, nvim.ChildProcessCommand("nvim.exe")) + } + v, err := nvim.NewChildProcess(opts...) if err != nil { t.Fatal(err) }