Skip to content
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

mac test using GH-actions #1

Closed
wants to merge 21 commits into from
Closed
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
77 changes: 77 additions & 0 deletions .github/workflows/mac-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# This workflow will build odo run tests on IBM Kubernetes cluster
#
# To configure this workflow:
#
# 2. Setup secrets in your repository: IBM_CLOUD_API_KEY, IBM_CLOUD_OPENSHIFT_CLUSTER_ENDPOINT and KUBE_CLUSTER_ID
# 3. Change the values for the IBM_CLOUD_REGION

name: Build and Test on mac

on:
push:
paths:
- 'cmd/**'
- 'pkg/**'
- 'go.mod'
- 'go.sum'
- 'tests/**'
- '.github/workflows/tests.yml'

# Environment variables available to all jobs and steps in this workflow
env:
GITHUB_SHA: ${{ github.sha }}
IBM_CLOUD_API_KEY: ${{ secrets.IBM_CLOUD_API_KEY }}
IBM_CLOUD_REGION: eu-de
OPENSHIFT_CLUSTER_ENDPOINT: ${{ secrets.IBM_CLOUD_OPENSHIFT_CLUSTER_ENDPOINT }}

jobs:
integration-tests-openshift:
name: Run integration tests on OpenShift
strategy:
matrix:
os: [macos-latest]
fail-fast: false
runs-on: ${{matrix.os}}
steps:

- name: Checkout
uses: actions/checkout@v2

- name: Install oc
uses: redhat-actions/oc-installer@v1

- name: Connect to Openshift cluster
uses: redhat-actions/oc-login@v1
with:
openshift_server_url: ${{ env.OPENSHIFT_CLUSTER_ENDPOINT }}
openshift_username: apikey
openshift_password: ${{ env.IBM_CLOUD_API_KEY }}

- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: '^1.15.1'

- name: Build odo
run: make install

- name: Run Integration tests
run: |
make test-integration
- name: Run Devfile Integration tests
run: |
make test-integration-devfile
- name: Run Operator Hub Integration tests
run: |
make test-operator-hub
- name: Run Login/logout Integration tests
env:
SKIP_USER_LOGIN_TESTS: true
run: |
make test-cmd-login-logout
- name: Run Command Integration tests
run: |
make test-cmd-project
- name: Run e2e tests
run: |
make test-e2e-devfile
17 changes: 12 additions & 5 deletions tests/integration/devfile/cmd_devfile_build_images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package devfile
import (
"path"
"path/filepath"
"runtime"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
Expand All @@ -24,29 +25,35 @@ var _ = Describe("odo devfile build-images command tests", func() {
})

When("using a devfile.yaml containing an Image component", func() {

var context string
BeforeEach(func() {
helper.CopyExample(filepath.Join("source", "nodejs"), commonVar.Context)
helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", "devfile-outerloop.yaml"), path.Join(commonVar.Context, "devfile.yaml"))
helper.Cmd("odo", "create").ShouldPass()

if runtime.GOOS == "darwin" {
context = filepath.Join("/private", commonVar.Context)
}
})
It("should run odo build-images without push", func() {
stdout := helper.Cmd("odo", "build-images").AddEnv("PODMAN_CMD=echo").ShouldPass().Out()
Expect(stdout).To(ContainSubstring("build -t quay.io/unknown-account/myimage -f " + filepath.Join(commonVar.Context, "Dockerfile ") + commonVar.Context))
Expect(stdout).To(ContainSubstring("build -t quay.io/unknown-account/myimage -f " + filepath.Join(context, "Dockerfile ") + context))
})

It("should run odo build-images --push", func() {
stdout := helper.Cmd("odo", "build-images", "--push").AddEnv("PODMAN_CMD=echo").ShouldPass().Out()
Expect(stdout).To(ContainSubstring("build -t quay.io/unknown-account/myimage -f " + filepath.Join(commonVar.Context, "Dockerfile ") + commonVar.Context))
Expect(stdout).To(ContainSubstring("build -t quay.io/unknown-account/myimage -f " + filepath.Join(context, "Dockerfile ") + context))
Expect(stdout).To(ContainSubstring("push quay.io/unknown-account/myimage"))
})
})

When("using a devfile.yaml containing an Image component with Dockerfile args", func() {
var context string
BeforeEach(func() {
if runtime.GOOS == "darwin" {
context = filepath.Join("/private", commonVar.Context)
}
helper.CopyExample(filepath.Join("source", "nodejs"), commonVar.Context)
helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", "devfile-outerloop-args.yaml"), path.Join(commonVar.Context, "devfile.yaml"))
helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", "devfile-outerloop-args.yaml"), filepath.Join(context, "devfile.yaml"))
helper.Cmd("odo", "create").ShouldPass()
})

Expand Down
8 changes: 6 additions & 2 deletions tests/integration/devfile/cmd_devfile_deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package devfile
import (
"path"
"path/filepath"
"runtime"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
Expand All @@ -24,19 +25,22 @@ var _ = Describe("odo devfile deploy command tests", func() {
})

When("using a devfile.yaml containing a deploy command", func() {

var context string
BeforeEach(func() {
helper.CopyExample(filepath.Join("source", "nodejs"), commonVar.Context)
helper.CopyExampleDevFile(filepath.Join("source", "devfiles", "nodejs", "devfile-deploy.yaml"), path.Join(commonVar.Context, "devfile.yaml"))
helper.Cmd("odo", "create").ShouldPass()
if runtime.GOOS == "darwin" {
context = filepath.Join("/private", commonVar.Context)
}
})
AfterEach(func() {
helper.Cmd("odo", "delete", "-a").ShouldPass()
})
It("should run odo deploy", func() {
stdout := helper.Cmd("odo", "deploy").AddEnv("PODMAN_CMD=echo").ShouldPass().Out()
By("building and pushing image to registry", func() {
Expect(stdout).To(ContainSubstring("build -t quay.io/unknown-account/myimage -f " + filepath.Join(commonVar.Context, "Dockerfile ") + commonVar.Context))
Expect(stdout).To(ContainSubstring("build -t quay.io/unknown-account/myimage -f " + filepath.Join(context, "Dockerfile ") + context))
Expect(stdout).To(ContainSubstring("push quay.io/unknown-account/myimage"))
})
By("deploying a deployment with the built image", func() {
Expand Down