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

Add GitHub workflows 'lint' and 'build' #98

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
53 changes: 53 additions & 0 deletions .github/workflows/build-on-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# The name of your workflow. GitHub displays the names of your workflows on your repository's actions page.
# If you omit name, GitHub sets it to the workflow file path relative to the root of the repository.
name: build-on-pull-request

# This workflow is triggered on pull request
on:
pull_request:
branches: [ $default-branch ] #, develop ]

jobs:
# Set the job key. The key is displayed as the job name
# when a job name is not provided
# The job key is “build"
build:
# Job name is “Build”
name: Build

strategy:
matrix:
go-version: [ 1.15.x ]
os: [ ubuntu-18.04 ] #macos-latest, windows-latest
runs-on: ${{ matrix.os }}

steps:
# This action sets up a go environment for use in actions by:
# optionally downloading and caching a version of Go by version and adding to PATH
# registering problem matchers for error output
# This step uses GitHub's setup-go: https://github.com/actions/setup-go
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
id: go

# This action checks-out your repository under $GITHUB_WORKSPACE, so your workflow can access it.
# This step uses GitHub's checkout: https://github.com/actions/checkout
- name: Check out code into the Go module directory
uses: actions/checkout@v2

# This step installs dependencies
# - name: Get dependencies
# run: |
# go get -v -t -d ./...
# if [ -f Gopkg.toml ]; then
# curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
# dep ensure
# fi

# This step builds source codes
- name: Build
run: |
go build -v ./src

42 changes: 42 additions & 0 deletions .github/workflows/lint-on-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# The name of your workflow. GitHub displays the names of your workflows on your repository's actions page.
# If you omit name, GitHub sets it to the workflow file path relative to the root of the repository.
name: lint-on-push

# This workflow is triggered on push
on:
push:
# Ignoring branches
branches-ignore:
# Push events to branches matching master
- 'master'
# Push events to branches matching develop
#- 'develop'

# Ignoring paths
paths-ignore:
# Push events to mypath/**
#- 'mypath/**'

jobs:
# Set the job key. The key is displayed as the job name
# when a job name is not provided
# The job key is “lint"
lint:
# Job name is “xxx”
name: Lint

strategy:
matrix:
go-version: [1.15.x]
os: [ubuntu-18.04] #macos-latest, windows-latest
runs-on: ${{ matrix.os }}

steps:
- name: Checkout source code
uses: actions/checkout@v2

- name: Install golangci-lint
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.34.1

