Skip to content

Commit

Permalink
add windows to CI pipeline
Browse files Browse the repository at this point in the history
Run tests on windows as well as linux and macos.
  • Loading branch information
fmoor committed May 13, 2021
1 parent 6f0fddd commit 30b98cd
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text eol=lf
16 changes: 14 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ jobs:
matrix:
go-version: ["1.15", "1.16"]
edgedb-version: [stable, nightly]
os: [ubuntu-latest, macos-latest]

os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v2

Expand All @@ -35,6 +34,14 @@ jobs:
run: |
go build .
- name: Setup WSL
if: ${{ matrix.os == 'windows-latest' }}
uses: vampire/setup-wsl@v1
with:
additional-packages:
ca-certificates
curl

- name: Install EdgeDB
uses: edgedb/setup-edgedb@v1
with:
Expand All @@ -45,5 +52,10 @@ jobs:
EDGEDB_SERVER_BIN: edgedb-server
run: |
make test
- name: Exercise Benchmarks
env:
EDGEDB_SERVER_BIN: edgedb-server
run: |
# run micro benchmarks to be sure they still work
make bench
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ lint:
golangci-lint run

test:
go test -race -timeout=5m ./...
go test -race -bench=$$^ -timeout=5m ./...

bench:
go test -run=^$$ -bench=. -benchmem -timeout=5m ./...
Expand Down
7 changes: 2 additions & 5 deletions connutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"net"
"os"
"path"
"syscall"
"testing"
"time"

Expand Down Expand Up @@ -477,10 +476,9 @@ func TestConnectRefused(t *testing.T) {
require.True(t, errors.As(err, &edbErr), msg)
assert.True(
t,
edbErr.Category(ClientConnectionFailedTemporarilyError),
edbErr.Category(ClientConnectionFailedError),
msg,
)
assert.True(t, errors.Is(err, syscall.ECONNREFUSED), msg)
}

func TestConnectInvalidName(t *testing.T) {
Expand Down Expand Up @@ -533,9 +531,8 @@ func TestConnectRefusedUnixSocket(t *testing.T) {
require.True(t, errors.As(err, &edbErr), "wrong error: %v", err)
assert.True(
t,
edbErr.Category(ClientConnectionFailedTemporarilyError),
edbErr.Category(ClientConnectionFailedError),
"wrong error: %v",
err,
)
assert.True(t, errors.Is(err, syscall.ENOENT), "wrong error: %v", err)
}
21 changes: 15 additions & 6 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"math/rand"
"os"
"os/exec"
"runtime"
"runtime/debug"
"strings"
"testing"
Expand All @@ -48,8 +49,8 @@ func executeOrPanic(command string) {
func startServer() (err error) {
log.Print("starting new server")

cmdName := os.Getenv("EDGEDB_SERVER_BIN")
if cmdName == "" {
serverBin := os.Getenv("EDGEDB_SERVER_BIN")
if serverBin == "" {
log.Fatal("EDGEDB_SERVER_BIN not set")
}

Expand All @@ -63,10 +64,19 @@ func startServer() (err error) {
`CREATE SUPERUSER ROLE test { SET password := "shhh" }`,
}

var cmdName string
if runtime.GOOS == "windows" {
cmdName = "wsl"
cmdArgs = append([]string{
"sudo", "-u", "nobody", serverBin,
}, cmdArgs...)
} else {
cmdName = serverBin
}

log.Println(cmdName, strings.Join(cmdArgs, " "))

cmd := exec.Command(cmdName, cmdArgs...)
cmd.Stderr = os.Stderr
stdout, err := cmd.StdoutPipe()
if err != nil {
log.Fatal(err)
Expand All @@ -88,8 +98,7 @@ func startServer() (err error) {
}

type serverData struct {
Port int `json:"port"`
Host string `json:"runstate_dir"`
Port int `json:"port"`
}

var data serverData
Expand All @@ -103,7 +112,7 @@ func startServer() (err error) {
}

opts = Options{
Hosts: []string{data.Host},
Hosts: []string{"127.0.0.1"},
Ports: []int{data.Port},
User: "test",
Password: "shhh",
Expand Down

0 comments on commit 30b98cd

Please sign in to comment.