You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ke...@apache.org on 2021/06/20 16:40:59 UTC

[skywalking-infra-e2e] branch main updated: Support GitHub Action (#20)

This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-infra-e2e.git


The following commit(s) were added to refs/heads/main by this push:
     new f1821ef  Support GitHub Action (#20)
f1821ef is described below

commit f1821ef7c3c20e58fa44ef724deabaae5cd72ed8
Author: mrproliu <74...@qq.com>
AuthorDate: Mon Jun 21 00:40:54 2021 +0800

    Support GitHub Action (#20)
---
 README.md                   | 11 +++++++++++
 action.yaml                 | 45 +++++++++++++++++++++++++++++++++++++++++++++
 commands/verify/verify.go   | 11 +++++------
 examples/compose/e2e.yaml   |  2 +-
 internal/util/utils.go      |  4 ++--
 test/verify/3.expected.yaml |  6 ++++--
 6 files changed, 68 insertions(+), 11 deletions(-)

diff --git a/README.md b/README.md
index 9aea96f..a3f10fb 100644
--- a/README.md
+++ b/README.md
@@ -10,6 +10,17 @@ SkyWalking Infra E2E is the next generation End-to-End Testing framework that ai
 
 - **[The design doc](https://skywalking.apache.org/blog/e2e-design/).**
 
+## GitHub Actions
+
+To use skywalking-infra-e2e in GitHub Actions, add a step in your GitHub workflow.
+
+```xml
+- name: Run E2E Test
+  uses: apache/skywalking-infra-e2e@main      # always prefer to use a revision instead of `main`.
+  with:
+    e2e-file: e2e.yaml                        # need to run E2E file path
+```
+
 ## License
 
 [Apache License 2.0](https://github.com/apache/skywalking-infra-e2e/blob/master/LICENSE)
diff --git a/action.yaml b/action.yaml
new file mode 100644
index 0000000..828a004
--- /dev/null
+++ b/action.yaml
@@ -0,0 +1,45 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+
+name: SkyWalking Infra E2E
+description: End-to-End Tesing framework that help to set up, verify E2E tests.
+author: Apache SkyWalking
+inputs:
+  e2e-file:
+    description: File path of e2e file
+    required: true
+
+runs:
+  using: "composite"
+  steps:
+    - shell: bash
+      run: |
+        mkdir -p /tmp/skywalking-infra-e2e/bin
+    - shell: bash
+      run: |
+        cd "$GITHUB_ACTION_PATH"
+        go mod download && make linux && mv bin/linux/e2e /tmp/skywalking-infra-e2e/bin/e2e
+    - shell: bash
+      run: |
+        cd /tmp/skywalking-infra-e2e
+        git clone https://github.com/apache/skywalking-cli.git
+        git -C skywalking-cli reset --hard 21ba64dd2ddfd6cfeca14801e7c3888f1befc3ca
+        cd skywalking-cli
+        make build && mv bin/swctl-*-linux-amd64 ../bin/swctl
+    - shell: bash
+      run: |
+        export PATH="$PATH:/tmp/skywalking-infra-e2e/bin"
+        e2e run -c "${{ inputs.e2e-file }}"
\ No newline at end of file
diff --git a/commands/verify/verify.go b/commands/verify/verify.go
index 290cf26..972769a 100644
--- a/commands/verify/verify.go
+++ b/commands/verify/verify.go
@@ -69,18 +69,17 @@ func verifySingleCase(expectedFile, actualFile, query string) error {
 		sourceName = query
 		actualData, err = util.ExecuteCommand(query)
 		if err != nil {
-			return fmt.Errorf("failed to execute the query: %v", err)
+			return fmt.Errorf("failed to execute the query: %s, output: %s, error: %v", query, actualData, err)
 		}
 	}
 
 	if err = verifier.Verify(actualData, expectedData); err != nil {
-		logger.Log.Warnf("failed to verify the output: %s\n", sourceName)
 		if me, ok := err.(*verifier.MismatchError); ok {
-			fmt.Println(me.Error())
+			return fmt.Errorf("failed to verify the output: %s, error: %v", sourceName, me.Error())
 		}
-	} else {
-		logger.Log.Infof("verified the output: %s\n", sourceName)
+		return fmt.Errorf("failed to verify the output: %s", sourceName)
 	}
+	logger.Log.Infof("verified the output: %s\n", sourceName)
 	return nil
 }
 
@@ -95,7 +94,7 @@ func DoVerifyAccordingConfig() error {
 	for _, v := range e2eConfig.Verify {
 		if v.GetExpected() != "" {
 			if err := verifySingleCase(v.GetExpected(), v.GetActual(), v.Query); err != nil {
-				logger.Log.Errorf("%v", err)
+				return err
 			}
 		} else {
 			logger.Log.Error("the expected data file is not specified")
diff --git a/examples/compose/e2e.yaml b/examples/compose/e2e.yaml
index adfb961..b676518 100644
--- a/examples/compose/e2e.yaml
+++ b/examples/compose/e2e.yaml
@@ -36,5 +36,5 @@ verify:
     expected: ../../test/verify/1.expected.yaml
   - actual: ../../test/verify/2.actual.yaml
     expected: ../../test/verify/2.expected.yaml
-  - query: swctl --display yaml --base-url=http://${e2e_host_and_port_oap_12800}/graphql service ls
+  - query: swctl --display yaml --base-url=http://127.0.0.1:${oap_12800}/graphql service ls
     expected: ../../test/verify/3.expected.yaml
\ No newline at end of file
diff --git a/internal/util/utils.go b/internal/util/utils.go
index fc5bda4..495586c 100644
--- a/internal/util/utils.go
+++ b/internal/util/utils.go
@@ -61,10 +61,10 @@ func ExecuteCommand(cmd string) (string, error) {
 	command.Stdout = &outinfo
 
 	if err := command.Start(); err != nil {
-		return "", err
+		return outinfo.String(), err
 	}
 	if err := command.Wait(); err != nil {
-		return "", err
+		return outinfo.String(), err
 	}
 	return outinfo.String(), nil
 }
diff --git a/test/verify/3.expected.yaml b/test/verify/3.expected.yaml
index 40f5133..01b8e9f 100644
--- a/test/verify/3.expected.yaml
+++ b/test/verify/3.expected.yaml
@@ -15,8 +15,10 @@
 # specific language governing permissions and limitations
 # under the License.
 
-{{- contains . }}
+{{if . }}
 - id: {{ notEmpty .id }}
   name: {{ notEmpty .name }}
   group: ""
-{{- end }}
+{{else}}
+[]
+{{end}}
\ No newline at end of file