- name: Run golangci-lint
run: $(go env GOPATH)/bin/golangci-lint run
36 changes: 11 additions & 25 deletions src/cmd/info.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
/*
Copyright © 2020 NAME HERE <EMAIL ADDRESS>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd

import (
Expand All @@ -28,33 +13,34 @@ var infoCmd = &cobra.Command{
Short: "Get information of Cloud-Barista System",
Long: `Get information of Cloud-Barista System. Information about containers and container images`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("\n[Get info for Cloud-Barista runtimes]\n")
fmt.Println("\n[Get info for Cloud-Barista runtimes]")
fmt.Println()

if common.FileStr == "" {
fmt.Println("file is required")
} else {
common.FileStr = common.GenConfigPath(common.FileStr, common.CB_OPERATOR_MODE)
common.FileStr = common.GenConfigPath(common.FileStr, common.CBOperatorMode)
var cmdStr string
switch common.CB_OPERATOR_MODE {
case common.Mode_DockerCompose:
common.SysCall_docker_compose_ps()
switch common.CBOperatorMode {
case common.ModeDockerCompose:
common.SysCallDockerComposePs()

fmt.Println("")
fmt.Println("[v]Status of Cloud-Barista runtime images")
cmdStr = "sudo COMPOSE_PROJECT_NAME=cloud-barista docker-compose -f " + common.FileStr + " images"
//fmt.Println(cmdStr)
common.SysCall(cmdStr)
case common.Mode_Kubernetes:
case common.ModeKubernetes:
fmt.Println("[v]Status of Cloud-Barista Helm release")
cmdStr = "sudo helm status --namespace " + common.CB_K8s_Namespace + " " + common.CB_Helm_Release_Name
cmdStr = "sudo helm status --namespace " + common.CBK8sNamespace + " " + common.CBHelmReleaseName
common.SysCall(cmdStr)
fmt.Println()
fmt.Println("[v]Status of Cloud-Barista pods")
cmdStr = "sudo kubectl get pods -n " + common.CB_K8s_Namespace
cmdStr = "sudo kubectl get pods -n " + common.CBK8sNamespace
common.SysCall(cmdStr)
fmt.Println()
fmt.Println("[v]Status of Cloud-Barista container images")
cmdStr = `sudo kubectl get pods -n ` + common.CB_K8s_Namespace + ` -o jsonpath="{..image}" |\
cmdStr = `sudo kubectl get pods -n ` + common.CBK8sNamespace + ` -o jsonpath="{..image}" |\
tr -s '[[:space:]]' '\n' |\
sort |\
uniq`
Expand All @@ -70,7 +56,7 @@ func init() {
rootCmd.AddCommand(infoCmd)

pf := infoCmd.PersistentFlags()
pf.StringVarP(&common.FileStr, "file", "f", common.Not_Defined, "User-defined configuration file")
pf.StringVarP(&common.FileStr, "file", "f", common.NotDefined, "User-defined configuration file")
// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
Expand Down
22 changes: 4 additions & 18 deletions src/cmd/pull.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
/*
Copyright © 2020 NAME HERE <EMAIL ADDRESS>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd

import (
Expand All @@ -28,12 +13,13 @@ var pullCmd = &cobra.Command{
Short: "Pull images of Cloud-Barista System containers",
Long: `Pull images of Cloud-Barista System containers`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("\n[Pull images of Cloud-Barista System containers]\n")
fmt.Println("\n[Pull images of Cloud-Barista System containers]")
fmt.Println()

if common.FileStr == "" {
fmt.Println("file is required")
} else {
common.FileStr = common.GenConfigPath(common.FileStr, common.CB_OPERATOR_MODE)
common.FileStr = common.GenConfigPath(common.FileStr, common.CBOperatorMode)
/*
var configuration mcisReq

Expand Down Expand Up @@ -61,7 +47,7 @@ func init() {
rootCmd.AddCommand(pullCmd)

pf := pullCmd.PersistentFlags()
pf.StringVarP(&common.FileStr, "file", "f", common.Not_Defined, "User-defined configuration file")
pf.StringVarP(&common.FileStr, "file", "f", common.NotDefined, "User-defined configuration file")
// cobra.MarkFlagRequired(pf, "file")

// Here you will define your flags and configuration settings.
Expand Down
38 changes: 12 additions & 26 deletions src/cmd/remove.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
/*
Copyright © 2020 NAME HERE <EMAIL ADDRESS>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd

import (
Expand All @@ -29,29 +14,30 @@ var removeCmd = &cobra.Command{
Long: `Stop and Remove Cloud-Barista System. Stop and Remove Cloud-Barista runtimes and related container images and meta-DB if necessary`,
Run: func(cmd *cobra.Command, args []string) {

fmt.Println("\n[Remove Cloud-Barista]\n")
fmt.Println("\n[Remove Cloud-Barista]")
fmt.Println()

if common.FileStr == "" {
fmt.Println("file is required")
} else {
common.FileStr = common.GenConfigPath(common.FileStr, common.CB_OPERATOR_MODE)
common.FileStr = common.GenConfigPath(common.FileStr, common.CBOperatorMode)
var cmdStr string
switch common.CB_OPERATOR_MODE {
case common.Mode_Kubernetes:
cmdStr = "sudo helm uninstall --namespace " + common.CB_K8s_Namespace + " " + common.CB_Helm_Release_Name
switch common.CBOperatorMode {
case common.ModeKubernetes:
cmdStr = "sudo helm uninstall --namespace " + common.CBK8sNamespace + " " + common.CBHelmReleaseName
common.SysCall(cmdStr)

cmdStr = "sudo kubectl delete pvc cb-spider -n " + common.CB_K8s_Namespace
cmdStr = "sudo kubectl delete pvc cb-spider -n " + common.CBK8sNamespace
common.SysCall(cmdStr)

cmdStr = "sudo kubectl delete pvc cb-tumblebug -n " + common.CB_K8s_Namespace
cmdStr = "sudo kubectl delete pvc cb-tumblebug -n " + common.CBK8sNamespace
common.SysCall(cmdStr)

cmdStr = "sudo kubectl delete pvc data-cb-dragonfly-etcd-0 -n " + common.CB_K8s_Namespace
cmdStr = "sudo kubectl delete pvc data-cb-dragonfly-etcd-0 -n " + common.CBK8sNamespace
common.SysCall(cmdStr)

//fallthrough
case common.Mode_DockerCompose:
case common.ModeDockerCompose:
if volFlag && imgFlag {
cmdStr = "sudo COMPOSE_PROJECT_NAME=cloud-barista docker-compose -f " + common.FileStr + " down -v --rmi all"
} else if volFlag {
Expand All @@ -65,7 +51,7 @@ var removeCmd = &cobra.Command{
//fmt.Println(cmdStr)
common.SysCall(cmdStr)

common.SysCall_docker_compose_ps()
common.SysCallDockerComposePs()
default:

}
Expand All @@ -81,7 +67,7 @@ func init() {
rootCmd.AddCommand(removeCmd)

pf := removeCmd.PersistentFlags()
pf.StringVarP(&common.FileStr, "file", "f", common.Not_Defined, "User-defined configuration file")
pf.StringVarP(&common.FileStr, "file", "f", common.NotDefined, "User-defined configuration file")
// cobra.MarkFlagRequired(pf, "file")

pf.BoolVarP(&volFlag, "volumes", "v", false, "Remove named volumes declared in the volumes section of the Compose file")
Expand Down
15 changes: 0 additions & 15 deletions src/cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
/*
Copyright © 2020 NAME HERE <EMAIL ADDRESS>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd

import (
Expand Down
38 changes: 12 additions & 26 deletions src/cmd/run.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
/*
Copyright © 2020 NAME HERE <EMAIL ADDRESS>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd

import (
Expand All @@ -28,7 +13,8 @@ var runCmd = &cobra.Command{
Short: "Setup and Run Cloud-Barista System",
Long: `Setup and Run Cloud-Barista System`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("\n[Setup and Run Cloud-Barista]\n")
fmt.Println("\n[Setup and Run Cloud-Barista]")
fmt.Println()

if common.FileStr == "" {
fmt.Println("file is required")
Expand All @@ -47,18 +33,18 @@ var runCmd = &cobra.Command{

common.PrintJsonPretty(configuration)
*/
common.FileStr = common.GenConfigPath(common.FileStr, common.CB_OPERATOR_MODE)
common.FileStr = common.GenConfigPath(common.FileStr, common.CBOperatorMode)

