Skip to content

Commit

Permalink
Set up CI with Azure Pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
antalakas committed Aug 27, 2020
1 parent 18919ac commit 03c31ba
Show file tree
Hide file tree
Showing 17 changed files with 172 additions and 72 deletions.
29 changes: 0 additions & 29 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# TileDB Go Bindings

[![GoDoc](https://godoc.org/github.com/TileDB-Inc/TileDB-Go?status.svg)](http://godoc.org/github.com/TileDB-Inc/TileDB-Go)
[![Build Status](https://travis-ci.org/TileDB-Inc/TileDB-Go.svg?branch=master)](https://travis-ci.org/TileDB-Inc/TileDB-Go)
[![Build Status](https://dev.azure.com/TileDB-Inc/CI/_apis/build/status/TileDB-Inc.TileDB-Go?branchName=refs%2Fpull%2F123%2Fmerge)](https://dev.azure.com/TileDB-Inc/CI/_build/latest?definitionId=25&branchName=refs%2Fpull%2F123%2Fmerge)

This package provides [TileDB](https://github.com/TileDB-Inc/TileDB) golang bindings via cgo. The bindings have been
designed to be idomatic Go. `runtime.set_finalizer` is used to ensure proper
Expand Down
5 changes: 4 additions & 1 deletion array.go
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ is the maximum number of elements for that attribute in the given subarray.
*/
func (a *Array) MaxBufferElements(subarray interface{}) (map[string][2]uint64, error) {
// Build map
ret := make(map[string][2]uint64, 0)
ret := make(map[string][2]uint64)
// Get schema
schema, err := a.Schema()
if err != nil {
Expand All @@ -843,6 +843,9 @@ func (a *Array) MaxBufferElements(subarray interface{}) (map[string][2]uint64, e

// Get datatype size to convert byte lengths to needed buffer sizes
dataType, err := attribute.Type()
if err != nil {
return nil, fmt.Errorf("Error getting attribute type for array: %s", err)
}
dataTypeSize := dataType.Size()

// Get attribute name
Expand Down
45 changes: 45 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Go
# Build your Go project.
# Add steps that test, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/go

trigger:
batch: true
branches:
include:
- master
paths:
exclude:
- README.md
- LICENSE
- .gitignore

pr:
autoCancel: true
branches:
include:
- master
paths:
exclude:
- README.md
- LICENSE
- .gitignore

variables:
GOPATH: '$(Pipeline.Workspace)/go'

stages:
- stage: Linux_Test
jobs:
- template: templates/azure/jobs/test.yml
parameters:
pool:
vmImage: 'ubuntu-18.04'
os: 'linux'
- stage: Mac_Test
jobs:
- template: templates/azure/jobs/test.yml
parameters:
pool:
vmImage: 'macos-10.14'
os: 'macos'
3 changes: 2 additions & 1 deletion config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ func TestFileConfig(t *testing.T) {
os.Remove(tmpPath)
}

config.SaveToFile(tmpPath)
err = config.SaveToFile(tmpPath)
assert.Nil(t, err)

config2, err := LoadConfig(tmpPath)
assert.Nil(t, err)
Expand Down
5 changes: 4 additions & 1 deletion context.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ func NewContext(config *Config) (*Context, error) {
context.Free()
})

context.setDefaultTags()
err1 := context.setDefaultTags()
if err != nil {
return nil, fmt.Errorf("Error creating tiledb context: %s", err1.Error())
}

return &context, nil
}
Expand Down
3 changes: 2 additions & 1 deletion context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func ExampleNewContext() {
// handle error
return
}
// Output: false
// Output: true
fmt.Println(isS3Supported)
}

Expand All @@ -56,6 +56,7 @@ func TestNewContext(t *testing.T) {
// Test context with config
context, err = NewContext(config)
assert.Nil(t, err)
assert.NotNil(t, context)
}

// TestGetContextConfig tests setting a new context
Expand Down
9 changes: 6 additions & 3 deletions enums.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,13 @@ func (d *Datatype) FromString(s string) error {
}

// DatatypeFromString converts from a datatype string to enum
func DatatypeFromString(s string) Datatype {
func DatatypeFromString(s string) (Datatype, error) {
var d Datatype
d.FromString(s)
return d
err := d.FromString(s)
if err != nil {
return TILEDB_ANY, err
}
return d, nil
}

// ReflectKind returns the reflect kind given a datatype
Expand Down
7 changes: 3 additions & 4 deletions query.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ type Query struct {
tiledbQuery *C.tiledb_query_t
array *Array
context *Context
uri string
buffers []interface{}
bufferMutex sync.Mutex
resultBufferElements map[string][2]*uint64
Expand All @@ -36,7 +35,7 @@ type RangeLimits struct {

// MarshalJSON implements the Marshaler interface for RangeLimits
func (r RangeLimits) MarshalJSON() ([]byte, error) {
rangeLimitMap := make(map[string]interface{}, 0)
rangeLimitMap := make(map[string]interface{})
rangeLimitMap["end"] = r.end
rangeLimitMap["start"] = r.start

Expand Down Expand Up @@ -75,7 +74,7 @@ func NewQuery(ctx *Context, array *Array) (*Query, error) {
query.Free()
})

query.resultBufferElements = make(map[string][2]*uint64, 0)
query.resultBufferElements = make(map[string][2]*uint64)

return &query, nil
}
Expand Down Expand Up @@ -1226,7 +1225,7 @@ func (q *Query) SetBufferVar(attributeOrDimension string, offset []uint64, buffe
// second is number of elements in the data buffer. For fixed sized attributes
// (and coordinates), the first is always 0.
func (q *Query) ResultBufferElements() (map[string][2]uint64, error) {
elements := make(map[string][2]uint64, 0)
elements := make(map[string][2]uint64)

// Will need the schema to infer data type size for attributes
schema, err := q.array.Schema()
Expand Down
2 changes: 0 additions & 2 deletions query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1282,8 +1282,6 @@ func TestQueryWrite(t *testing.T) {
assert.Equal(t, len(bufferA4), elementsCopied)

_, _, err = query.SetBufferVar("a4", offsetBufferA4, bufferA4)
// Immediately set bufferA4 to nil to validate underlying array is not GC'ed
bufferA4 = nil
assert.Nil(t, err)

bufferA5 := "hello" + "world"
Expand Down
21 changes: 0 additions & 21 deletions scripts/ci_install_tiledb.sh

This file was deleted.

8 changes: 0 additions & 8 deletions scripts/travis.gofmt.sh

This file was deleted.

64 changes: 64 additions & 0 deletions templates/azure/jobs/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
jobs:
- job: RunTests
strategy:
matrix:
GoVersion_1_13:
go.version: '1.13'
GoVersion_1_14:
go.version: '1.14'

pool:
vmImage: 'ubuntu-18.04'

steps:
- script: echo ${{ parameters.os }}

- template: ../steps/setup_go.yml
parameters:
goVersion: '$(go.version)'

- template: ../steps/format_go.yml

- ${{ if eq(parameters.os, 'linux') }}:
- template: ../steps/install_tiledb_linux.yml

- ${{ if eq(parameters.os, 'macos') }}:
- template: ../steps/install_tiledb_macos.yml

- script: |
set -e -x
go version
go get -u github.com/jstemmer/go-junit-report
go get github.com/axw/gocov/gocov
go get github.com/AlekSi/gocov-xml
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.24.0
curl https://cdn.shiftleft.io/download/sl > $(go env GOPATH)/bin/sl && chmod a+rx $(go env GOPATH)/bin/sl
displayName: 'Install Dependencies'
- ${{ if eq(parameters.os, 'linux') }}:
- script: |
set -e -x
golangci-lint run
displayName: 'Run Code Quality Checks'
- script: |
set -v -x
go test -v -coverprofile=coverage.txt -covermode count ./... > test_results.txt
go-junit-report < test_results.txt > report.xml
displayName: 'Run Unit Tests'
- task: PublishTestResults@2
displayName: 'Publish Test Results'
inputs:
testRunner: JUnit
testResultsFiles: $(System.DefaultWorkingDirectory)/**/report.xml

- script: |
set -e -x
gocov convert coverage.txt > coverage.json
gocov-xml < coverage.json > coverage.xml
displayName: 'Run Code Coverage Tests'
- task: PublishCodeCoverageResults@1
displayName: 'Publish Code Coverage'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: $(System.DefaultWorkingDirectory)/**/coverage.xml
11 changes: 11 additions & 0 deletions templates/azure/steps/format_go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
steps:
- script: |
ls -al
if [[ -n "$(gofmt -l .)" ]]; then
echo "TileDB-Go code is not formatted:"
gofmt -d .
exit 1
else
echo "TileDB-Go code is well formatted."
fi
displayName: 'Checks formatting of Go code'
8 changes: 8 additions & 0 deletions templates/azure/steps/install_tiledb_linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Install TileDB in a system location
steps:
- script: |
set -e -x
curl --location -o tiledb.tar.gz https://github.com/TileDB-Inc/TileDB/releases/download/2.0.8/tiledb-linux-2.0.8-db41376-full.tar.gz \
&& sudo tar -C /usr/local -xf tiledb.tar.gz
sudo ldconfig /usr/local/lib
displayName: 'Install TileDB'
7 changes: 7 additions & 0 deletions templates/azure/steps/install_tiledb_macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Install TileDB in a system location
steps:
- script: |
set -e -x
curl --location -o tiledb.tar.gz https://github.com/TileDB-Inc/TileDB/releases/download/2.0.8/tiledb-macos-2.0.8-db41376-full.tar.gz \
&& sudo tar -C /usr/local -xf tiledb.tar.gz
displayName: 'Install TileDB'
15 changes: 15 additions & 0 deletions templates/azure/steps/setup_go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
parameters:
goVersion: '1.14'

steps:
- task: GoTool@0
displayName: 'Use Go ${{ parameters.goVersion }}'
inputs:
version: ${{ parameters.goVersion }}

- script: |
set -e -x
mkdir -p '$(GOPATH)/bin'
echo '##vso[task.prependpath]$(GOROOT)/bin'
echo '##vso[task.prependpath]$(GOPATH)/bin'
displayName: 'Create Go Workspace'

0 comments on commit 03c31ba

Please sign in to comment.