Repository: pkg/sftp
Pull request #402 (2020-12-08 12:20:53)

CI: switch to GitHub Actions
GitHub actions have some missing features compared to Travis but they are much faster.

Please take a look at the build times here:

https://github.com/drakkan/sftp/actions

the build starts as soon as we push a new commit, travis seems to wait more than hour before starting the build (at least today)


Patch:
diff --git a/.github/workflows/.editorconfig b/.github/workflows/.editorconfig
new file mode 100644
index 0000000..7bd3346
--- /dev/null
+++ b/.github/workflows/.editorconfig
@@ -0,0 +1,2 @@
+[*.yml]
+indent_size = 2
diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml
new file mode 100644
index 0000000..0a7959e
--- /dev/null
+++ b/.github/workflows/CI.yml
@@ -0,0 +1,31 @@
+name: CI
+
+on:
+  push:
+    branches: [master]
+  pull_request:
+
+jobs:
+  run-tests:
+    name: Run test cases
+    runs-on: ${{ matrix.os }}
+    strategy:
+      matrix:
+        os: [ubuntu-latest, macos-latest]
+        go: [1.15, 1.14]
+        exclude:
+          - os: macos-latest
+            go: 1.14
+
+    steps:
+      - uses: actions/checkout@v2
+
+      - name: Set up Go
+        uses: actions/setup-go@v2
+        with:
+          go-version: ${{ matrix.go }}
+
+      - name: Run tests
+        run: |
+          make integration
+          make integration_w_race
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 1cbefce..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,46 +0,0 @@
-language: go
-go_import_path: github.com/pkg/sftp
-
-# current and previous stable releases, plus tip
-# remember to exclude previous and tip for macs below
-go:
-  - 1.14.x
-  - 1.15.x
-  - tip
-
-os:
-  - linux
-  - osx
-
-matrix:
-  exclude:
-    - os: osx
-      go: 1.14.x
-    - os: osx
-      go: tip
-
-env:
-  global:
-    - GO111MODULE=on
-
-addons:
-  ssh_known_hosts:
-      - bitbucket.org
-
-install:
-  - go get -t -v ./...
-  - ssh-keygen -t rsa -q -P "" -f $HOME/.ssh/id_rsa
-
-script:
-  - go test -integration -v ./...
-  - go test -testserver -v ./...
-  - go test -integration -testserver -v ./...
-  - go test -integration -allocator -v ./...
-  - go test -testserver -allocator -v ./...
-  - go test -integration -testserver -allocator -v ./...
-  - go test -race -integration -v ./...
-  - go test -race -testserver -v ./...
-  - go test -race -integration -testserver -v ./...
-  - go test -race -integration -allocator -v ./...
-  - go test -race -testserver -allocator -v ./...
-  - go test -race -integration -allocator -testserver -v ./...
diff --git a/README.md b/README.md
index 1fb700c..536e97b 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@ The `sftp` package provides support for file system operations on remote ssh
 servers using the SFTP subsystem. It also implements an SFTP server for serving
 files from the filesystem.
 
-[![UNIX Build Status](https://travis-ci.org/pkg/sftp.svg?branch=master)](https://travis-ci.org/pkg/sftp) [![GoDoc](http://godoc.org/github.com/pkg/sftp?status.svg)](http://godoc.org/github.com/pkg/sftp)
+![CI Status](https://github.com/pkg/sftp/workflows/CI/badge.svg?branch=master&event=push) [![GoDoc](http://godoc.org/github.com/pkg/sftp?status.svg)](http://godoc.org/github.com/pkg/sftp)
 
 usage and examples
 ------------------
diff --git a/client.go b/client.go
index cdd5669..e329ed5 100644
--- a/client.go
+++ b/client.go
@@ -655,18 +655,14 @@ func (c *Client) Join(elem ...string) string { return path.Join(elem...) }
 // is not empty.
 func (c *Client) Remove(path string) error {
 	err := c.removeFile(path)
-	// some servers, *cough* osx *cough*, return EPERM, not ENODIR.
-	// serv-u returns ssh_FX_FILE_IS_A_DIRECTORY
-	// EPERM is converted to os.ErrPermission so it is not a StatusError
 	if err, ok := err.(*StatusError); ok {
 		switch err.Code {
-		case sshFxFailure, sshFxFileIsADirectory:
+		// some servers, *cough* osx *cough*, return EPERM, not ENODIR.
+		// serv-u returns ssh_FX_FILE_IS_A_DIRECTORY
+		case sshFxPermissionDenied, sshFxFailure, sshFxFileIsADirectory:
 			return c.RemoveDirectory(path)
 		}
 	}
-	if os.IsPermission(err) {
-		return c.RemoveDirectory(path)
-	}
 	return err
 }
 
@@ -1367,8 +1363,6 @@ func normaliseError(err error) error {
 			return io.EOF
 		case sshFxNoSuchFile:
 			return os.ErrNotExist
-		case sshFxPermissionDenied:
-			return os.ErrPermission
 		case sshFxOk:
 			return nil
 		default:


Test patch:
diff --git a/client_integration_test.go b/client_integration_test.go
index caf15cb..eda5d32 100644
--- a/client_integration_test.go
+++ b/client_integration_test.go
@@ -453,13 +453,16 @@ func TestClientCreateFailed(t *testing.T) {
 	defer sftp.Close()
 
 	f, err := ioutil.TempFile("", "sftptest-createfailed")
-	require.NoError(t, err)
-
+	if err != nil {
+		t.Fatal(err)
+	}
 	defer f.Close()
 	defer os.Remove(f.Name())
 
 	f2, err := sftp.Create(f.Name())
-	require.True(t, os.IsPermission(err))
+	if err1, ok := err.(*StatusError); !ok || err1.Code != sshFxPermissionDenied {
+		t.Fatalf("Create: want: %v, got %#v", sshFxPermissionDenied, err)
+	}
 	if err == nil {
 		f2.Close()
 	}