var cmdStr string
switch common.CB_OPERATOR_MODE {
case common.Mode_DockerCompose:
switch common.CBOperatorMode {
case common.ModeDockerCompose:
cmdStr = "sudo COMPOSE_PROJECT_NAME=cloud-barista docker-compose -f " + common.FileStr + " up"
//fmt.Println(cmdStr)
common.SysCall(cmdStr)
case common.Mode_Kubernetes:
cmdStr = "sudo kubectl create ns " + common.CB_K8s_Namespace
case common.ModeKubernetes:
cmdStr = "sudo kubectl create ns " + common.CBK8sNamespace
common.SysCall(cmdStr)
cmdStr = "sudo helm install --namespace " + common.CB_K8s_Namespace + " " + common.CB_Helm_Release_Name + " -f " + common.FileStr + " ../helm-chart --debug"
cmdStr = "sudo helm install --namespace " + common.CBK8sNamespace + " " + common.CBHelmReleaseName + " -f " + common.FileStr + " ../helm-chart --debug"
//fmt.Println(cmdStr)
common.SysCall(cmdStr)
default:
Expand All @@ -74,13 +60,13 @@ func init() {
rootCmd.AddCommand(runCmd)

pf := runCmd.PersistentFlags()
pf.StringVarP(&common.FileStr, "file", "f", common.Not_Defined, "User-defined configuration file")
pf.StringVarP(&common.FileStr, "file", "f", common.NotDefined, "User-defined configuration file")

/*
switch common.CB_OPERATOR_MODE {
case common.Mode_DockerCompose:
switch common.CBOperatorMode {
case common.ModeDockerCompose:
pf.StringVarP(&common.FileStr, "file", "f", "../docker-compose-mode-files/docker-compose.yaml", "Path to Cloud-Barista Docker Compose YAML file")
case common.Mode_Kubernetes:
case common.ModeKubernetes:
pf.StringVarP(&common.FileStr, "file", "f", "../helm-chart/values.yaml", "Path to Cloud-Barista Helm chart file")
default:

Expand Down
Loading