Skip to content

Add Go integration tests #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/workflows/gotest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Devfile Go integration tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
# every day at 9am EST
- cron: 0 1 * * *
jobs:

build:
name: Run Tests
strategy:
matrix:
os: [ ubuntu-latest, macos-10.15 ]
runs-on: ${{ matrix.os }}
continue-on-error: true
timeout-minutes: 20

steps:

- name: Setup Go environment
uses: actions/[email protected]
with:
go-version: 1.15
id: go

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

- name: Check go mod status
run: |
make gomod_tidy
if [[ ! -z $(git status -s) ]]
then
echo "Go mod state is not clean"
git diff "$GITHUB_SHA"
exit 1
fi

- name: Check format
run: |
make gofmt
if [[ ! -z $(git status -s) ]]
then
echo "not well formatted sources are found : $(git status -s)"
exit 1
fi

- name: Run Go Tests
run: make test

# - name: Upload Test Coverage results
# uses: actions/upload-artifact@v2
# with:
# name: lib-test-coverage-html
# path: tests/v2/lib-test-coverage.html
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,5 @@ dmypy.json
# Pyre type checker
.pyre/

# Test temp directory
tests/v2/integrationTest/tmp/
29 changes: 29 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FILES := main

default: bin

.PHONY: all
all: gomod_tidy gofmt test

.PHONY: gomod_tidy
gomod_tidy:
go mod tidy

.PHONY: gofmt
gofmt:
go fmt -x ./...

.PHONY: bin
bin:
go build *.go

.PHONY: test
test:
go test -v ./tests/v2/integrationTest
# go test -coverprofile tests/v2/lib-test-coverage.out -v ./...
# go tool cover -html=tests/v2/lib-test-coverage.out -o tests/v2/lib-test-coverage.html

.PHONY: clean
clean:
@rm -rf $(FILES)

36 changes: 36 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module github.com/devfile/library

go 1.15

require (
github.com/devfile/api/v2 v2.0.0-20220309195345-48ebbf1e51cf
github.com/fatih/color v1.7.0
github.com/fsnotify/fsnotify v1.4.9
github.com/gobwas/glob v0.2.3
github.com/golang/mock v1.5.0
github.com/google/go-cmp v0.5.5
github.com/google/go-github v17.0.0+incompatible // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/go-version v1.3.0
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348
github.com/mattn/go-colorable v0.1.2 // indirect
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/onsi/ginkgo v1.16.4
github.com/onsi/gomega v1.14.0
github.com/openshift/api v0.0.0-20200930075302-db52bc4ef99f
github.com/openshift/odo v1.2.6
github.com/pkg/errors v0.9.1
github.com/spf13/afero v1.2.2
github.com/stretchr/testify v1.7.0
github.com/tidwall/gjson v1.14.1
github.com/xeipuuv/gojsonschema v1.2.0
k8s.io/api v0.21.3
k8s.io/apimachinery v0.21.3
k8s.io/client-go v0.21.3
k8s.io/klog v1.0.0
k8s.io/utils v0.0.0-20210722164352-7f3ee0f31471
sigs.k8s.io/controller-runtime v0.9.5
sigs.k8s.io/yaml v1.2.0
)
816 changes: 816 additions & 0 deletions go.sum

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ var _ = Describe("odo devfile create command tests", func() {
})

Measure("should successfully create the devfile component with valid component name", func(b Benchmarker) {
runtime := b.Time("========== Command: odo create java-openliberty " +
cmpName + " ==========", func() {
runtime := b.Time("========== Command: odo create java-openliberty "+
cmpName+" ==========", func() {
helper.Cmd("odo", "create", "java-openliberty", cmpName).ShouldPass()
})
b.RecordValueWithPrecision("========== Execution time in ms ==========", float64(runtime.Milliseconds()), "ms", 2)
Expand Down
Loading