Skip to content

Commit

Permalink
CI: Add MacOS unit test workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Mayank Shah <[email protected]>
  • Loading branch information
mayankshah1607 committed Oct 5, 2020
1 parent eef5de2 commit 03d4ef6
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 16 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/darwin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: MacOS Build & Unit Test
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:

build:
name: Build
runs-on: macos-latest
steps:

- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.13
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Build Test
run: |
make azuredisk-darwin
- name: Run unit tests on MacOS
run: go test -v -race ./pkg/...
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
name: Go

name: Linux Build & Unit Tests
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:

build:
name: Build
runs-on: ubuntu-latest
Expand All @@ -22,9 +19,8 @@ jobs:
- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Test
- name: Build Test
run: sudo go test -covermode=count -coverprofile=profile.cov ./pkg/...

- name: Send coverage
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: Go

name: Windows Build & Unit Tests
on:
push:
branches: [ master ]
Expand All @@ -20,9 +19,9 @@ jobs:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Build
- name: Build Test
run: |
go build -a -o _output/azurediskplugin.exe ./pkg/azurediskplugin
make azuredisk-windows
- name: Run Windows Unit Tests
run: |
# start the CSI Proxy before running tests on windows
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ azuredisk:
azuredisk-windows:
CGO_ENABLED=0 GOOS=windows go build -a -ldflags ${LDFLAGS} -o _output/azurediskplugin.exe ./pkg/azurediskplugin

.PHONY: azuredisk-darwin
azuredisk-darwin:
CGO_ENABLED=0 GOOS=darwin go build -a -ldflags ${LDFLAGS} -o _output/azurediskplugin ./pkg/azurediskplugin

.PHONY: container
container: azuredisk
docker build --no-cache -t $(IMAGE_TAG) -f ./pkg/azurediskplugin/dev.Dockerfile .
Expand Down
22 changes: 16 additions & 6 deletions pkg/azuredisk/nodeserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,19 @@ func TestGetBlockSizeBytes(t *testing.T) {
testTarget, err := testutil.GetWorkDirPath("test")
assert.NoError(t, err)

invalidPathErr := testutil.TestError{
DefaultError: fmt.Errorf("error when getting size of block volume at path %s: "+
"output: , err: exit status 1", testTarget),
WindowsError: fmt.Errorf("error when getting size of block volume at path %s: "+
"output: , err: executable file not found in %%PATH%%", testTarget),
}

// exception in darwin
if runtime.GOOS == "darwin" {
invalidPathErr.DefaultError = fmt.Errorf("error when getting size of block volume at "+
"path %s: output: , err: executable file not found in $PATH", testTarget)
}

tests := []struct {
desc string
req string
Expand All @@ -685,12 +698,9 @@ func TestGetBlockSizeBytes(t *testing.T) {
},
},
{
desc: "invalid path",
req: testTarget,
expectedErr: testutil.TestError{
DefaultError: fmt.Errorf("error when getting size of block volume at path %s: output: , err: exit status 1", testTarget),
WindowsError: fmt.Errorf("error when getting size of block volume at path %s: output: , err: executable file not found in %%PATH%%", testTarget),
},
desc: "invalid path",
req: testTarget,
expectedErr: invalidPathErr,
},
}
for _, test := range tests {
Expand Down

0 comments on commit 03d4ef6

Please sign in to comment.