ci: Run sdk and api tests in ci
This adds new makefile targets and configuration to run the tests in the api and sdk modules. These do not run by default since `go test ./...` does not cross module boundaries.
This commit is contained in:
10 files changed
+130
-1
No files matched your search
Generated
+56
@@ -179,6 +179,28 @@ jobs:
|
||||
name: Save package cache
|
||||
paths:
|
||||
- .buildcache/packages/store
|
||||
test-api:
|
||||
machine:
|
||||
image: ubuntu-2004:202107-02
|
||||
resource_class: medium
|
||||
working_directory: ~/boundary
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
command: |
|
||||
make install-go
|
||||
source ~/.bashrc
|
||||
echo 'export GOROOT=$GOROOT' >> "$BASH_ENV"
|
||||
echo 'export GOPATH=$GOPATH' >> "$BASH_ENV"
|
||||
echo 'export PATH=$PATH' >> "$BASH_ENV"
|
||||
echo "$ go version"
|
||||
go version
|
||||
name: Install go
|
||||
- run:
|
||||
command: |
|
||||
make test-api
|
||||
name: Run API Tests
|
||||
no_output_timeout: 15m
|
||||
darwin_arm64_package:
|
||||
docker:
|
||||
- image: docker.mirror.hashicorp.services/circleci/buildpack-deps
|
||||
@@ -591,6 +613,28 @@ jobs:
|
||||
name: Save package cache
|
||||
paths:
|
||||
- .buildcache/packages/store
|
||||
test-sdk:
|
||||
machine:
|
||||
image: ubuntu-2004:202107-02
|
||||
resource_class: medium
|
||||
working_directory: ~/boundary
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
command: |
|
||||
make install-go
|
||||
source ~/.bashrc
|
||||
echo 'export GOROOT=$GOROOT' >> "$BASH_ENV"
|
||||
echo 'export GOPATH=$GOPATH' >> "$BASH_ENV"
|
||||
echo 'export PATH=$PATH' >> "$BASH_ENV"
|
||||
echo "$ go version"
|
||||
go version
|
||||
name: Install go
|
||||
- run:
|
||||
command: |
|
||||
make test-sdk
|
||||
name: Run SDK Tests
|
||||
no_output_timeout: 15m
|
||||
algolia-index:
|
||||
docker:
|
||||
- image: docker.mirror.hashicorp.services/node:12
|
||||
@@ -1052,6 +1096,16 @@ jobs:
|
||||
working_directory: ~/boundary
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
command: |
|
||||
make install-go
|
||||
source ~/.bashrc
|
||||
echo 'export GOROOT=$GOROOT' >> "$BASH_ENV"
|
||||
echo 'export GOPATH=$GOPATH' >> "$BASH_ENV"
|
||||
echo 'export PATH=$PATH' >> "$BASH_ENV"
|
||||
echo "$ go version"
|
||||
go version
|
||||
name: Install go
|
||||
- run:
|
||||
command: |
|
||||
which pg_isready || sudo apt-get update && sudo apt-get install -y postgresql-client
|
||||
@@ -1650,6 +1704,8 @@ workflows:
|
||||
ci:
|
||||
jobs:
|
||||
- build
|
||||
- test-api
|
||||
- test-sdk
|
||||
- test-sql-latest
|
||||
- test-sql-11-alpine
|
||||
- test-sql-12-alpine
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
---
|
||||
description: >
|
||||
Ensure the right version of Go is installed and set PATH, GOPATH, GOROOT
|
||||
steps:
|
||||
- run:
|
||||
name: "Install go"
|
||||
command: |
|
||||
make install-go
|
||||
source ~/.bashrc
|
||||
echo 'export GOROOT=$GOROOT' >> "$BASH_ENV"
|
||||
echo 'export GOPATH=$GOPATH' >> "$BASH_ENV"
|
||||
echo 'export PATH=$PATH' >> "$BASH_ENV"
|
||||
echo "$ go version"
|
||||
go version
|
||||
@@ -1,6 +1,7 @@
|
||||
executor: go-machine
|
||||
steps:
|
||||
- checkout
|
||||
- install-go
|
||||
- run:
|
||||
name: "Initialize Test Database"
|
||||
command: |
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
executor: go-machine-medium
|
||||
steps:
|
||||
- checkout
|
||||
- install-go
|
||||
- run:
|
||||
name: "Run API Tests"
|
||||
no_output_timeout: 15m
|
||||
command: |
|
||||
make test-api
|
||||
@@ -0,0 +1,9 @@
|
||||
executor: go-machine-medium
|
||||
steps:
|
||||
- checkout
|
||||
- install-go
|
||||
- run:
|
||||
name: "Run SDK Tests"
|
||||
no_output_timeout: 15m
|
||||
command: |
|
||||
make test-sdk
|
||||
@@ -1,5 +1,7 @@
|
||||
jobs:
|
||||
- build
|
||||
- test-api
|
||||
- test-sdk
|
||||
- test-sql:
|
||||
matrix:
|
||||
parameters:
|
||||
|
||||
@@ -192,4 +192,20 @@ Note that if `max_connections` is set too low, it may result in sporadic test
|
||||
failures if a connection cannot be established. In this case, reduce the number
|
||||
of concurrent tests via `GOMAXPROCS` or selectively run tests.
|
||||
|
||||
### SDK and API tests
|
||||
|
||||
Tests for the SDK and API modules can also be run. These do not require a test
|
||||
database:
|
||||
|
||||
```
|
||||
$ make test-api
|
||||
$ make test-sdk
|
||||
```
|
||||
|
||||
Or all of the test can be run with a single target:
|
||||
|
||||
```
|
||||
$ make test-all
|
||||
```
|
||||
|
||||
## [Adding additional field to an existing API (or new API)](internal/adding-a-new-field-readme.md)
|
||||
@@ -189,7 +189,6 @@ test-database-down:
|
||||
make -C testing/dbtest/docker clean
|
||||
|
||||
.PHONY: test-ci
|
||||
test-ci: install-go
|
||||
test-ci: export CI_BUILD=1
|
||||
test-ci:
|
||||
CGO_ENABLED=$(CGO_ENABLED) BUILD_TAGS='$(BUILD_TAGS)' sh -c "'$(CURDIR)/scripts/build.sh'"
|
||||
@@ -203,6 +202,17 @@ test-sql:
|
||||
test:
|
||||
go test ./... -timeout 30m
|
||||
|
||||
.PHONY: test-sdk
|
||||
test-sdk:
|
||||
$(MAKE) -C sdk/ test
|
||||
|
||||
.PHONY: test-api
|
||||
test-api:
|
||||
$(MAKE) -C api/ test
|
||||
|
||||
.PHONY: test-all
|
||||
test-all: test-sdk test-api test
|
||||
|
||||
.PHONY: install-go
|
||||
install-go:
|
||||
./ci/goinstall.sh
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
.PHONY: all
|
||||
all: test
|
||||
|
||||
.PHONY: test
|
||||
test:
|
||||
go test -v ./...
|
||||
@@ -0,0 +1,6 @@
|
||||
.PHONY: all
|
||||
all: test
|
||||
|
||||
.PHONY: test
|
||||
test:
|
||||
go test -v ./...
|
||||
Reference in new issue
Block a user