diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..68466b1 --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,19 @@ +# This workflow will build a golang project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go + +name: Go + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + diff --git a/.harness/mypipeline.yaml b/.harness/mypipeline.yaml deleted file mode 100644 index 0e30c1a..0000000 --- a/.harness/mypipeline.yaml +++ /dev/null @@ -1 +0,0 @@ -some yaml diff --git a/README.md b/README.md index 33401a3..f85e411 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ $ ./go-sample-app ```bash $ curl http://localhost:8080?name=Nofar Hello, Nofar -Test +Test1 ``` @@ -21,7 +21,7 @@ Test - + diff --git a/config/.harness/Go_Demo.yaml b/config/.harness/Go_Demo.yaml index 0d9a343..8e2f748 100644 --- a/config/.harness/Go_Demo.yaml +++ b/config/.harness/Go_Demo.yaml @@ -1,112 +1,133 @@ pipeline: - name: Go Demo - identifier: Go_Demo - projectIdentifier: Product_Demos_CIE - orgIdentifier: default - tags: {} - stages: - - stage: - name: Build Test and Push - identifier: Test_Build_and_Push - type: CI - spec: - cloneCodebase: true - execution: - steps: - - step: - type: Run - name: Run Unit Tests - identifier: Run_Unit_Tests - spec: - connectorRef: account.nofar_dockerhub - image: golang:1.15 - command: |- - set +e - go get gotest.tools/gotestsum - gotestsum --format=standard-verbose --junitfile unit-tests.xml - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -tags netgo - exit 0 - reports: - type: JUnit - spec: - paths: - - "*.xml" - - parallel: - - step: - type: BuildAndPushDockerRegistry - name: Build and push image to DockerHub - identifier: Build_and_push_image_to_DockerHub - spec: - connectorRef: account.nofar_dockerhub - repo: bluebbb/godemo - tags: - - <+pipeline.sequenceId> - - step: - type: Run - name: show workspace content - identifier: show_workspace_content - spec: - connectorRef: account.nofar_dockerhub - image: alpine - command: ls - infrastructure: - type: KubernetesDirect + name: Go Demo + identifier: Go_Demo + projectIdentifier: Product_Demos_CIE + orgIdentifier: default + tags: {} + stages: + - stage: + name: Build Test and Push + identifier: Test_Build_and_Push + type: CI + spec: + cloneCodebase: true + execution: + steps: + - step: + type: Run + name: Run Unit Tests + identifier: Run_Unit_Tests + spec: + connectorRef: account.nofar_dockerhub + image: golang:1.15 + command: |- + set +e + go get gotest.tools/gotestsum + gotestsum --format=standard-verbose --junitfile unit-tests.xml + exit 0 + privileged: false + reports: + type: JUnit spec: - connectorRef: account.k8scluster - namespace: harness-delegate-pmdemo - serviceDependencies: [] - sharedPaths: - - "" - variables: - - name: myStageVar - type: String - value: stageVarValue - - stage: - name: Run Integration Test - identifier: Run_Integration_Test - type: CI + paths: + - "*.xml" + when: + stageStatus: Success + failureStrategies: [] + - step: + type: Run + name: Go Build + identifier: Go_Build + spec: + connectorRef: account.nofar_dockerhub + image: golang:1.15 + command: |- + set +e + go get gotest.tools/gotestsum + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -tags netgo + exit 0 + privileged: false + when: + stageStatus: Success + failureStrategies: [] + - step: + type: Run + name: print content + identifier: print_content + spec: + connectorRef: account.nofar_dockerhub + image: alpine + command: ls -a + privileged: false + - step: + type: BuildAndPushDockerRegistry + name: Build and push image to DockerHub + identifier: Build_and_push_image_to_DockerHub + spec: + connectorRef: account.nofar_dockerhub + repo: bluebbb/godemo + tags: + - latest + optimize: true + sharedPaths: + - "" + platform: + os: Linux + arch: Amd64 + runtime: + type: Cloud + spec: {} + variables: + - name: myStageVar + type: String + value: stageVarValue + - stage: + name: Run Integration Test + identifier: Run_Integration_Test + type: CI + spec: + cloneCodebase: false + execution: + steps: + - step: + type: Run + name: test connection to server + identifier: test_connection_to_server + spec: + connectorRef: account.nofar_dockerhub + image: curlimages/curl:7.69.1 + command: |- + sleep 5 + curl localhost:8080 + privileged: false + - step: + type: Run + name: echo + identifier: echo + spec: + connectorRef: account.nofar_dockerhub + image: alpine + command: echo "hello" + privileged: false + serviceDependencies: + - identifier: runhelloworldserver + name: Run Hello World Server + type: Service spec: - cloneCodebase: false - execution: - steps: - - step: - type: Run - name: test connection to server - identifier: test_connection_to_server - spec: - connectorRef: account.nofar_dockerhub - image: curlimages/curl:7.69.1 - command: |- - sleep 5 - curl localhost:8080 - privileged: false - - step: - type: Run - name: echo - identifier: echo - spec: - connectorRef: account.nofar_dockerhub - image: alpine - command: echo "hello" - privileged: false - serviceDependencies: - - identifier: runhelloworldserver - name: Run Hello World Server - type: Service - spec: - connectorRef: account.nofar_dockerhub - image: bluebbb/godemo:<+pipeline.sequenceId> - infrastructure: - useFromStage: Test_Build_and_Push - sharedPaths: - - "" - description: running integ tests - properties: - ci: - codebase: - connectorRef: account.goHelloWorldServer_repo - build: <+input> - variables: - - name: pipelineVar - type: String - value: pipelineVarValue + connectorRef: account.nofar_dockerhub + image: bluebbb/godemo:<+pipeline.sequenceId> + infrastructure: + useFromStage: Test_Build_and_Push + sharedPaths: + - "" + description: running integ tests + properties: + ci: + codebase: + connectorRef: BS1223 + repoName: goHelloWorldServer + build: <+input> + variables: + - name: pipelineVar + type: String + value: pipelineVarValue diff --git a/config/.harness/nofar_demo.yaml b/config/.harness/nofar_demo.yaml deleted file mode 100644 index 08aee95..0000000 --- a/config/.harness/nofar_demo.yaml +++ /dev/null @@ -1,26 +0,0 @@ -inputSet: - identifier: "nofar_demo" - name: "nofar_demo" - orgIdentifier: "default" - projectIdentifier: "Product_Demos_CIE" - pipeline: - identifier: "Go_Demo" - stages: - - stage: - identifier: "Run_Integration_Test" - type: "CI" - spec: - execution: - steps: - - step: - identifier: "test_connection_to_server" - type: "Run" - spec: - image: "curlimages/curl:7.69.1" - properties: - ci: - codebase: - build: - type: "branch" - spec: - branch: "main" diff --git a/config_123/.harness/go_pipeline.yaml b/config_123/.harness/go_pipeline.yaml deleted file mode 100644 index fe54dbb..0000000 --- a/config_123/.harness/go_pipeline.yaml +++ /dev/null @@ -1,31 +0,0 @@ -pipeline: - name: go pipeline - identifier: go_pipeline - projectIdentifier: Demo_slkdflkdjf - orgIdentifier: default - tags: {} - stages: - - stage: - name: s1 - identifier: s1 - description: "" - type: CI - spec: - cloneCodebase: false - execution: - steps: - - step: - type: Run - name: echo - identifier: echo - spec: - connectorRef: account.nofar_dockerhub - image: alpine - command: echo "hello" - privileged: false - serviceDependencies: [] - infrastructure: - type: KubernetesDirect - spec: - connectorRef: account.k8scluster - namespace: aaaa diff --git a/config_123/.harness/pipeline345.yaml b/config_123/.harness/pipeline345.yaml deleted file mode 100644 index 61287bd..0000000 --- a/config_123/.harness/pipeline345.yaml +++ /dev/null @@ -1,31 +0,0 @@ -pipeline: - name: go pipeline - identifier: go_pipeline234 - projectIdentifier: Demo_slkdflkdjf - orgIdentifier: default - tags: {} - stages: - - stage: - name: s1 - identifier: s1 - description: "" - type: CI - spec: - cloneCodebase: false - execution: - steps: - - step: - type: Run - name: echo - identifier: echo - spec: - connectorRef: account.nofar_dockerhub - image: alpine - command: echo "hello" - privileged: false - serviceDependencies: [] - infrastructure: - type: KubernetesDirect - spec: - connectorRef: account.k8scluster - namespace: aaaa diff --git a/hello_server.go b/hello_server.go index df038fd..573ff89 100644 --- a/hello_server.go +++ b/hello_server.go @@ -23,7 +23,7 @@ func CreateGreeting(name string) string { if name == "" { name = "Guest" } - return "Hello, " + name + "\n" + return "Hellooooo111, " + name + "\n" } func main() { diff --git a/hello_server_test.go b/hello_server_test.go index 2797605..f8caa02 100644 --- a/hello_server_test.go +++ b/hello_server_test.go @@ -16,21 +16,7 @@ func TestGreetingSpecificDemo(t *testing.T) { } } -func TestShowFailure(t *testing.T) { - greeting := CreateGreeting("Demo1") - if greeting != "Hello, Demo\n" { - t.Errorf("Intentional failure. got: %s, want: %s.", greeting, "Hello, Demo\n") - } -} -func TestGreetingDefault(t *testing.T) { - greeting := CreateGreeting("") - if greeting != "Hello, Guest\n" { - t.Errorf("Greeting was incorrect, got: %s, want: %s.", greeting, "Hello, Guest\n") - } -} - - diff --git a/subfolder/.harness/is1.yaml b/subfolder/.harness/is1.yaml deleted file mode 100644 index ee7847b..0000000 --- a/subfolder/.harness/is1.yaml +++ /dev/null @@ -1,19 +0,0 @@ -inputSet: - identifier: "is1" - name: "is1" - orgIdentifier: "Archit" - projectIdentifier: "nofar_git_exp3" - pipeline: - identifier: "test2" - stages: - - stage: - identifier: "stage1" - type: "CI" - spec: - execution: - steps: - - step: - identifier: "test" - type: "Run" - spec: - image: "alpine" diff --git a/subfolder/.harness/test2.yaml b/subfolder/.harness/test2.yaml deleted file mode 100644 index 0aa841a..0000000 --- a/subfolder/.harness/test2.yaml +++ /dev/null @@ -1,31 +0,0 @@ -pipeline: - name: test2 - identifier: test2 - projectIdentifier: nofar_git_exp3 - orgIdentifier: Archit - tags: {} - stages: - - stage: - name: stage1 - identifier: stage1 - description: "" - type: CI - spec: - cloneCodebase: false - execution: - steps: - - step: - type: Run - name: test - identifier: test - spec: - connectorRef: harnessImage - image: <+input> - command: echo 'hello moo' - privileged: false - serviceDependencies: [] - infrastructure: - type: KubernetesDirect - spec: - connectorRef: account.trtrtr - namespace: whatever diff --git a/test.txt b/test.txt deleted file mode 100644 index bbe838c..0000000 --- a/test.txt +++ /dev/null @@ -1,2 +0,0 @@ -A -s