Kaynağa Gözat

fix(ci): get code coverage output in ut (#1817)

* fix(ci): get code coverage output in ut

Signed-off-by: Jianxiang Ran <rxan_embedded@163.com>

* fix(ci): pick plugin test out

Signed-off-by: Jianxiang Ran <rxan_embedded@163.com>

* fix(ci): remove test coverage yaml

Signed-off-by: Jianxiang Ran <rxan_embedded@163.com>

* fix(ci): remove test for topo

Signed-off-by: Jianxiang Ran <rxan_embedded@163.com>

---------

Signed-off-by: Jianxiang Ran <rxan_embedded@163.com>
superxan 2 yıl önce
ebeveyn
işleme
b3968ef424

+ 29 - 1
.github/workflows/run_test_case.yaml

@@ -59,7 +59,7 @@ jobs:
         cd ../../../../
         cp -r sdk/python/example/pysam plugins/portable/pysam
         cp -r sdk/python/ekuiper plugins/portable/pysam/
-        go test --tags="edgex script test" ./...
+        go test --tags="edgex script test" --cover -covermode=atomic -coverpkg=./... -coverprofile=coverage.out $(go list ./... | grep -v "github.com/lf-edge/ekuiper/internal/topo/topotest/plugin")
     - name: run plugins test case
       run: |
         mkdir -p data/test/uploads
@@ -74,3 +74,31 @@ jobs:
       with:
         name: stream.log
         path: log/stream.log
+    - uses: actions/upload-artifact@v3
+      with:
+        name: coverprofile
+        path: |
+          *.out
+
+  codecov:
+    runs-on: ubuntu-latest
+    needs:
+      - run_test_case
+    steps:
+      - uses: actions/download-artifact@v3
+        with:
+          name: coverprofile
+      - name: Get cover files
+        id: files
+        run: |
+          files="$(find -maxdepth 1 -name '*.out' -exec readlink -f '{}' ';' | tr '\n' ',' | sed 's/,$//g')"
+          echo "files=$files" >> $GITHUB_OUTPUT
+      - uses: codecov/codecov-action@v3
+        with:
+          token: ${{ secrets.CODECOV_TOKEN }}
+          files: ${{ steps.files.outputs.files }} # optional
+          fail_ci_if_error: true # optional (default = false)
+          verbose: true # optional (default = false)
+      - uses: geekyeggo/delete-artifact@v2
+        with:
+          name: coverprofile

+ 0 - 86
.github/workflows/run_test_coverage.yaml

@@ -1,86 +0,0 @@
-name: Run test coverage
-
-concurrency:
-  group: code-coverage-${{ github.event_name }}-${{ github.ref }}
-  cancel-in-progress: true
-
-on:
-  push:
-    tags:
-      - "*"
-    ## For update codecov.io
-    branches:
-      - master**
-  pull_request:
-  release:
-    types:
-      - published
-
-jobs:
-  run_test_coverage:
-    runs-on: ubuntu-latest
-
-    steps:
-    - uses: actions/checkout@v3
-    - uses: actions/setup-go@v3
-      with:
-        go-version: '1.20'
-    - uses: actions/setup-python@v4
-      with:
-        python-version: '3.x'
-        architecture: 'x64'
-    - run: pip3 install pynng
-    - name: install lib
-      run: sudo apt-get update && sudo apt-get install libzmq3-dev -y
-    - name: run test coverage
-      run: |
-        curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash > /dev/null && source $HOME/.wasmedge/env
-        mkdir -p plugins/wasm
-        set -e -u -x
-        mkdir -p data
-        mkdir -p log
-        mkdir -p plugins/sinks
-        sed -i -r "s/debug: .*/debug: true/1" etc/kuiper.yaml
-        go build --buildmode=plugin -o plugins/sources/Random@v2.0.0.so extensions/sources/random/random.go
-        cp extensions/sources/random/random.yaml etc/sources/random.yaml
-        go build --buildmode=plugin -o plugins/functions/Echo.so extensions/functions/echo/echo.go
-        go build --buildmode=plugin -o plugins/functions/CountPlusOne@v1.0.0.so extensions/functions/countPlusOne/countPlusOne.go
-        go build --buildmode=plugin -o plugins/functions/AccumulateWordCount@v1.0.0.so extensions/functions/accumulateWordCount/accumulateWordCount.go
-        go build --buildmode=plugin -o data/test/helloworld.so internal/converter/protobuf/test/*.go
-        go build --buildmode=plugin -o data/test/myFormat.so internal/converter/custom/test/*.go
-        mkdir -p plugins/portable/mirror
-        cd sdk/go/example/mirror
-        go build -o ../../../../plugins/portable/mirror/mirror .
-        cp mirror.json ../../../../plugins/portable/mirror
-        cd ../../../../
-        cp -r sdk/python/example/pysam plugins/portable/pysam
-        cp -r sdk/python/ekuiper plugins/portable/pysam/
-        go test --tags="edgex script test" -cover $(go list ./... | grep -v "github.com/lf-edge/ekuiper/internal/service/test" | grep -v "github.com/lf-edge/ekuiper/internal/converter/protobuf/test" | grep -v "github.com/lf-edge/ekuiper/test" | grep -v "github.com/lf-edge/ekuiper/tools" | grep -v "github.com/lf-edge/ekuiper/internal/topo/topotest/plugin") -coverprofile coverage.out -coverpkg  ./...
-    - uses: actions/upload-artifact@v3
-      with:
-        name: coverprofile
-        path: | 
-          *.out
-
-  codecov:
-    runs-on: ubuntu-latest
-    needs:
-      - run_test_coverage
-    steps:
-    - uses: actions/download-artifact@v3
-      with:
-        name: coverprofile
-    - name: Get cover files
-      id: files
-      run: |
-        files="$(find -maxdepth 1 -name '*.out' -exec readlink -f '{}' ';' | tr '\n' ',' | sed 's/,$//g')"
-        echo "files=$files" >> $GITHUB_OUTPUT
-    - uses: codecov/codecov-action@v3
-      with:
-        token: ${{ secrets.CODECOV_TOKEN }}
-        files: ${{ steps.files.outputs.files }} # optional
-        fail_ci_if_error: true # optional (default = false)
-        verbose: true # optional (default = false)
-    - uses: geekyeggo/delete-artifact@v2
-      with:
-        name: coverprofile