diff --git a/.github/pr-title-checker-config.json b/.github/pr-title-checker-config.json index 1b386639cc..1449dd78e6 100644 --- a/.github/pr-title-checker-config.json +++ b/.github/pr-title-checker-config.json @@ -5,12 +5,19 @@ }, "CHECKS": { "prefixes": [ - "fix: ", - "feat: ", - "feature: ", - "doc: ", - "ci: ", - "chore: " + "fix", + "feat", + "feature", + "docs", + "ci", + "chore", + "test", + "revert", + "style", + "refactor", + "sync", + "perf", + "merge" ], "regexp": "docs\\(v[0-9]\\): ", "regexpFlags": "i", diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 70e899b411..0f93ca657e 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -1,17 +1,12 @@ -name: "CodeQL" +name: Layotto Env Pipeline 🌊 on: - push: - branches: [master, ] - pull_request: - # The branches below must be a subset of the branches above - branches: [master] schedule: - cron: '0 4 * * 5' jobs: analyse: - name: Analyse + name: 🍀 CodeQL runs-on: ubuntu-latest steps: diff --git a/.github/workflows/dead-link-checker.yaml b/.github/workflows/dead-link-checker.yaml index 7f3c6628ca..242c789d0d 100644 --- a/.github/workflows/dead-link-checker.yaml +++ b/.github/workflows/dead-link-checker.yaml @@ -1,4 +1,4 @@ -name: Dead Link Checker +name: Layotto Env Pipeline 🌊 on: pull_request: @@ -6,7 +6,8 @@ on: - main jobs: - CheckDeadLinks: + check: + name: "🍀 DeadLink Validation" runs-on: ubuntu-latest timeout-minutes: 30 steps: @@ -22,4 +23,4 @@ jobs: nohup docsify serve docs -p 3000 & - name: Check dead links in all the .md files - run: make check-dead-link \ No newline at end of file + run: make style.deadlink diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml deleted file mode 100644 index cc8b95f918..0000000000 --- a/.github/workflows/github-actions.yml +++ /dev/null @@ -1,101 +0,0 @@ -name: test - -on: - push: - branches: [main, develop] - pull_request: - branches: "*" - -jobs: - - build: - name: ${{ matrix.os }} - Go ${{ matrix.go_version }} - runs-on: ${{ matrix.os }} - strategy: - # If you want to matrix build , you can append the following list. - matrix: - go_version: - - 1.14.13 - os: - - ubuntu-latest - - env: - DING_TOKEN: ${{ secrets.DING_TOKEN }} - DING_SIGN: ${{ secrets.DING_SIGN }} - - steps: - - name: Set up Go 1.x - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go_version }} - id: go - - - name: Check out code into the Go module directory - uses: actions/checkout@v2 - - - name: Cache dependencies - uses: actions/cache@v2.1.4 - with: - # Cache - path: ~/go/pkg/mod - # Cache key - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} - # An ordered list of keys to use for restoring the cache if no cache hit occurred for key - restore-keys: | - ${{ runner.os }}-go- - - - name: Get dependencies - run: | - if [ -f Gopkg.toml ]; then - curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh - dep ensure - else - go get -v -t -d ./... - fi - - - name: gofmt - run: | - go fmt ./... && git status && [[ -z `git status -s` ]] - # diff -u <(echo -n) <(gofmt -d -s .) - - #- name: Install go ci lint - # run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.27.0 - - #- name: Run Linter - # run: golangci-lint run --timeout=10m -v - - - name: ut - run: make coverage - - - name: Post Coverage - run: bash <(curl -s https://codecov.io/bash) - - wasm-integrate: - name: wasm-integrate - runs-on: ubuntu-latest - steps: - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: 1.14.13 - - - name: Check out code - uses: actions/checkout@v2 - - - name: Run Integrate tests. - run: make wasm-integrate-ci - - runtime-integrate: - name: runtime-integrate - runs-on: ubuntu-latest - steps: - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: 1.14.13 - - - name: Check out code - uses: actions/checkout@v2 - - - name: Run Integrate tests. - run: make runtime-integrate-ci \ No newline at end of file diff --git a/.github/workflows/layotto-ci.yml b/.github/workflows/layotto-ci.yml new file mode 100644 index 0000000000..6bd67136fd --- /dev/null +++ b/.github/workflows/layotto-ci.yml @@ -0,0 +1,285 @@ +name: Layotto Dev Pipeline 🌊 + +# Ignore some changes of commits: +# 1. changes in .ci/ +# 2. changes in docs/ +# 3. changes in markdown files + +on: + push: + branches: [main] + paths-ignore: + - 'docs/**' + - '**/*.md' + pull_request: + branches: "*" + paths-ignore: + - 'docs/**' + - '**/*.md' + +jobs: + style-check: + name: "🌈 Go Style Check" + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.18.1 + - name: Format Go + run: | + make check.style + + golangci-lint: + name: "👀 Go CI Linter" + needs: [style-check] + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.18.1 + # TODO(@Xunzhuo): open it after fixing lint errors + # - name: Go Lint Test + # run: make check.lint + + go-unit-test: + name: "👀 Go Unit Test" + needs: [style-check] + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.18.1 + # TODO(@Xunzhuo): open it after fixing unit test errors + # - name: Go Unit Test + # run: make check.unit + + coverage: + name: "🤔 Coverage Analysis" + needs: [go-unit-test,golangci-lint,style-check] + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + - name: Test Coverage + run: make style.coverage + - name: Post Coverage + run: bash <(curl -s https://codecov.io/bash) + + wasm-integrate: + name: "⚙️ Integrate with WASM" + needs: [coverage] + runs-on: ubuntu-latest + steps: + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.18.1 + - name: Check out code + uses: actions/checkout@v2 + - name: Run Integrate tests + run: make integrate.wasm + + runtime-integrate: + name: "⚙️ Integrate with Runtime" + needs: [coverage] + runs-on: ubuntu-latest + steps: + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.18.1 + - name: Check out code + uses: actions/checkout@v2 + - name: Run Integrate tests + run: make integrate.runtime + + build-binary-darwin-amd64-artifact: + name: "🧳 Darwin AMD64 Artifact" + needs: [runtime-integrate,wasm-integrate] + runs-on: ubuntu-latest + steps: + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.18.1 + - name: Check out code + uses: actions/checkout@v2 + - name: Build Artifact + run: | + make go.build.darwin_amd64.layotto + - name: Publish Artifact + uses: actions/upload-artifact@v2.2.4 + with: + name: layotto.darwin_amd64 + path: _output/darwin/amd64/layotto + retention-days: 5 + if-no-files-found: error + + build-binary-darwin-arm64-artifact: + name: "🧳 Darwin ARM64 Artifact" + needs: [runtime-integrate,wasm-integrate] + runs-on: ubuntu-latest + steps: + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.18.1 + - name: Check out code + uses: actions/checkout@v2 + - name: Build Artifact + run: | + make go.build.darwin_arm64.layotto + - name: Publish Artifact + uses: actions/upload-artifact@v2.2.4 + with: + name: layotto.darwin_arm64 + path: _output/darwin/arm64/layotto + retention-days: 5 + if-no-files-found: error + + build-binary-linux-amd64-artifact: + name: "🧳 Linux AMD64 Artifact" + needs: [runtime-integrate,wasm-integrate] + runs-on: ubuntu-latest + steps: + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.18.1 + - name: Check out code + uses: actions/checkout@v2 + - name: Build Artifact + run: | + make go.build.linux_amd64.layotto + - name: Publish Artifact + uses: actions/upload-artifact@v2.2.4 + with: + name: layotto.linux_amd64 + path: _output/linux/amd64/layotto + retention-days: 5 + if-no-files-found: error + + build-binary-linux-arm64-artifact: + name: "🧳 Linux ARM64 Artifact" + needs: [runtime-integrate,wasm-integrate] + runs-on: ubuntu-latest + steps: + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.18.1 + - name: Check out code + uses: actions/checkout@v2 + - name: Build Artifact + run: | + make go.build.linux_arm64.layotto + - name: Publish Artifact + uses: actions/upload-artifact@v2.2.4 + with: + name: layotto.linux_arm64 + path: _output/linux/arm64/layotto + retention-days: 5 + if-no-files-found: error + + build-wasm-binary-linux-amd64-artifact: + name: "🧳 Linux AMD64 WASM Artifact" + needs: [wasm-integrate] + runs-on: ubuntu-latest + steps: + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.18.1 + - name: Check out code + uses: actions/checkout@v2 + # TODO(@Xunzhuo): open it after stabilizing wasm cmds + # - name: Build Artifact + # run: | + # make wasm + # - name: Publish Artifact + # uses: actions/upload-artifact@v2.2.4 + # with: + # name: layotto.wasm.linux_amd64 + # path: _output/linux/amd64/layotto + # retention-days: 5 + # if-no-files-found: error + + build-push-wasm-image: + name: "🎉 Linux AMD64 WASM Image" + needs: [build-wasm-binary-linux-amd64-artifact,build-binary-linux-arm64-artifact,build-binary-linux-amd64-artifact,build-binary-darwin-amd64-artifact,build-binary-darwin-arm64-artifact] + if: github.ref_name == 'main' + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + # TODO(@Xunzhuo): open it after stabilizing wasm cmds + # - name: Login to DockerHub + # uses: docker/login-action@v1 + # with: + # username: ${{ secrets.DOCKERHUB_USERNAME }} + # password: ${{ secrets.DOCKERHUB_TOKEN }} + # - name: Build Layotto Latest Image + # run: | + # make wasm.image VERSION=latest + # - name: Push Image to DockerHub + # run: | + # make wasm.image.push VERSION=latest + + build-push-linux-amd64-image: + name: "🎉 Linux AMD64 Image" + needs: [build-wasm-binary-linux-amd64-artifact,build-binary-linux-arm64-artifact,build-binary-linux-amd64-artifact,build-binary-darwin-amd64-artifact,build-binary-darwin-arm64-artifact] + if: github.ref_name == 'main' + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build Layotto Latest Image + run: | + make image.build.linux_amd64.layotto VERSION=latest + - name: Push Image to DockerHub + run: | + make image.push.linux_amd64.layotto VERSION=latest + + build-push-linux-arm64-image: + name: "🎉 Linux ARMD64 Image" + needs: [build-wasm-binary-linux-amd64-artifact,build-binary-linux-arm64-artifact,build-binary-linux-amd64-artifact,build-binary-darwin-amd64-artifact,build-binary-darwin-arm64-artifact] + if: github.ref_name == 'main' + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build Layotto Latest Image + run: | + make image.build.linux_arm64.layotto VERSION=latest + - name: Push Image to DockerHub + run: | + make image.push.linux_arm64.layotto VERSION=latest diff --git a/.github/workflows/layotto-release.yml b/.github/workflows/layotto-release.yml new file mode 100644 index 0000000000..7d5a0cd46f --- /dev/null +++ b/.github/workflows/layotto-release.yml @@ -0,0 +1,271 @@ +name: Layotto Release Pipeline 🌊 + +on: + create + +jobs: + style-check: + name: "🌈 Go Style Check" + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + - name: Set up Go + if: ${{ startsWith(github.ref, 'refs/tags/') }} + uses: actions/setup-go@v2 + with: + go-version: 1.18.1 + - name: Format Go + run: | + make check.style + + golangci-lint: + name: "👀 Go CI Linter" + needs: [style-check] + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + - name: Set up Go + if: ${{ startsWith(github.ref, 'refs/tags/') }} + uses: actions/setup-go@v3 + with: + go-version: 1.18.1 + # TODO(@Xunzhuo): open it after fixing lint errors + # - name: Go Lint Test + # run: make check.lint + + go-unit-test: + name: "👀 Go Unit Test" + needs: [style-check] + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + - name: Set up Go + if: ${{ startsWith(github.ref, 'refs/tags/') }} + uses: actions/setup-go@v3 + with: + go-version: 1.18.1 + # TODO(@Xunzhuo): open it after fixing unit test errors + # - name: Go Unit Test + # run: make check.unit + + coverage: + name: "🤔 Coverage Analysis" + needs: [go-unit-test,golangci-lint,style-check] + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + - name: Test Coverage + run: make style.coverage + - name: Post Coverage + run: bash <(curl -s https://codecov.io/bash) + + wasm-integrate: + name: "⚙️ Integrate with WASM" + needs: [coverage] + runs-on: ubuntu-latest + steps: + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.18.1 + - name: Check out code + uses: actions/checkout@v2 + - name: Run Integrate tests + run: make integrate.wasm + + runtime-integrate: + name: "⚙️ Integrate with Runtime" + needs: [coverage] + runs-on: ubuntu-latest + steps: + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.18.1 + - name: Check out code + uses: actions/checkout@v2 + - name: Run Integrate tests + run: make integrate.runtime + + build-binary-darwin-amd64-artifact: + name: "🧳 Darwin AMD64 Artifact" + needs: [runtime-integrate,wasm-integrate] + runs-on: ubuntu-latest + steps: + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.18.1 + - name: Check out code + uses: actions/checkout@v2 + - name: Build Artifact + run: | + make go.build.darwin_amd64.layotto + - name: Publish Artifact + uses: actions/upload-artifact@v2.2.4 + with: + name: layotto.darwin_amd64 + path: _output/darwin/amd64/layotto + retention-days: 5 + if-no-files-found: error + + build-binary-darwin-arm64-artifact: + name: "🧳 Darwin ARM64 Artifact" + needs: [runtime-integrate,wasm-integrate] + runs-on: ubuntu-latest + steps: + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.18.1 + - name: Check out code + uses: actions/checkout@v2 + - name: Build Artifact + run: | + make go.build.darwin_arm64.layotto + - name: Publish Artifact + uses: actions/upload-artifact@v2.2.4 + with: + name: layotto.darwin_arm64 + path: _output/darwin/arm64/layotto + retention-days: 5 + if-no-files-found: error + + build-binary-linux-amd64-artifact: + name: "🧳 Linux AMD64 Artifact" + needs: [runtime-integrate,wasm-integrate] + runs-on: ubuntu-latest + steps: + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.18.1 + - name: Check out code + uses: actions/checkout@v2 + - name: Build Artifact + run: | + make go.build.linux_amd64.layotto + - name: Publish Artifact + uses: actions/upload-artifact@v2.2.4 + with: + name: layotto.linux_amd64 + path: _output/linux/amd64/layotto + retention-days: 5 + if-no-files-found: error + + build-binary-linux-arm64-artifact: + name: "🧳 Linux ARM64 Artifact" + needs: [runtime-integrate,wasm-integrate] + runs-on: ubuntu-latest + steps: + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.18.1 + - name: Check out code + uses: actions/checkout@v2 + - name: Build Artifact + run: | + make go.build.linux_arm64.layotto + - name: Publish Artifact + uses: actions/upload-artifact@v2.2.4 + with: + name: layotto.linux_arm64 + path: _output/linux/arm64/layotto + retention-days: 5 + if-no-files-found: error + + build-wasm-binary-linux-amd64-artifact: + name: "🧳 Linux AMD64 WASM Artifact" + needs: [wasm-integrate] + runs-on: ubuntu-latest + steps: + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.18.1 + - name: Check out code + uses: actions/checkout@v2 + # TODO(@Xunzhuo): open it after stabilizing wasm cmds + # - name: Build Artifact + # run: | + # make wasm + # - name: Publish Artifact + # uses: actions/upload-artifact@v2.2.4 + # with: + # name: layotto.wasm.linux_amd64 + # path: _output/linux/amd64/layotto + # retention-days: 5 + # if-no-files-found: error + + build-push-wasm-image: + name: "🎉 Linux AMD64 WASM Image" + needs: [build-wasm-binary-linux-amd64-artifact,build-binary-linux-arm64-artifact,build-binary-linux-amd64-artifact,build-binary-darwin-amd64-artifact,build-binary-darwin-arm64-artifact] + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + # TODO(@Xunzhuo): open it after stabilizing wasm cmds + # - name: Login to DockerHub + # uses: docker/login-action@v1 + # with: + # username: ${{ secrets.DOCKERHUB_USERNAME }} + # password: ${{ secrets.DOCKERHUB_TOKEN }} + # - name: Build Layotto Latest Image + # run: | + # make wasm.image + # - name: Push Image to DockerHub + # run: | + # make wasm.image.push + + build-push-linux-amd64-image: + name: "🎉 Linux AMD64 Image" + needs: [build-wasm-binary-linux-amd64-artifact,build-binary-linux-arm64-artifact,build-binary-linux-amd64-artifact,build-binary-darwin-amd64-artifact,build-binary-darwin-arm64-artifact] + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build Layotto Latest Image + run: | + make image.build.linux_amd64.layotto + - name: Push Image to DockerHub + run: | + make image.push.linux_amd64.layotto + + build-push-linux-arm64-image: + name: "🎉 Linux ARMD64 Image" + needs: [build-wasm-binary-linux-amd64-artifact,build-binary-linux-arm64-artifact,build-binary-linux-amd64-artifact,build-binary-darwin-amd64-artifact,build-binary-darwin-arm64-artifact] + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build Layotto Latest Image + run: | + make image.build.linux_arm64.layotto + - name: Push Image to DockerHub + run: | + make image.push.linux_arm64.layotto diff --git a/.github/workflows/license-checker.yml b/.github/workflows/license-checker.yml index 640801d977..8e5565dda9 100644 --- a/.github/workflows/license-checker.yml +++ b/.github/workflows/license-checker.yml @@ -1,4 +1,4 @@ -name: Check License +name: Layotto Env Pipeline 🌊 on: push: @@ -9,7 +9,8 @@ on: - main jobs: - check-license: + check: + name: "🍀 License Validation" runs-on: ubuntu-latest steps: @@ -19,4 +20,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - log: info \ No newline at end of file + log: info diff --git a/.github/workflows/pr_title_check.yml b/.github/workflows/pr-title-checker.yml similarity index 80% rename from .github/workflows/pr_title_check.yml rename to .github/workflows/pr-title-checker.yml index d9542372e2..e3ce0d2377 100644 --- a/.github/workflows/pr_title_check.yml +++ b/.github/workflows/pr-title-checker.yml @@ -1,6 +1,7 @@ -name: "PR Title Checker" +name: Layotto Env Pipeline 🌊 + on: - pull_request_target: + pull_request: types: - opened - edited @@ -10,10 +11,11 @@ on: jobs: check: + name: "🍀 Title Validation" runs-on: ubuntu-latest steps: - uses: thehanimo/pr-title-checker@v1.3.4 with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} pass_on_octokit_error: false - configuration_path: ".github/pr-title-checker-config.json" \ No newline at end of file + configuration_path: ".github/pr-title-checker-config.json" diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index aac985417b..0000000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,41 +0,0 @@ -# Auto build and push docker image to docker hub when releasing tags ---- -name: Auto Layotto Build and Push image - -on: - create - -jobs: - publish_image: - name: Build and Push Layotto image - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v2.3.5 - with: - submodules: recursive - - - name: Extract Tags name - if: ${{ startsWith(github.ref, 'refs/tags/') }} - id: tag_env - shell: bash - run: | - echo "##[set-output name=version;]$(echo ${GITHUB_REF##*/})" - - - name: Login to Docker Hub - if: ${{ startsWith(github.ref, 'refs/tags/') }} - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build Layotto Image - if: ${{ startsWith(github.ref, 'refs/tags/') }} - run: | - make image tag=${{ steps.tag_env.outputs.version }} - - - name: Push Layotto Docker image - if: ${{ startsWith(github.ref, 'refs/tags/') }} - run: | - docker push layotto/layotto:${{ steps.tag_env.outputs.version }} - diff --git a/.github/workflows/test-quickstart.yml b/.github/workflows/quickstart-checker.yml similarity index 57% rename from .github/workflows/test-quickstart.yml rename to .github/workflows/quickstart-checker.yml index 2e1ed33437..190ed0f4fb 100644 --- a/.github/workflows/test-quickstart.yml +++ b/.github/workflows/quickstart-checker.yml @@ -1,4 +1,4 @@ -name: test-quickstart +name: Layotto Env Pipeline 🌊 on: push: @@ -10,20 +10,13 @@ on: jobs: test: - name: ${{ matrix.os }} - Go ${{ matrix.go_version }} - runs-on: ${{ matrix.os }} - strategy: - # If you want to matrix build , you can append the following list. - matrix: - go_version: - - 1.14.13 - os: - - ubuntu-latest + name: "🍀 Quickstart Validation" + runs-on: ubuntu-latest steps: - name: Set up Go 1.x uses: actions/setup-go@v2 with: - go-version: ${{ matrix.go_version }} + go-version: 1.14.13 - name: Check out code into the Go module directory uses: actions/checkout@v2 @@ -34,10 +27,10 @@ jobs: # Cache path: ~/go/pkg/mod # Cache key - key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + key: ubuntu-latest-go-${{ hashFiles('**/go.sum') }} # An ordered list of keys to use for restoring the cache if no cache hit occurred for key restore-keys: | - ${{ runner.os }}-go- + ubuntu-latest-go- - name: Get dependencies run: | @@ -48,10 +41,5 @@ jobs: go get -v -t -d ./... fi - - name: Download mdsh - run: | - curl -o mdsh.sh https://raw.githubusercontent.com/seeflood/mdsh/master/bin/mdsh - chmod +x mdsh.sh - - name: Test quickstart - run: make test-quickstart \ No newline at end of file + run: make style.quickstart diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index c6bd7a32fd..1ac40b6c81 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -1,10 +1,11 @@ -name: 'Close stale issues and PRs' +name: Layotto Env Pipeline 🌊 on: schedule: - cron: '30 1 * * *' jobs: stale: + name: "🍀 Update Stale Status" runs-on: ubuntu-latest steps: - uses: actions/stale@v4 @@ -31,4 +32,4 @@ jobs: stale-issue-label: 'stale' exempt-issue-labels: 'pinned,good first issue,help wanted' stale-pr-label: 'stale' - exempt-pr-labels: 'pinned' \ No newline at end of file + exempt-pr-labels: 'pinned' diff --git a/.gitignore b/.gitignore index 00e15e868b..1fb8a362a3 100644 --- a/.gitignore +++ b/.gitignore @@ -4,16 +4,17 @@ build/bundles .idea .test .out -layotto !./.gitignore IMAGEBUILD/ coverage.txt .DS_Store logs/ *.swp +/layotto /cover.out vendor/ demo/state/redis/client +_output/ # node node_modules/ diff --git a/.golangci.yml b/.golangci.yml index 90f5091ab9..c28b7261c3 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,152 +1,53 @@ -# This file contains all available configuration options -# with their default values. - -# options for analysis running -run: - # default concurrency is a available CPU number - concurrency: 4 - - # timeout for analysis, e.g. 30s, 5m, default is 1m - deadline: 10m - - # exit code when at least one issue was found, default is 1 - issues-exit-code: 1 - - # include test files or not, default is true - tests: true - - # list of build tags, all linters use it. Default is empty list. - build-tags: [] - - # which dirs to skip: they won't be analyzed; - # can use regexp here: generated.*, regexp is applied on full path; - # default value is empty list, but next dirs are always skipped independently - # from this option's value: - # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ - skip-dirs: [] - - # which files to skip: they will be analyzed, but issues from them - # won't be reported. Default value is empty list, but there is - # no need to include all autogenerated files, we confidently recognize - # autogenerated files. If it's not please let us know. - skip-files: [] - -# output configuration options -output: - # colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number" - format: json - - # print lines of code with issue, default is true - print-issued-lines: true - - # print linter name in the end of issue text, default is true - print-linter-name: true - - -# all available settings of specific linters -linters-settings: - errcheck: - # report about not checking of errors in type assetions: `a := b.(MyStruct)`; - # default is false: such cases aren't reported by default. - check-type-assertions: false - - # report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`; - # default is false: such cases aren't reported by default. - check-blank: false - govet: - # report about shadowed variables - check-shadowing: true - golint: - # minimal confidence for issues, default is 0.8 - min-confidence: 0.8 - gofmt: - # simplify code: gofmt with `-s` option, true by default - simplify: true - goimports: - # put imports beginning with prefix after 3rd-party packages; - # it's a comma-separated list of prefixes - local-prefixes: mosn.io/layotto - gocyclo: - # minimal code complexity to report, 30 by default (but we recommend 10-20) - min-complexity: 10 - maligned: - # print struct with more effective memory layout or not, false by default - suggest-new: true - dupl: - # tokens count to trigger issue, 150 by default - threshold: 100 - goconst: - # minimal length of string constant, 3 by default - min-len: 3 - # minimal occurrences count to trigger, 3 by default - min-occurrences: 3 - depguard: - list-type: blacklist - include-go-root: false - packages: - - github.com/davecgh/go-spew/spew - misspell: - # Correct spellings using locale preferences for US or UK. - # Default is to use a neutral variety of English. - # Setting locale to US will correct the British spelling of 'colour' to 'color'. - locale: US - ignore-words: - - someword - lll: - # max line length, lines longer will be reported. Default is 120. - # '\t' is counted as 1 character by default, and can be changed with the tab-width option - line-length: 120 - # tab width in spaces. Default to 1. - tab-width: 1 - unused: - # treat code as a program (not a library) and report unused exported identifiers; default is false. - # XXX: if you enable this setting, unused will report a lot of false-positives in text editors: - # if it's called for subdir of a project it can't find funcs usages. All text editor integrations - # with golangci-lint call it on a directory with the changed file. - check-exported: false - unparam: - # Inspect exported functions, default is false. Set to true if no external program/library imports your code. - # XXX: if you enable this setting, unparam will report a lot of false-positives in text editors: - # if it's called for subdir of a project it can't find external interfaces. All text editor integrations - # with golangci-lint call it on a directory with the changed file. - check-exported: false - nakedret: - # make an issue if func has more lines of code than this setting and it has naked returns; default is 30 - max-func-lines: 30 - prealloc: - # XXX: we don't recommend using this linter before doing performance profiling. - # For most programs usage of prealloc will be a premature optimization. - - # Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them. - # True by default. - simple: true - range-loops: true # Report preallocation suggestions on range loops, true by default - for-loops: false # Report preallocation suggestions on for loops, false by default - gocritic: - # Which checks should be disabled; can't be combined with 'enabled-checks'; default is empty - disabled-checks: - - regexpMust - - # Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint` run to see all tags and checks. - # Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags". - enabled-tags: - - performance - - settings: # settings passed to gocritic - captLocal: # must be valid enabled check name - paramsOnly: true - -linters: - enable: - - deadcode - - govet - - golint - - varcheck - - errcheck - - goconst - - structcheck - - dupl - - interfacer - - goimports - disable-all: true - fast: false +run : + deadline : 10m + tests : true + modules-download-mode : readonly + skip-dirs : + - spec/proto + skip-files : + - .pb.go + # - _test.go + + +linters : + disable-all : true + enable : + - unused + - gofmt + - ineffassign + - govet + - deadcode + - structcheck + - varcheck + - typecheck + - golint + - unconvert + - staticcheck + - gosimple + - bodyclose + - goimports + - rowserrcheck + - goconst + - lll + - gocyclo + +issues : + exclude-rules : + - linters : + - staticcheck + text : "SA1019:" + +linters-settings : + goconst : + min-len : 2 + min-occurrences : 4 + gocyclo : + min-complexity : 20 + goimports : + local-prefixes : mosn.io/layotto + golint : + min-confidence : 0 + lll : + line-length : 120 + errcheck : + check-type-assertions : true diff --git a/.licenserc.yaml b/.licenserc.yaml index 9eabcbe0f7..00350a895d 100644 --- a/.licenserc.yaml +++ b/.licenserc.yaml @@ -21,6 +21,7 @@ header: - 'pkg/' - 'components/' - 'sdk/' + - 'make/' paths-ignore: # js related diff --git a/Makefile b/Makefile index edd6dfb689..6af8928476 100644 --- a/Makefile +++ b/Makefile @@ -1,73 +1,279 @@ -SHELL = /bin/bash -export GO111MODULE=on - -MAJOR_VERSION = $(shell cat VERSION) -TARGET = layotto -ARM_TARGET = layotto.aarch64 -PROJECT_NAME = mosn.io/layotto -CONFIG_FILE = runtime_config.json -BUILD_IMAGE = godep-builder -GIT_VERSION = $(shell git log -1 --pretty=format:%h) -SCRIPT_DIR = $(shell pwd)/etc/script - -IMAGE_NAME = layotto -REPOSITORY = layotto/${IMAGE_NAME} -IMAGE_BUILD_DIR = IMAGEBUILD - -IMAGE_TAG := $(tag) - -ifeq ($(IMAGE_TAG),) -IMAGE_TAG := dev-${MAJOR_VERSION}-${GIT_VERSION} -endif - -build-local: - @rm -rf build/bundles/${MAJOR_VERSION}/binary - CGO_ENABLED=1 go build \ - -ldflags "-B 0x$(shell head -c20 /dev/urandom|od -An -tx1|tr -d ' \n') -X main.Version=${MAJOR_VERSION}(${GIT_VERSION}) -X ${PROJECT_NAME}/pkg/types.IstioVersion=${ISTIO_VERSION}" \ - -v -o ${TARGET} \ - ${PROJECT_NAME}/cmd/layotto - mkdir -p build/bundles/${MAJOR_VERSION}/binary - mv ${TARGET} build/bundles/${MAJOR_VERSION}/binary - @cd build/bundles/${MAJOR_VERSION}/binary && $(shell which md5sum) -b ${TARGET} | cut -d' ' -f1 > ${TARGET}.md5 - cp configs/${CONFIG_FILE} build/bundles/${MAJOR_VERSION}/binary - @cd build/bundles/${MAJOR_VERSION}/binary - -build-arm64: - @rm -rf build/bundles/${MAJOR_VERSION}/binary - GOOS=linux GOARCH=arm64 go build\ - -a -ldflags "-B 0x$(shell head -c20 /dev/urandom|od -An -tx1|tr -d ' \n')" \ - -v -o ${ARM_TARGET} \ - ${PROJECT_NAME}/cmd/layotto - mkdir -p build/bundles/${MAJOR_VERSION}/binary - mv ${ARM_TARGET} build/bundles/${MAJOR_VERSION}/binary - @cd build/bundles/${MAJOR_VERSION}/binary && $(shell which md5sum) -b ${ARM_TARGET} | cut -d' ' -f1 > ${ARM_TARGET}.md5 - -image: build-local - @rm -rf ${IMAGE_BUILD_DIR} - cp -r build/contrib/builder/image ${IMAGE_BUILD_DIR} && cp build/bundles/${MAJOR_VERSION}/binary/${TARGET} ${IMAGE_BUILD_DIR} && cp -r configs ${IMAGE_BUILD_DIR} && cp -r etc ${IMAGE_BUILD_DIR} - docker build --rm -t ${REPOSITORY}:${IMAGE_TAG} ${IMAGE_BUILD_DIR} - rm -rf ${IMAGE_BUILD_DIR} - -wasm-integrate-ci: - docker build --rm -t ${BUILD_IMAGE} build/contrib/builder/image/faas - docker run --rm -v $(shell pwd):/go/src/${PROJECT_NAME} -v $(shell pwd)/test/wasm/wasm_test.sh:/go/src/${PROJECT_NAME}/wasm_test.sh -w /go/src/${PROJECT_NAME} ${BUILD_IMAGE} sh ./wasm_test.sh - -runtime-integrate-ci: - docker build --rm -t ${BUILD_IMAGE} build/contrib/builder/image/integrate - docker run --rm -v $(shell pwd):/go/src/${PROJECT_NAME} -v $(shell pwd)/test/runtime/integrate_test.sh:/go/src/${PROJECT_NAME}/integrate_test.sh -w /go/src/${PROJECT_NAME} ${BUILD_IMAGE} sh ./integrate_test.sh - -coverage: - sh ${SCRIPT_DIR}/report.sh - -build-linux-wasm-layotto: - docker build --rm -t ${BUILD_IMAGE} build/contrib/builder/image/faas - docker run --rm -v $(shell pwd):/go/src/${PROJECT_NAME} -w /go/src/${PROJECT_NAME} ${BUILD_IMAGE} go build -tags wasmer -o layotto /go/src/${PROJECT_NAME}/cmd/layotto - -build-linux-wasm-local: - go build -tags wasmer -o layotto $(shell pwd)/cmd/layotto - -check-dead-link: - sh ${SCRIPT_DIR}/check-dead-link.sh - -test-quickstart: - sh ${SCRIPT_DIR}/test-quickstart.sh \ No newline at end of file +# Copyright 2021 Layotto Authors +# 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. + +# Layotto commands 👀: + +# A fast and efficient cloud native application runtime 🚀. +# Commands below are used in Development 💻 and GitHub workflow 🌊. + +# Usage: make ... + +# COMMANDS: +# build Build layotto for host platform. +# build.multiarch Build layotto for multiple platforms. See option PLATFORMS. +# image Build docker images for host arch. +# image.multiarch Build docker images for multiple platforms. See option PLATFORMS. +# push Push docker images to registry. +# push.multiarch Push docker images for multiple platforms to registry. +# app Build app docker images for host arch. [`/docker/app` contains apps dockerfiles] +# app.multiarch Build app docker images for multiple platforms. See option PLATFORMS. +# wasm Build layotto wasm for linux arm64 platform. +# wasm.multiarch Build layotto wasm for multiple platform. +# wasm.image Build layotto wasm image for multiple platform. +# wasm.image.push Push layotto wasm image for multiple platform. +# check Run all go checks of code sources. +# check.lint Run go syntax and styling of go sources. +# check.unit Run go unit test. +# check.style Run go style test. +# style.coverage Run coverage analysis. +# style.deadlink Run deadlink check test. +# style.quickstart Run quickstart check test. +# integrate.wasm Run integration test with wasm. +# integrate.runtime Run integration test with runtime. +# format Format layotto go codes style with gofmt and goimports. +# clean Remove all files that are created by building. +# all Run format codes, check codes, build Layotto codes for host platform with one command +# help Show this help info. + +# ARGS: +# BINS The binaries to build. Default is all of cmd. +# This option is available when using: make build/build.multiarch +# Example: make build BINS="layotto_multiple_api layotto" +# IMAGES Backend images to make. Default is all of cmds. +# This option is available when using: make image/image.multiarch/push/push.multiarch +# Example: make image.multiarch IMAGES="layotto_multiple_api layotto" +# PLATFORMS The multiple platforms to build. Default is linux_amd64 and linux_arm64. +# This option is available when using: make build.multiarch/image.multiarch/push.multiarch +# Example: make image.multiarch IMAGES="layotto" PLATFORMS="linux_amd64 linux_arm64" +# Supported Platforms: linux_amd64 linux_arm64 darwin_amd64 darwin_arm64 + + +SHELL := /bin/bash + +# ============================================================================== +# ROOT Options: +# ============================================================================== + +ROOT_PACKAGE=mosn.io/layotto + +# ============================================================================== +# Includes: +# ============================================================================== + +include make/common.mk +include make/golang.mk +include make/image.mk +include make/wasm.mk +include make/ci.mk + +# ============================================================================== +# Targets: +# ============================================================================== + +# ============================================================================== +## build: Build layotto for host platform. +# ============================================================================== +.PHONY: build +build: + @$(MAKE) go.build + +# ============================================================================== +## build.multiarch: Build layotto for multiple platforms. See option PLATFORMS. +# ============================================================================== +.PHONY: build.multiarch +build.multiarch: + @$(MAKE) go.build.multiarch + +# ============================================================================== +## image: Build docker images for host arch. +# ============================================================================== +.PHONY: image +image: + @$(MAKE) image.build + +# ============================================================================== +## image.multiarch: Build docker images for multiple platforms. See option PLATFORMS. +# ============================================================================== +.PHONY: image.multiarch +image.multiarch: + @$(MAKE) image.build.multiarch + +# ============================================================================== +## push: Push docker images to registry. +# ============================================================================== +.PHONY: push +push: + @$(MAKE) image.push + +# ============================================================================== +## push.multiarch: Push docker images for multiple platforms to registry. +# ============================================================================== +.PHONY: push.multiarch +push.multiarch: + @$(MAKE) image.push.multiarch + +# ============================================================================== +## app: Build app docker images for host arch. [`/docker/app` contains apps dockerfiles] +# ============================================================================== +.PHONY: app +app: + @$(MAKE) app.image + +# ============================================================================== +## app.multiarch: Build app docker images for multiple platforms. See option PLATFORMS. +# ============================================================================== +.PHONY: app.multiarch +app.multiarch: + @$(MAKE) app.image.multiarch + +# ============================================================================== +## wasm: Build layotto wasm for linux arm64 platform. +# ============================================================================== +.PHONY: wasm +wasm: + @$(MAKE) go.wasm + +# ============================================================================== +## wasm.multiarch: Build layotto wasm for multiple platform. +# ============================================================================== +.PHONY: wasm.multiarch +wasm.multiarch: + @$(MAKE) go.wasm.multiarch + +# ============================================================================== +## wasm.image: Build layotto wasm image for multiple platform. +# ============================================================================== +.PHONY: wasm.image +wasm.image: + @$(MAKE) go.wasm.image + +# ============================================================================== +## wasm.image.push: Push layotto wasm image for multiple platform. +# ============================================================================== +.PHONY: wasm.image.push +wasm.image.push: + @$(MAKE) go.wasm.image.push + +# ============================================================================== +## check: Run all go checks of code sources. +# ============================================================================== +.PHONY: check +check: check.style check.unit check.lint + +# ============================================================================== +## check.lint: Run go syntax and styling of go sources. +# ============================================================================== +.PHONY: check.lint +check.lint: + @$(MAKE) go.lint + +# ============================================================================== +## check.unit: Run go unit test. +# ============================================================================== +.PHONY: check.unit +check.unit: + @$(MAKE) go.test + +# ============================================================================== +## check.style: Run go style test. +# ============================================================================== +.PHONY: check.style +check.style: + @$(MAKE) go.style + +# ============================================================================== +## style.coverage: Run coverage analysis. +# ============================================================================== +.PHONY: style.coverage +style.coverage: + @$(MAKE) checker.coverage + +# ============================================================================== +## style.deadlink: Run deadlink check test. +# ============================================================================== +.PHONY: style.deadlink +style.deadlink: + @$(MAKE) checker.deadlink + +# ============================================================================== +## style.quickstart: Run quickstart check test. +# ============================================================================== +.PHONY: style.quickstart +style.quickstart: + @$(MAKE) checker.quickstart + +# ============================================================================== +## integrate.wasm: Run integration test with wasm. +# ============================================================================== +.PHONY: integrate.wasm +integrate.wasm: + @$(MAKE) integration.wasm + +# ============================================================================== +## integrate.runtime: Run integration test with runtime. +# ============================================================================== +.PHONY: integrate.runtime +integrate.runtime: + @$(MAKE) integration.runtime + +# ============================================================================== +## format: Format layotto go codes style with gofmt and goimports. +# ============================================================================== +.PHONY: format +format: go.format + +# ============================================================================== +## clean: Remove all files that are created by building. +# ============================================================================== +.PHONY: clean +clean: + @$(MAKE) go.clean + +# ============================================================================== +## all: Run format codes, check codes, build Layotto codes for host platform with one command +# ============================================================================== +.PHONY: all +all: format check.style check.unit check.lint build + +# ============================================================================== +# Usage +# ============================================================================== + +define USAGE_OPTIONS + +ARGS: + BINS The binaries to build. Default is all of cmd. + This option is available when using: make build/build.multiarch + Example: make build BINS="layotto_multiple_api layotto" + IMAGES Backend images to make. Default is all of cmds. + This option is available when using: make image/image.multiarch/push/push.multiarch + Example: make image.multiarch IMAGES="layotto_multiple_api layotto" + PLATFORMS The multiple platforms to build. Default is linux_amd64 and linux_arm64. + This option is available when using: make build.multiarch/image.multiarch/push.multiarch + Example: make image.multiarch IMAGES="layotto" PLATFORMS="linux_amd64 linux_arm64" + Supported Platforms: linux_amd64 linux_arm64 darwin_amd64 darwin_arm64 +endef +export USAGE_OPTIONS + +# ============================================================================== +# Help +# ============================================================================== + +## help: Show this help info. +.PHONY: help +help: Makefile + @echo -e "Layotto commands 👀: \n\nA fast and efficient cloud native application runtime 🚀." + @echo -e "Commands below are used in Development 💻 and GitHub workflow 🌊.\n" + @echo -e "Usage: make ...\n\nCOMMANDS:" + @sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /' + @echo "$$USAGE_OPTIONS" diff --git a/RELEASING.md b/RELEASING.md new file mode 100644 index 0000000000..cb0b64a288 --- /dev/null +++ b/RELEASING.md @@ -0,0 +1,53 @@ +# 发布手册 +本文介绍下发布新版本时,发布负责人需要做什么 + +## 发布周期 +Layotto 发布周期暂定为每季度发布一次。 + +## 发布 checklist + +#### Step1: 检查当前迭代的 [Roadmap](https://github.com/mosn/layotto/projects) + +1. 检查进行中的任务 +2. 检查未完成的任务 +3. 与负责人确认任务状态和发布内容 + +#### Step2: 创建发布 tag, push 至 github 并检查工作流 + +1. 规范:请按照 `v{majorVersion}.{subVersion}.{latestVersion}` 格式创建 tag。 +2. 等待 CI 结束,确认以下内容: + + CI 测试 Jobs 全部通过: + + Go 代码风格校验 + + Go 代码规范校验 + + Go 单元测试 + + Go 集成测试 + + CI 多平台 Artifacts 构建 Jobs 全部通过: + + Linux/AMD64 Artifacts 成功 Build 并 Upload + + Linux/ARM64 Artifacts 成功 Build 并 Upload + + Darwin/AMD64 Artifacts 成功 Build 并 Upload + + Darwin/ARM64 Artifacts 成功 Build 并 Upload + + CI 多平台 Image 构建/发布 Jobs 全部通过: + + Linux/AMD64 Image 成功 Build 并 Push DockerHub + + Linux/ARM64 Image 成功 Build 并 Push DockerHub + + Image Tag 规范: + + AMD64/X86 架构的镜像:`layotto/layotto:{tag}` + + ARM64 架构的镜像:`layotto/layotto.arm64:{tag}` + +#### Step3: Draft a new release 并编写发布报告 + +> 发布报告可以先用 github 的功能自动生成,再基于生成的内容做修改。 + +> 可以参考以前的 [发版报告](https://github.com/mosn/layotto/releases) + +#### Step4: 上传多平台架构的 Binaries + +> 不必手动构建,直接将 `步骤 2` 中构建的多平台 Artifacts 下载上传即可 + +#### Step5: 确认发布 + +1. 点击发布 +2. 社区周知 +3. 检查 [Roadmap](https://github.com/mosn/layotto/projects),修改上个版本未完成的任务,把 milestone 改为下个版本 +4. 如果有 SDK 发布,需在 SDK 仓库做发布,并上传中央仓库 (比如 Java SDK 需要上传到 Maven 中央仓库)。 + +> TODO: need to translate. \ No newline at end of file diff --git a/build/contrib/builder/image/Dockerfile b/build/contrib/builder/image/Dockerfile deleted file mode 100644 index 53268a9bae..0000000000 --- a/build/contrib/builder/image/Dockerfile +++ /dev/null @@ -1,48 +0,0 @@ -FROM centos:centos7 as builder - -ENV CHROOT_RUNTIME_PREFIX /ROOT/home/admin/runtime -RUN useradd -ms /bin/bash admin - -COPY ./etc/supervisor/supervisord.conf /ROOT/etc/supervisord.conf -COPY ./etc/supervisor/runtime.conf /ROOT/etc/supervisord/conf.d/runtime.conf -#if you want test any backgroud store, cp it's .conf -COPY ./etc/supervisor/etcd.conf /ROOT/etc/supervisord/conf.d/etcd.conf - -COPY ./layotto $CHROOT_RUNTIME_PREFIX/bin/runtime - -RUN mkdir -p $RUNTIME_PREFIX/conf \ - && mkdir -p $RUNTIME_PREFIX/logs - -COPY ./configs/runtime_config.json $CHROOT_RUNTIME_PREFIX/conf/runtime_config.json - -RUN chmod +x $CHROOT_RUNTIME_PREFIX/bin/runtime -RUN chown -R admin:admin /ROOT/home/admin - - -FROM centos:centos7 -ENV TMP_FOLDER /tmp - -RUN yum install -y \ - ssh wget curl perl logrotate make build-essential procps etcd \ - tsar tcpdump mpstat iostat vmstat sysstat \ - python-setuptools; yum clean all - -# pip -WORKDIR $TMP_FOLDER -RUN wget https://mirrors.aliyun.com/pypi/packages/69/81/52b68d0a4de760a2f1979b0931ba7889202f302072cc7a0d614211bc7579/pip-18.0.tar.gz#sha256=a0e11645ee37c90b40c46d607070c4fd583e2cd46231b1c06e389c5e814eed76 -RUN tar zvxf pip-18.0.tar.gz -WORKDIR $TMP_FOLDER/pip-18.0 -RUN python setup.py install - -# supervisor -RUN pip install supervisor -i https://mirrors.aliyun.com/pypi/simple -RUN pip install supervisor-stdout -i https://mirrors.aliyun.com/pypi/simple - -RUN useradd -ms /bin/bash admin -# copy all in one layer -COPY --from=builder /ROOT / - -RUN echo "export RUNTIME_PREFIX=/home/admin/runtime" >> /etc/bashrc \ - && echo "export PATH=$PATH" >> /etc/bashrc - -ENTRYPOINT ["/usr/bin/supervisord" , "-c" , "/etc/supervisord.conf"] \ No newline at end of file diff --git a/build/contrib/builder/image/integrate/Dockerfile b/build/contrib/builder/image/integrate/Dockerfile deleted file mode 100644 index 190598bed1..0000000000 --- a/build/contrib/builder/image/integrate/Dockerfile +++ /dev/null @@ -1,4 +0,0 @@ -FROM golang:1.16 -MAINTAINER lingfenglangshao@gmail.com - -RUN apt-get update && apt-get install -y redis-server \ No newline at end of file diff --git a/cmd/layotto/main.go b/cmd/layotto/main.go index 91d2d1c372..6fcd829916 100644 --- a/cmd/layotto/main.go +++ b/cmd/layotto/main.go @@ -18,6 +18,10 @@ package main import ( "encoding/json" + "os" + "strconv" + "time" + "github.com/dapr/components-contrib/secretstores" "github.com/dapr/components-contrib/secretstores/aws/parameterstore" "github.com/dapr/components-contrib/secretstores/aws/secretmanager" @@ -34,9 +38,6 @@ import ( secretstores_loader "mosn.io/layotto/pkg/runtime/secretstores" "mosn.io/mosn/pkg/stagemanager" "mosn.io/mosn/pkg/trace/skywalking" - "os" - "strconv" - "time" "mosn.io/layotto/components/file/local" "mosn.io/layotto/components/file/s3/alicloud" diff --git a/cmd/layotto_multiple_api/helloworld/component/in_memory.go b/cmd/layotto_multiple_api/helloworld/component/in_memory.go index ee15d1295d..46b0344b5d 100644 --- a/cmd/layotto_multiple_api/helloworld/component/in_memory.go +++ b/cmd/layotto_multiple_api/helloworld/component/in_memory.go @@ -15,6 +15,7 @@ package component import ( "context" + "mosn.io/layotto/components/custom" ) diff --git a/cmd/layotto_multiple_api/helloworld/component/say_goodbye.go b/cmd/layotto_multiple_api/helloworld/component/say_goodbye.go index 00a4770e78..d053bcd71b 100644 --- a/cmd/layotto_multiple_api/helloworld/component/say_goodbye.go +++ b/cmd/layotto_multiple_api/helloworld/component/say_goodbye.go @@ -15,6 +15,7 @@ package component import ( "context" + "mosn.io/layotto/components/custom" ) diff --git a/cmd/layotto_multiple_api/helloworld/grpc_api.go b/cmd/layotto_multiple_api/helloworld/grpc_api.go index 7a345066ea..70692f3ec6 100644 --- a/cmd/layotto_multiple_api/helloworld/grpc_api.go +++ b/cmd/layotto_multiple_api/helloworld/grpc_api.go @@ -19,6 +19,7 @@ package helloworld import ( "context" "fmt" + rawGRPC "google.golang.org/grpc" pb "google.golang.org/grpc/examples/helloworld/helloworld" "mosn.io/layotto/cmd/layotto_multiple_api/helloworld/component" diff --git a/cmd/layotto_multiple_api/main.go b/cmd/layotto_multiple_api/main.go index 6bbcb5312d..2530fe1ede 100644 --- a/cmd/layotto_multiple_api/main.go +++ b/cmd/layotto_multiple_api/main.go @@ -18,6 +18,10 @@ package main import ( "encoding/json" + "os" + "strconv" + "time" + "mosn.io/api" helloworld_api "mosn.io/layotto/cmd/layotto_multiple_api/helloworld" "mosn.io/layotto/cmd/layotto_multiple_api/helloworld/component" @@ -29,9 +33,6 @@ import ( _ "mosn.io/mosn/pkg/filter/stream/grpcmetric" "mosn.io/mosn/pkg/stagemanager" "mosn.io/mosn/pkg/trace/skywalking" - "os" - "strconv" - "time" mock_state "mosn.io/layotto/pkg/mock/components/state" _ "mosn.io/layotto/pkg/wasm" diff --git a/components/configstores/apollo/change_listener.go b/components/configstores/apollo/change_listener.go index 6f847c2594..b736586310 100644 --- a/components/configstores/apollo/change_listener.go +++ b/components/configstores/apollo/change_listener.go @@ -17,10 +17,11 @@ package apollo import ( + "time" + "github.com/zouyx/agollo/v4/storage" "mosn.io/layotto/components/configstores" "mosn.io/pkg/log" - "time" ) type changeListener struct { diff --git a/components/configstores/apollo/configstore.go b/components/configstores/apollo/configstore.go index 0b20afff16..f9765833e9 100644 --- a/components/configstores/apollo/configstore.go +++ b/components/configstores/apollo/configstore.go @@ -22,13 +22,14 @@ import ( "errors" "fmt" "io/ioutil" - "mosn.io/layotto/components/pkg/actuators" "net/http" "strconv" "strings" "sync" "time" + "mosn.io/layotto/components/pkg/actuators" + "mosn.io/layotto/components/configstores" "mosn.io/pkg/log" ) diff --git a/components/configstores/apollo/configstore_test.go b/components/configstores/apollo/configstore_test.go index 68bfe46e36..a99d3a86f1 100644 --- a/components/configstores/apollo/configstore_test.go +++ b/components/configstores/apollo/configstore_test.go @@ -21,14 +21,15 @@ import ( "context" "encoding/json" "errors" - "github.com/stretchr/testify/assert" - "github.com/zouyx/agollo/v4" "io/ioutil" - "mosn.io/layotto/components/configstores" - "mosn.io/mosn/pkg/log" "net/http" "reflect" "testing" + + "github.com/stretchr/testify/assert" + "github.com/zouyx/agollo/v4" + "mosn.io/layotto/components/configstores" + "mosn.io/mosn/pkg/log" ) // MockRepository implements Repository interface diff --git a/components/configstores/apollo/default_logger_test.go b/components/configstores/apollo/default_logger_test.go index 8a8974c287..0ebc0f3abd 100644 --- a/components/configstores/apollo/default_logger_test.go +++ b/components/configstores/apollo/default_logger_test.go @@ -17,8 +17,9 @@ package apollo import ( - "mosn.io/pkg/log" "testing" + + "mosn.io/pkg/log" ) func TestNewDefaultLogger(t *testing.T) { diff --git a/components/configstores/apollo/repository.go b/components/configstores/apollo/repository.go index 142e7bc0e9..aaff905a13 100644 --- a/components/configstores/apollo/repository.go +++ b/components/configstores/apollo/repository.go @@ -19,6 +19,7 @@ package apollo import ( "errors" "fmt" + "github.com/zouyx/agollo/v4" agolloConfig "github.com/zouyx/agollo/v4/env/config" "mosn.io/pkg/log" diff --git a/components/configstores/apollo/subscriber_holder.go b/components/configstores/apollo/subscriber_holder.go index 5a535526bf..0cbd988f03 100644 --- a/components/configstores/apollo/subscriber_holder.go +++ b/components/configstores/apollo/subscriber_holder.go @@ -17,8 +17,9 @@ package apollo import ( - "mosn.io/layotto/components/configstores" "sync" + + "mosn.io/layotto/components/configstores" ) // Holding subscribers' chan and ctx. diff --git a/components/configstores/apollo/subscriber_holder_test.go b/components/configstores/apollo/subscriber_holder_test.go index 863d841d93..5475f8c954 100644 --- a/components/configstores/apollo/subscriber_holder_test.go +++ b/components/configstores/apollo/subscriber_holder_test.go @@ -17,9 +17,10 @@ package apollo import ( + "testing" + "github.com/stretchr/testify/assert" "mosn.io/layotto/components/configstores" - "testing" ) // Test CRUD operations of subscriberHolder diff --git a/components/configstores/etcdv3/etcdv3.go b/components/configstores/etcdv3/etcdv3.go index bb93ad9431..b7fabc57d4 100644 --- a/components/configstores/etcdv3/etcdv3.go +++ b/components/configstores/etcdv3/etcdv3.go @@ -16,12 +16,13 @@ package etcdv3 import ( "context" "fmt" - "mosn.io/pkg/utils" "strconv" "strings" "sync" "time" + "mosn.io/pkg/utils" + "go.etcd.io/etcd/api/v3/mvccpb" clientv3 "go.etcd.io/etcd/client/v3" "mosn.io/layotto/components/configstores" diff --git a/components/custom/registry.go b/components/custom/registry.go index 31359d99b2..a12af8dfa7 100644 --- a/components/custom/registry.go +++ b/components/custom/registry.go @@ -15,6 +15,7 @@ package custom import ( "fmt" + "mosn.io/layotto/components/pkg/info" ) diff --git a/components/custom/registry_test.go b/components/custom/registry_test.go index 84d443dcf3..f77eb5c989 100644 --- a/components/custom/registry_test.go +++ b/components/custom/registry_test.go @@ -17,9 +17,10 @@ package custom import ( - "mosn.io/layotto/components/pkg/info" "strings" "testing" + + "mosn.io/layotto/components/pkg/info" ) func TestNewRegistry(t *testing.T) { diff --git a/components/file/s3/qiniu/qiniu_oss_client_test.go b/components/file/s3/qiniu/qiniu_oss_client_test.go index 5a1309b26d..accf696f76 100644 --- a/components/file/s3/qiniu/qiniu_oss_client_test.go +++ b/components/file/s3/qiniu/qiniu_oss_client_test.go @@ -20,12 +20,13 @@ import ( "bytes" "context" "errors" + "testing" + "github.com/golang/mock/gomock" "github.com/qiniu/go-sdk/v7/auth/qbox" "github.com/qiniu/go-sdk/v7/storage" "github.com/stretchr/testify/assert" "mosn.io/layotto/components/pkg/mock" - "testing" ) func TestNewClient(t *testing.T) { diff --git a/components/file/s3/qiniu/qiniu_oss_test.go b/components/file/s3/qiniu/qiniu_oss_test.go index df765d390a..7b6cbfb884 100644 --- a/components/file/s3/qiniu/qiniu_oss_test.go +++ b/components/file/s3/qiniu/qiniu_oss_test.go @@ -18,15 +18,16 @@ package qiniu import ( "context" + "io" + "strings" + "testing" + "time" + "github.com/golang/mock/gomock" "github.com/qiniu/go-sdk/v7/storage" "github.com/stretchr/testify/assert" - "io" "mosn.io/layotto/components/file" "mosn.io/layotto/components/pkg/mock" - "strings" - "testing" - "time" ) func TestNew(t *testing.T) { diff --git a/components/hello/helloworld/helloworld.go b/components/hello/helloworld/helloworld.go index ca9a0377cf..dc47258838 100644 --- a/components/hello/helloworld/helloworld.go +++ b/components/hello/helloworld/helloworld.go @@ -18,6 +18,7 @@ package helloworld import ( "context" + "mosn.io/layotto/components/hello" ) diff --git a/components/lock/consul/consul_lock.go b/components/lock/consul/consul_lock.go index f733be4e77..f90d8a341d 100644 --- a/components/lock/consul/consul_lock.go +++ b/components/lock/consul/consul_lock.go @@ -14,14 +14,15 @@ package consul import ( + "runtime" + "strconv" + "sync" + "github.com/hashicorp/consul/api" "mosn.io/layotto/components/lock" "mosn.io/layotto/components/pkg/utils" msync "mosn.io/mosn/pkg/sync" "mosn.io/pkg/log" - "runtime" - "strconv" - "sync" ) type ConsulLock struct { diff --git a/components/lock/consul/consul_lock_test.go b/components/lock/consul/consul_lock_test.go index 12f386651c..ecef6f5d99 100644 --- a/components/lock/consul/consul_lock_test.go +++ b/components/lock/consul/consul_lock_test.go @@ -14,13 +14,14 @@ package consul import ( + "testing" + "github.com/golang/mock/gomock" "github.com/hashicorp/consul/api" "github.com/stretchr/testify/assert" "mosn.io/layotto/components/lock" "mosn.io/layotto/components/pkg/mock" "mosn.io/pkg/log" - "testing" ) const resouseId = "resoure_1" diff --git a/components/lock/etcd/etcd_lock.go b/components/lock/etcd/etcd_lock.go index 94e6ab7094..faf61217e7 100644 --- a/components/lock/etcd/etcd_lock.go +++ b/components/lock/etcd/etcd_lock.go @@ -16,7 +16,8 @@ package etcd import ( "context" "fmt" - "go.etcd.io/etcd/client/v3" + + clientv3 "go.etcd.io/etcd/client/v3" "mosn.io/layotto/components/pkg/utils" "mosn.io/layotto/components/lock" diff --git a/components/lock/etcd/etcd_lock_test.go b/components/lock/etcd/etcd_lock_test.go index 20073270cf..36faff1fca 100644 --- a/components/lock/etcd/etcd_lock_test.go +++ b/components/lock/etcd/etcd_lock_test.go @@ -15,13 +15,14 @@ package etcd import ( "fmt" - "mosn.io/pkg/log" "net/url" "os" "sync" "testing" "time" + "mosn.io/pkg/log" + "mosn.io/layotto/components/lock" "github.com/google/uuid" diff --git a/components/lock/in-memory/in_memory_lock.go b/components/lock/in-memory/in_memory_lock.go index deaf4c4e18..210bd50bad 100644 --- a/components/lock/in-memory/in_memory_lock.go +++ b/components/lock/in-memory/in_memory_lock.go @@ -17,9 +17,10 @@ package in_memory import ( - "mosn.io/layotto/components/lock" "sync" "time" + + "mosn.io/layotto/components/lock" ) type InMemoryLock struct { diff --git a/components/lock/in-memory/in_memory_lock_test.go b/components/lock/in-memory/in_memory_lock_test.go index 4843b84bf8..b61a23259b 100644 --- a/components/lock/in-memory/in_memory_lock_test.go +++ b/components/lock/in-memory/in_memory_lock_test.go @@ -17,10 +17,11 @@ package in_memory import ( - "github.com/stretchr/testify/assert" - "mosn.io/layotto/components/lock" "testing" "time" + + "github.com/stretchr/testify/assert" + "mosn.io/layotto/components/lock" ) func TestNew(t *testing.T) { diff --git a/components/lock/mongo/mongo_lock.go b/components/lock/mongo/mongo_lock.go index b315b62618..09044433c6 100644 --- a/components/lock/mongo/mongo_lock.go +++ b/components/lock/mongo/mongo_lock.go @@ -16,6 +16,8 @@ package mongo import ( "context" "fmt" + "time" + "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" @@ -25,7 +27,6 @@ import ( "mosn.io/layotto/components/lock" "mosn.io/layotto/components/pkg/utils" "mosn.io/pkg/log" - "time" ) const ( diff --git a/components/lock/mongo/mongo_lock_test.go b/components/lock/mongo/mongo_lock_test.go index c9c9b44e1d..169e9df0a1 100644 --- a/components/lock/mongo/mongo_lock_test.go +++ b/components/lock/mongo/mongo_lock_test.go @@ -14,6 +14,9 @@ package mongo import ( + "sync" + "testing" + "github.com/google/uuid" "github.com/stretchr/testify/assert" "go.mongodb.org/mongo-driver/bson" @@ -21,8 +24,6 @@ import ( "mosn.io/layotto/components/lock" "mosn.io/layotto/components/pkg/mock" "mosn.io/pkg/log" - "sync" - "testing" ) const ( diff --git a/components/lock/redis/cluster_redis_lock.go b/components/lock/redis/cluster_redis_lock.go index a88f36163d..3e3611e95d 100644 --- a/components/lock/redis/cluster_redis_lock.go +++ b/components/lock/redis/cluster_redis_lock.go @@ -16,14 +16,15 @@ package redis import ( "context" "fmt" + "strings" + "sync" + "time" + "github.com/go-redis/redis/v8" "mosn.io/layotto/components/lock" "mosn.io/layotto/components/pkg/utils" msync "mosn.io/mosn/pkg/sync" "mosn.io/pkg/log" - "strings" - "sync" - "time" ) //RedLock diff --git a/components/lock/redis/cluster_redis_lock_test.go b/components/lock/redis/cluster_redis_lock_test.go index 498c22c100..c9cda6891e 100644 --- a/components/lock/redis/cluster_redis_lock_test.go +++ b/components/lock/redis/cluster_redis_lock_test.go @@ -14,14 +14,15 @@ package redis import ( + "strings" + "sync" + "testing" + miniredis "github.com/alicebob/miniredis/v2" "github.com/google/uuid" "github.com/stretchr/testify/assert" "mosn.io/layotto/components/lock" "mosn.io/pkg/log" - "strings" - "sync" - "testing" ) const cResourceId = "resource_red_lock" diff --git a/components/lock/redis/standalone_redis_lock.go b/components/lock/redis/standalone_redis_lock.go index b22a34da1c..4e4abf7ef4 100644 --- a/components/lock/redis/standalone_redis_lock.go +++ b/components/lock/redis/standalone_redis_lock.go @@ -16,11 +16,12 @@ package redis import ( "context" "fmt" + "time" + "github.com/go-redis/redis/v8" "mosn.io/layotto/components/lock" "mosn.io/layotto/components/pkg/utils" "mosn.io/pkg/log" - "time" ) // Standalone Redis lock store.Any fail-over related features are not supported,such as Sentinel and Redis Cluster. diff --git a/components/lock/redis/standalone_redis_lock_test.go b/components/lock/redis/standalone_redis_lock_test.go index 0fe4bcd39b..a7b60f1979 100644 --- a/components/lock/redis/standalone_redis_lock_test.go +++ b/components/lock/redis/standalone_redis_lock_test.go @@ -14,13 +14,14 @@ package redis import ( + "sync" + "testing" + miniredis "github.com/alicebob/miniredis/v2" "github.com/google/uuid" "github.com/stretchr/testify/assert" "mosn.io/layotto/components/lock" "mosn.io/pkg/log" - "sync" - "testing" ) const resourceId = "resource_xxx" diff --git a/components/lock/zookeeper/zookeeper_lock.go b/components/lock/zookeeper/zookeeper_lock.go index 324ee43acb..480b324df0 100644 --- a/components/lock/zookeeper/zookeeper_lock.go +++ b/components/lock/zookeeper/zookeeper_lock.go @@ -14,12 +14,13 @@ package zookeeper import ( + "time" + "github.com/go-zookeeper/zk" "mosn.io/layotto/components/lock" "mosn.io/layotto/components/pkg/utils" "mosn.io/pkg/log" util "mosn.io/pkg/utils" - "time" ) // Zookeeper lock store diff --git a/components/lock/zookeeper/zookeeper_lock_test.go b/components/lock/zookeeper/zookeeper_lock_test.go index f8f39ca531..eade0d94d2 100644 --- a/components/lock/zookeeper/zookeeper_lock_test.go +++ b/components/lock/zookeeper/zookeeper_lock_test.go @@ -14,14 +14,15 @@ package zookeeper import ( + "testing" + "time" + "github.com/go-zookeeper/zk" "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" "mosn.io/layotto/components/lock" "mosn.io/layotto/components/pkg/mock" "mosn.io/pkg/log" - "testing" - "time" ) const resouseId = "resoure_1" diff --git a/components/pkg/actuators/actutors_test.go b/components/pkg/actuators/actutors_test.go index 9ad444fa06..6f8bcd8942 100644 --- a/components/pkg/actuators/actutors_test.go +++ b/components/pkg/actuators/actutors_test.go @@ -14,8 +14,9 @@ package actuators import ( - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func TestRangeAllIndicators(t *testing.T) { diff --git a/components/pkg/actuators/indicator.go b/components/pkg/actuators/indicator.go index 8749dca49f..846f4b3b26 100644 --- a/components/pkg/actuators/indicator.go +++ b/components/pkg/actuators/indicator.go @@ -17,8 +17,9 @@ package actuators import ( - "mosn.io/layotto/components/pkg/common" "sync" + + "mosn.io/layotto/components/pkg/common" ) const ( diff --git a/components/pkg/mock/custom_component_mock.go b/components/pkg/mock/custom_component_mock.go index 7a26367fc6..3096cc13e7 100644 --- a/components/pkg/mock/custom_component_mock.go +++ b/components/pkg/mock/custom_component_mock.go @@ -15,6 +15,7 @@ package mock import ( "context" + "mosn.io/layotto/components/custom" ) diff --git a/components/pkg/mock/mongo_lock_mock.go b/components/pkg/mock/mongo_lock_mock.go index cd8ad87186..65cded7dd6 100644 --- a/components/pkg/mock/mongo_lock_mock.go +++ b/components/pkg/mock/mongo_lock_mock.go @@ -15,6 +15,7 @@ package mock import ( "context" + "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" diff --git a/components/pkg/mock/mongo_sequencer_mock.go b/components/pkg/mock/mongo_sequencer_mock.go index 55e3151bbc..a7ee0c9b1f 100644 --- a/components/pkg/mock/mongo_sequencer_mock.go +++ b/components/pkg/mock/mongo_sequencer_mock.go @@ -15,14 +15,15 @@ package mock import ( "context" + "reflect" + "unsafe" + "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/bsoncodec" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" "go.mongodb.org/mongo-driver/mongo/readpref" "mosn.io/layotto/components/pkg/utils" - "reflect" - "unsafe" ) var Result = make(map[string]bson.M) diff --git a/components/pkg/mock/zookeeper_mock.go b/components/pkg/mock/zookeeper_mock.go index c8a2ecc2b2..f7287994cc 100644 --- a/components/pkg/mock/zookeeper_mock.go +++ b/components/pkg/mock/zookeeper_mock.go @@ -18,10 +18,11 @@ package mock import ( - "mosn.io/layotto/components/pkg/utils" reflect "reflect" time "time" + "mosn.io/layotto/components/pkg/utils" + zk "github.com/go-zookeeper/zk" gomock "github.com/golang/mock/gomock" ) diff --git a/components/pkg/utils/consul.go b/components/pkg/utils/consul.go index 06ab713945..f1b05dad79 100644 --- a/components/pkg/utils/consul.go +++ b/components/pkg/utils/consul.go @@ -15,6 +15,7 @@ package utils import ( "errors" + "github.com/hashicorp/consul/api" "mosn.io/layotto/components/lock" ) diff --git a/components/pkg/utils/etcd.go b/components/pkg/utils/etcd.go index 487b8b9ea7..8def2a1e48 100644 --- a/components/pkg/utils/etcd.go +++ b/components/pkg/utils/etcd.go @@ -19,11 +19,12 @@ import ( "crypto/x509" "errors" "fmt" - clientv3 "go.etcd.io/etcd/client/v3" "io/ioutil" "strconv" "strings" "time" + + clientv3 "go.etcd.io/etcd/client/v3" ) const ( diff --git a/components/pkg/utils/etcd_test.go b/components/pkg/utils/etcd_test.go index a16abdd73e..dcbd535557 100644 --- a/components/pkg/utils/etcd_test.go +++ b/components/pkg/utils/etcd_test.go @@ -17,8 +17,9 @@ package utils import ( - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func Test_addPathSeparator(t *testing.T) { diff --git a/components/pkg/utils/mongo.go b/components/pkg/utils/mongo.go index dd7e360562..a29b75c102 100644 --- a/components/pkg/utils/mongo.go +++ b/components/pkg/utils/mongo.go @@ -17,14 +17,15 @@ import ( "context" "errors" "fmt" + "strconv" + "time" + "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" "go.mongodb.org/mongo-driver/mongo/readconcern" "go.mongodb.org/mongo-driver/mongo/readpref" "go.mongodb.org/mongo-driver/mongo/writeconcern" - "strconv" - "time" ) const ( diff --git a/components/pkg/utils/redis.go b/components/pkg/utils/redis.go index ae6b612aba..9b089793a0 100644 --- a/components/pkg/utils/redis.go +++ b/components/pkg/utils/redis.go @@ -17,11 +17,12 @@ import ( "crypto/tls" "errors" "fmt" - "github.com/go-redis/redis/v8" "runtime" "strconv" "strings" "time" + + "github.com/go-redis/redis/v8" ) const ( @@ -202,7 +203,7 @@ func ParseRedisClusterMetadata(properties map[string]string) (RedisClusterMetada if err != nil { return m, fmt.Errorf("redis store error: can't parse concurrency field: %s", err) } - if con <= 0{ + if con <= 0 { con = runtime.NumCPU() } m.Concurrency = con diff --git a/components/pkg/utils/zookeeper.go b/components/pkg/utils/zookeeper.go index 6e3bdf1243..a6ce4e1d62 100644 --- a/components/pkg/utils/zookeeper.go +++ b/components/pkg/utils/zookeeper.go @@ -16,10 +16,11 @@ package utils import ( "errors" "fmt" - "github.com/go-zookeeper/zk" "strconv" "strings" "time" + + "github.com/go-zookeeper/zk" ) const ( diff --git a/components/rpc/invoker/mosn/channel/httpchannel_test.go b/components/rpc/invoker/mosn/channel/httpchannel_test.go index 5bf3ca62b4..466083d44b 100644 --- a/components/rpc/invoker/mosn/channel/httpchannel_test.go +++ b/components/rpc/invoker/mosn/channel/httpchannel_test.go @@ -54,7 +54,7 @@ func (ts *testhttpServer) readLoop(conn net.Conn) { case "close": return case "timeout": - time.Sleep(2*time.Second) + time.Sleep(2 * time.Second) default: } @@ -107,7 +107,7 @@ func TestManyRequests(t *testing.T) { channel, err := newHttpChannel(ChannelConfig{Size: 1}) assert.Nil(t, err) - for i:=0;i<100;i++{ + for i := 0; i < 100; i++ { req := &rpc.RPCRequest{Ctx: context.TODO(), Id: "foo", Method: "bar", Data: []byte("hello"), Timeout: 1000} _, err = channel.Do(req) assert.Nil(t, err) @@ -124,7 +124,7 @@ func TestResponseTimeout(t *testing.T) { _, err = channel.Do(req) assert.Error(t, err) - for i:=0;i<100;i++{ + for i := 0; i < 100; i++ { req = &rpc.RPCRequest{Ctx: context.TODO(), Id: "foo", Method: "bar", Data: []byte("hello"), Timeout: 1000} _, err = channel.Do(req) assert.Nil(t, err) diff --git a/components/sequencer/etcd/store.go b/components/sequencer/etcd/store.go index ae20ea08a0..29ea27d479 100644 --- a/components/sequencer/etcd/store.go +++ b/components/sequencer/etcd/store.go @@ -16,6 +16,7 @@ package etcd import ( "context" "fmt" + clientv3 "go.etcd.io/etcd/client/v3" "mosn.io/layotto/components/pkg/utils" "mosn.io/layotto/components/sequencer" diff --git a/components/sequencer/etcd/store_test.go b/components/sequencer/etcd/store_test.go index ec92c46195..6dabb24286 100644 --- a/components/sequencer/etcd/store_test.go +++ b/components/sequencer/etcd/store_test.go @@ -15,8 +15,6 @@ package etcd import ( "fmt" - "mosn.io/layotto/components/sequencer" - "mosn.io/pkg/log" "net" "net/url" "os" @@ -24,6 +22,9 @@ import ( "testing" "time" + "mosn.io/layotto/components/sequencer" + "mosn.io/pkg/log" + "github.com/stretchr/testify/assert" "go.etcd.io/etcd/server/v3/embed" ) diff --git a/components/sequencer/in-memory/in_memory_sequencer.go b/components/sequencer/in-memory/in_memory_sequencer.go index e56c322b78..d6ecb9763e 100644 --- a/components/sequencer/in-memory/in_memory_sequencer.go +++ b/components/sequencer/in-memory/in_memory_sequencer.go @@ -17,10 +17,11 @@ package in_memory import ( + "sync" + "go.uber.org/atomic" "mosn.io/layotto/components/pkg/actuators" "mosn.io/layotto/components/sequencer" - "sync" ) var ( diff --git a/components/sequencer/mongo/mongo_sequencer.go b/components/sequencer/mongo/mongo_sequencer.go index b90340dc5d..b010321c85 100644 --- a/components/sequencer/mongo/mongo_sequencer.go +++ b/components/sequencer/mongo/mongo_sequencer.go @@ -16,6 +16,7 @@ package mongo import ( "context" "fmt" + "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" diff --git a/components/sequencer/mongo/mongo_sequencer_test.go b/components/sequencer/mongo/mongo_sequencer_test.go index 3fe078047c..30930c80a3 100644 --- a/components/sequencer/mongo/mongo_sequencer_test.go +++ b/components/sequencer/mongo/mongo_sequencer_test.go @@ -14,13 +14,14 @@ package mongo import ( + "testing" + "github.com/stretchr/testify/assert" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" "mosn.io/layotto/components/pkg/mock" "mosn.io/layotto/components/sequencer" "mosn.io/pkg/log" - "testing" ) const key = "resource_xxx" diff --git a/components/sequencer/redis/standalone_redis_sequencer.go b/components/sequencer/redis/standalone_redis_sequencer.go index 3b56c4d1b6..37576e987b 100644 --- a/components/sequencer/redis/standalone_redis_sequencer.go +++ b/components/sequencer/redis/standalone_redis_sequencer.go @@ -15,6 +15,7 @@ package redis import ( "context" + "github.com/go-redis/redis/v8" "mosn.io/layotto/components/pkg/utils" "mosn.io/layotto/components/sequencer" diff --git a/components/sequencer/redis/standalone_redis_sequencer_test.go b/components/sequencer/redis/standalone_redis_sequencer_test.go index b9ded13321..722d27161a 100644 --- a/components/sequencer/redis/standalone_redis_sequencer_test.go +++ b/components/sequencer/redis/standalone_redis_sequencer_test.go @@ -15,11 +15,12 @@ package redis import ( "fmt" + "testing" + "github.com/alicebob/miniredis/v2" "github.com/stretchr/testify/assert" "mosn.io/layotto/components/sequencer" "mosn.io/pkg/log" - "testing" ) const key = "resource_xxx" diff --git a/components/sequencer/zookeeper/zookeeper_sequencer.go b/components/sequencer/zookeeper/zookeeper_sequencer.go index 9208d80fa2..b99a74b02b 100644 --- a/components/sequencer/zookeeper/zookeeper_sequencer.go +++ b/components/sequencer/zookeeper/zookeeper_sequencer.go @@ -16,6 +16,7 @@ package zookeeper import ( "context" "fmt" + "github.com/go-zookeeper/zk" "mosn.io/layotto/components/pkg/utils" "mosn.io/layotto/components/sequencer" diff --git a/components/sequencer/zookeeper/zookeeper_sequencer_test.go b/components/sequencer/zookeeper/zookeeper_sequencer_test.go index 25ccc18b69..63ce276ab2 100644 --- a/components/sequencer/zookeeper/zookeeper_sequencer_test.go +++ b/components/sequencer/zookeeper/zookeeper_sequencer_test.go @@ -14,13 +14,14 @@ package zookeeper import ( + "testing" + "github.com/go-zookeeper/zk" "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" "mosn.io/layotto/components/pkg/mock" "mosn.io/layotto/components/sequencer" "mosn.io/pkg/log" - "testing" ) const key = "resoure_1" diff --git a/demo/configuration/apollo/client.go b/demo/configuration/apollo/client.go index a088701777..668d13a3eb 100644 --- a/demo/configuration/apollo/client.go +++ b/demo/configuration/apollo/client.go @@ -20,12 +20,13 @@ import ( "context" "encoding/json" "fmt" - "google.golang.org/grpc" - client "mosn.io/layotto/sdk/go-sdk/client" - runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" "strconv" "sync" "time" + + "google.golang.org/grpc" + client "mosn.io/layotto/sdk/go-sdk/client" + runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" ) const ( diff --git a/demo/configuration/etcd/etcd.go b/demo/configuration/etcd/etcd.go index 5a0c88ef4d..791278c04a 100644 --- a/demo/configuration/etcd/etcd.go +++ b/demo/configuration/etcd/etcd.go @@ -19,8 +19,9 @@ package main import ( "context" "fmt" - client "mosn.io/layotto/sdk/go-sdk/client" "time" + + client "mosn.io/layotto/sdk/go-sdk/client" ) func main() { diff --git a/demo/faas/code/golang/client/function.go b/demo/faas/code/golang/client/function.go index 951578ef10..a4a5c26e3d 100644 --- a/demo/faas/code/golang/client/function.go +++ b/demo/faas/code/golang/client/function.go @@ -18,9 +18,10 @@ package main import ( "errors" + "strings" + "github.com/tetratelabs/proxy-wasm-go-sdk/proxywasm" "github.com/tetratelabs/proxy-wasm-go-sdk/proxywasm/types" - "strings" ) func main() { @@ -95,7 +96,6 @@ func getQueryParam(body string, paramName string) (string, error) { return "", errors.New("not found") } - // Override types.DefaultHttpContext. func (ctx *httpHeaders) OnHttpStreamDone() { proxywasm.LogInfof("%d finished", ctx.contextID) diff --git a/demo/flowcontrol/client.go b/demo/flowcontrol/client.go index 8dca075aad..cedbe99f97 100644 --- a/demo/flowcontrol/client.go +++ b/demo/flowcontrol/client.go @@ -19,9 +19,10 @@ package main import ( "context" "fmt" - runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" "time" + runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" + "google.golang.org/grpc" ) diff --git a/demo/lock/common/client.go b/demo/lock/common/client.go index e8e78a2223..9c3dec483b 100644 --- a/demo/lock/common/client.go +++ b/demo/lock/common/client.go @@ -4,10 +4,11 @@ import ( "context" "flag" "fmt" + "sync" + "github.com/google/uuid" client "mosn.io/layotto/sdk/go-sdk/client" runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" - "sync" ) const ( diff --git a/demo/lock/consul/client.go b/demo/lock/consul/client.go index 248f0864a7..5cca84f629 100644 --- a/demo/lock/consul/client.go +++ b/demo/lock/consul/client.go @@ -3,10 +3,11 @@ package main import ( "context" "fmt" + "sync" + "github.com/google/uuid" client "mosn.io/layotto/sdk/go-sdk/client" runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" - "sync" ) const ( diff --git a/demo/lock/etcd/client.go b/demo/lock/etcd/client.go index 4e0abcc8c4..2870fb2e89 100644 --- a/demo/lock/etcd/client.go +++ b/demo/lock/etcd/client.go @@ -3,10 +3,11 @@ package main import ( "context" "fmt" + "sync" + "github.com/google/uuid" client "mosn.io/layotto/sdk/go-sdk/client" runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" - "sync" ) const ( diff --git a/demo/lock/in-memory/client.go b/demo/lock/in-memory/client.go index 0d9daebd75..3f05cf006f 100644 --- a/demo/lock/in-memory/client.go +++ b/demo/lock/in-memory/client.go @@ -3,10 +3,11 @@ package main import ( "context" "fmt" + "sync" + "github.com/google/uuid" client "mosn.io/layotto/sdk/go-sdk/client" runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" - "sync" ) const ( diff --git a/demo/lock/mongo/client.go b/demo/lock/mongo/client.go index 564048ed33..497f0d9d07 100644 --- a/demo/lock/mongo/client.go +++ b/demo/lock/mongo/client.go @@ -3,10 +3,11 @@ package main import ( "context" "fmt" + "sync" + "github.com/google/uuid" client "mosn.io/layotto/sdk/go-sdk/client" runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" - "sync" ) const ( diff --git a/demo/lock/redis/client.go b/demo/lock/redis/client.go index bda4231732..7e9f7ce2ff 100644 --- a/demo/lock/redis/client.go +++ b/demo/lock/redis/client.go @@ -3,10 +3,11 @@ package main import ( "context" "fmt" + "sync" + "github.com/google/uuid" client "mosn.io/layotto/sdk/go-sdk/client" runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" - "sync" ) const ( diff --git a/demo/lock/redis/redis_cluster/client_cluster_lock.go b/demo/lock/redis/redis_cluster/client_cluster_lock.go index 8a266f117a..31462a14a8 100644 --- a/demo/lock/redis/redis_cluster/client_cluster_lock.go +++ b/demo/lock/redis/redis_cluster/client_cluster_lock.go @@ -3,10 +3,11 @@ package main import ( "context" "fmt" + "sync" + "github.com/google/uuid" client "mosn.io/layotto/sdk/go-sdk/client" runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" - "sync" ) const ( diff --git a/demo/lock/zookeeper/client.go b/demo/lock/zookeeper/client.go index 6c36944dbd..e647c81090 100644 --- a/demo/lock/zookeeper/client.go +++ b/demo/lock/zookeeper/client.go @@ -3,10 +3,11 @@ package main import ( "context" "fmt" + "sync" + "github.com/google/uuid" "mosn.io/layotto/sdk/go-sdk/client" runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" - "sync" ) const ( diff --git a/demo/pubsub/redis/client/publish_client.go b/demo/pubsub/redis/client/publish_client.go index 578ef584c3..d1e84b014c 100644 --- a/demo/pubsub/redis/client/publish_client.go +++ b/demo/pubsub/redis/client/publish_client.go @@ -38,7 +38,7 @@ func main() { func testPublish(cli client.Client) error { data := []byte("value1") - err := cli.PublishEvent(context.Background(), "redis",topicName, data) + err := cli.PublishEvent(context.Background(), "redis", topicName, data) if err != nil { panic(err) } diff --git a/demo/sequencer/common/client.go b/demo/sequencer/common/client.go index 41d0469141..87dd634269 100644 --- a/demo/sequencer/common/client.go +++ b/demo/sequencer/common/client.go @@ -4,6 +4,7 @@ import ( "context" "flag" "fmt" + client "mosn.io/layotto/sdk/go-sdk/client" runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" ) diff --git a/demo/sequencer/in-memory/client.go b/demo/sequencer/in-memory/client.go index 13b8634532..c4ec224744 100644 --- a/demo/sequencer/in-memory/client.go +++ b/demo/sequencer/in-memory/client.go @@ -3,6 +3,7 @@ package main import ( "context" "fmt" + client "mosn.io/layotto/sdk/go-sdk/client" runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" ) diff --git a/demo/sequencer/mongo/client.go b/demo/sequencer/mongo/client.go index 4a6fecd530..a07a26663f 100644 --- a/demo/sequencer/mongo/client.go +++ b/demo/sequencer/mongo/client.go @@ -3,6 +3,7 @@ package main import ( "context" "fmt" + client "mosn.io/layotto/sdk/go-sdk/client" runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" ) diff --git a/demo/sequencer/redis/client.go b/demo/sequencer/redis/client.go index 87d7039382..5e06050a71 100644 --- a/demo/sequencer/redis/client.go +++ b/demo/sequencer/redis/client.go @@ -3,6 +3,7 @@ package main import ( "context" "fmt" + client "mosn.io/layotto/sdk/go-sdk/client" runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" ) diff --git a/demo/sequencer/zookeeper/client.go b/demo/sequencer/zookeeper/client.go index ab2e06eb82..5b9dc1674b 100644 --- a/demo/sequencer/zookeeper/client.go +++ b/demo/sequencer/zookeeper/client.go @@ -3,6 +3,7 @@ package main import ( "context" "fmt" + client "mosn.io/layotto/sdk/go-sdk/client" runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" ) diff --git a/demo/state/common/client.go b/demo/state/common/client.go index ec83cde469..352249b633 100755 --- a/demo/state/common/client.go +++ b/demo/state/common/client.go @@ -20,6 +20,7 @@ import ( "context" "flag" "fmt" + client "mosn.io/layotto/sdk/go-sdk/client" ) diff --git a/demo/state/redis/client.go b/demo/state/redis/client.go index 9cf284f789..3eb0b68b73 100755 --- a/demo/state/redis/client.go +++ b/demo/state/redis/client.go @@ -19,6 +19,7 @@ package main import ( "context" "fmt" + client "mosn.io/layotto/sdk/go-sdk/client" ) diff --git a/diagnostics/skywalking/grpc_tracer.go b/diagnostics/skywalking/grpc_tracer.go index 1b710f0f94..55b52fa81b 100644 --- a/diagnostics/skywalking/grpc_tracer.go +++ b/diagnostics/skywalking/grpc_tracer.go @@ -18,9 +18,10 @@ package skywalking import ( "context" - "mosn.io/layotto/diagnostics/grpc" "time" + "mosn.io/layotto/diagnostics/grpc" + "github.com/SkyAPM/go2sky" language_agent "github.com/SkyAPM/go2sky/reporter/grpc/language-agent" "mosn.io/api" diff --git a/build/contrib/builder/image/faas/Dockerfile b/docker/app/faas/Dockerfile similarity index 59% rename from build/contrib/builder/image/faas/Dockerfile rename to docker/app/faas/Dockerfile index a5cdde9756..2d6297ebe0 100644 --- a/build/contrib/builder/image/faas/Dockerfile +++ b/docker/app/faas/Dockerfile @@ -1,7 +1,6 @@ FROM golang:1.16 -MAINTAINER lingfenglangshao@gmail.com RUN apt-get update && apt-get install -y redis-server -RUN curl -L -O https://github.com/wasmerio/wasmer/releases/download/2.0.0/wasmer-linux-amd64.tar.gz +RUN curl -L -O https://github.com/wasmerio/wasmer/releases/download/2.2.1/wasmer-linux-amd64.tar.gz RUN tar zvxf wasmer-linux-amd64.tar.gz -RUN cp lib/libwasmer.so /usr/lib/libwasmer.so \ No newline at end of file +RUN cp lib/libwasmer.so /usr/lib/libwasmer.so diff --git a/docker/app/integrate/Dockerfile b/docker/app/integrate/Dockerfile new file mode 100644 index 0000000000..4299556983 --- /dev/null +++ b/docker/app/integrate/Dockerfile @@ -0,0 +1,3 @@ +FROM golang:1.16 + +RUN apt-get update && apt-get install -y redis-server diff --git a/docker/layotto/Dockerfile b/docker/layotto/Dockerfile new file mode 100644 index 0000000000..00bf12781b --- /dev/null +++ b/docker/layotto/Dockerfile @@ -0,0 +1,11 @@ +# A simplified docker file for building layotto base image + +FROM centos:centos7 + +COPY ./layotto /runtime/ + +WORKDIR /runtime + +RUN chmod +x /runtime/layotto + +ENTRYPOINT ["/runtime/layotto"] diff --git a/docs/en/development/commands.md b/docs/en/development/commands.md new file mode 100644 index 0000000000..12edb425c6 --- /dev/null +++ b/docs/en/development/commands.md @@ -0,0 +1,64 @@ +# Layotto Commands Guidelines: + +Layotto provides powerful commands, which makes contribution and local development/test easier. List as below: + + +## Highlights + ++ You can simply run `make all` to format your codes, make style checks, linter checks, unit tests, and build layotto binary for host platform. + ++ You can also run `make format` to format your codes. + ++ Run `make check` to make style checks, linter checks, unit tests. + ++ Run `make build` to build layotto binary for host platform. + +See below commands to know more details or excute `make help`: + +``` +Layotto commands 👀: + +A fast and efficient cloud native application runtime 🚀. +Commands below are used in Development 💻 and GitHub workflow 🌊. + +Usage: make ... + +COMMANDS: + build Build layotto for host platform. + build.multiarch Build layotto for multiple platforms. See option PLATFORMS. + image Build docker images for host arch. + image.multiarch Build docker images for multiple platforms. See option PLATFORMS. + push Push docker images to registry. + push.multiarch Push docker images for multiple platforms to registry. + app Build app docker images for host arch. [`/docker/app` contains apps dockerfiles] + app.multiarch Build app docker images for multiple platforms. See option PLATFORMS. + wasm Build layotto wasm for linux arm64 platform. + wasm.multiarch Build layotto wasm for multiple platform. + wasm.image Build layotto wasm image for multiple platform. + wasm.image.push Push layotto wasm image for multiple platform. + check Run all go checks of code sources. + check.lint Run go syntax and styling of go sources. + check.unit Run go unit test. + check.style Run go style test. + style.coverage Run coverage analysis. + style.deadlink Run deadlink check test. + style.quickstart Run quickstart check test. + integrate.wasm Run integration test with wasm. + integrate.runtime Run integration test with runtime. + format Format layotto go codes style with gofmt and goimports. + clean Remove all files that are created by building. + all Run format codes, check codes, build Layotto codes for host platform with one command + help Show this help info. + +ARGS: + BINS The binaries to build. Default is all of cmd. + This option is available when using: make build/build.multiarch + Example: make build BINS="layotto_multiple_api layotto" + IMAGES Backend images to make. Default is all of cmds. + This option is available when using: make image/image.multiarch/push/push.multiarch + Example: make image.multiarch IMAGES="layotto_multiple_api layotto" + PLATFORMS The multiple platforms to build. Default is linux_amd64 and linux_arm64. + This option is available when using: make build.multiarch/image.multiarch/push.multiarch + Example: make image.multiarch IMAGES="layotto" PLATFORMS="linux_amd64 linux_arm64" + Supported Platforms: linux_amd64 linux_arm64 darwin_amd64 darwin_arm64 +``` \ No newline at end of file diff --git a/docs/en/development/explanation-for-github-workflow.md b/docs/en/development/explanation-for-github-workflow.md deleted file mode 100644 index f79519951c..0000000000 --- a/docs/en/development/explanation-for-github-workflow.md +++ /dev/null @@ -1,81 +0,0 @@ -This document explain each component of Layotto's github workflow. - -Note: configuration files of Layotto github workflow are [here](https://github.com/mosn/layotto/tree/main/.github/workflows) - -## 1. Cron jobs -### stale bot -![img_1.png](../../img/development/workflow/img_1.png) - -We use [Close Stale Issues](https://github.com/marketplace/actions/close-stale-issues) . - -An issue or PR will be automatically marked as stale if it has not had recent activity in the last 30 days. It will be closed in the next 7 days unless it is tagged (pinned, security, good first issue or help wanted) or other activity occurs. - -**If a community task issue was closed by this bot,then the task can be assigned to others.** - -Merged in https://github.com/mosn/layotto/pull/246 - -## 2. CI/CD -![img.png](../../img/development/workflow/img.png) -### 2.1. Chore -#### <1> cla bot - -check if the contributor has signed cla - -#### TODO: Automatically generate new API reference when proto files are modified - -Currently [we have to do it manually](https://mosn.io/layotto/#/en/api_reference/how_to_generate_api_doc) . - -The generated documents are [here](https://github.com/mosn/layotto/blob/main/docs/en/api_reference/runtime_v1.md) and [here](https://github.com/mosn/layotto/blob/main/docs/en/api_reference/appcallback_v1.md) - -### 2.2. Test -#### <5> Run unit tests -#### <5> Check if you have done `go fmt` -#### <2><3> Make sure ut coverage ratio won't decrease - -See https://docs.codecov.com/docs/commit-status#branches - -#### TODO: Integration tests - - -### 2.3. Lint -#### <4> License checker -We use https://github.com/marketplace/actions/license-eye - -Merged in https://github.com/mosn/layotto/pull/247 - -##### How to add license headers for all files automatically? -In Layotto directory: - -```shell -docker run -it --rm -v $(pwd):/github/workspace apache/skywalking-eyes header fix -``` - -It will add license headers for code files recursively. - -##### How to configurate the License checker to ignore files of specified types? -The ignore list is in `.licenserc.yaml`. You can add new types into it. - -##### For more details of this tool -See https://github.com/marketplace/actions/license-eye#docker-image for details - -#### PR title lint -In order to standardize PR title, we add this check action. You can learn more in https://github.com/thehanimo/pr-title-checker. - -##### config the pr title check -If the title is in either `prefixes` or `regexp`, the check will pass. Otherwise , a label `title needs formatting` will be added to that pull request. -`regexpFlags` mean regular expression flags, such as : `i`(Case-insensitive search) `g`(Global search) . -``` -"CHECKS": { -"prefixes": ["fix: ", "feat: ","doc: "], -"regexp": "docs\\(v[0-9]\\): ", -"regexpFlags": "i", -"ignoreLabels" : ["dont-check-PRs-with-this-label", "meta"] -} -``` -~~#### TODO: PR body lint?~~ -#### TODO: Code style lint -For example,find out `go xxx()` without `recover` -We can use go lint and refer to MOSN's configuration - -#### ~~- Commit message lint~~ (reverted) -see https://github.com/mosn/layotto/issues/243 \ No newline at end of file diff --git a/docs/en/development/github-workflows.md b/docs/en/development/github-workflows.md new file mode 100644 index 0000000000..1ffda51538 --- /dev/null +++ b/docs/en/development/github-workflows.md @@ -0,0 +1,181 @@ +# Layotto GitHub Workflows + +本文档解释了 Layotto 的 Github 四大工作流: ++ Layotto Env Pipeline 🌊 ++ Layotto Dev Pipeline 🌊 (Before Merged) ++ Layotto Dev Pipeline 🌊 (After Merged) ++ Layotto Release Pipeline 🌊 + +工作流中包含了一个或多个任务,提高了 Layotto 的代码规范度和安全性,简化了开发/构建/发布等重复步骤,以下为对上述四大工作流的详细解释。 + +### Layotto Env Pipeline 🌊 + +#### Job 任务内容 + +Layotto Env Pipeline 流水线主要负责 Layotto 的项目以及相关环境的规范,其中目前包含以下任务: ++ Title Validation (基于 Semantic 风格 检查 PR Title 的规范) ++ Quickstart Validation (QuickStart 文档的校验) ++ Update Stale Status (Issue/PR 状态的更新) ++ License Validation (License 的校验) ++ DeadLink Validation (文档中 DeadLink 的检查) ++ CodeQL (CodeQL 的分析) + +#### Job 触发方式 + +Layotto Env Pipeline 流水线任务触发方式: ++ Title Validation: + ``` + pull_request: + types: + - opened 开启 PR + - edited 编辑 PR + - synchronize 同步 PR + - labeled PR 添加 Label + - unlabeled PR 取消 Label + ``` ++ Quickstart Validation: + ``` + push: + branches: + - main 合并 PR + pull_request: + branches: + - main 提交 PR + ``` ++ Update Stale Status: + ``` + on: + schedule: + - cron: '30 1 * * *' 定时任务 + ``` ++ License Validation: + ``` + push: + branches: + - main 合并 PR + pull_request: + branches: + - main 提交 PR + ``` ++ DeadLink Validation: + ``` + pull_request: + branches: + - main 提交 PR + ``` ++ CodeQL: + ``` + schedule: + - cron: '0 4 * * 5' 定时任务 + ``` + +### Layotto Dev Pipeline 🌊 (Before Merged) + +![release.png](../../img/development/workflow/workflow-dev.png) + +#### Job 任务内容 + +Layotto Dev Pipeline (Before Merged) 流水线主要负责 Layotto 提交 PR 后对代码的校验,其中目前包含以下若干任务: + ++ Go Style Check:对代码进行 风格校验 ++ Go CI Linter:对代码进行 Linter 规范校验 ++ Go Unit Test 对代码进行 单元测试 ++ Coverage Analysis 对代码进行 Coverage 分析 ++ Integrate with WASM 对代码进行 WASM 集成测试 ++ Integrate with Runtime 对代码进行 Runtime 集成测试 ++ Darwin AMD64 Artifact 对代码构建 Darwin AMD64 Binary 校验 ++ Darwin ARM64 Artifact 对代码构建 Darwin ARM64 Binary 校验 ++ Linux AMD64 Artifact 对代码构建 Linux AMD64Binary 校验 ++ Linux ARM64 Artifact 对代码构建 Linux ARM64 Binary 校验 ++ Linux AMD64 WASM Artifact 对 Layotto WASM 构建 Linux AMD64 Binary 校验 + +#### Job 触发方式 + +``` + on: + push: + branches: [main] 合并 PR + paths-ignore: 忽略以下变更: docs 目录下文件,markdown 文件 + - 'docs/**' + - '**/*.md' + pull_request: + branches: "*" 提交 PR + paths-ignore: 忽略以下变更: docs 目录下文件,markdown 文件 + - 'docs/**' + - '**/*.md' +``` + +### Layotto Dev Pipeline 🌊 (After Merged) + +![release.png](../../img/development/workflow/workflow-merge.png) + +#### Job 任务内容 + +Layotto Dev Pipeline (After Merged) 流水线主要负责 Layotto 代码合并后的校验和发布,其中目前包含以下任务: + ++ Go Style Check:对代码进行 风格校验 ++ Go CI Linter:对代码进行 Linter 规范校验 ++ Go Unit Test 对代码进行 单元测试 ++ Coverage Analysis 对代码进行 Coverage 分析 ++ Integrate with WASM 对代码进行 WASM 集成测试 ++ Integrate with Runtime 对代码进行 Runtime 集成测试 ++ Darwin AMD64 Artifact 对代码构建 Darwin AMD64 Binary 校验 ++ Darwin ARM64 Artifact 对代码构建 Darwin ARM64 Binary 校验 ++ Linux AMD64 Artifact 对代码构建 Linux AMD64Binary 校验 ++ Linux ARM64 Artifact 对代码构建 Linux ARM64 Binary 校验 ++ Linux AMD64 WASM Artifact 对 Layotto WASM 构建 Linux AMD64 Binary 校验 ++ Linux AMD64 WASM Image 发布最新版本的 Layotto WASM 镜像,镜像规范为 layotto/faas-amd64:latest ++ Linux AMD64 Image 发布最新版本的 Layotto 镜像,镜像规范为 layotto/layotto:latest ++ Linux ARMD64 Image 发布最新版本的 Layotto 镜像,镜像规范为 layotto/layotto.arm64:latest + +#### Job 触发方式 + +``` + on: + push: + branches: [main] 合并 PR + paths-ignore: 忽略以下变更: docs 目录下文件,markdown 文件 + - 'docs/**' + - '**/*.md' + pull_request: + branches: "*" 提交 PR + paths-ignore: 忽略以下变更: docs 目录下文件,markdown 文件 + - 'docs/**' + - '**/*.md' +``` + +### Layotto Release Pipeline 🌊 + +![release.png](../../img/development/workflow/workflow-release.png) + +#### Job 任务内容 + +Layotto Release Pipeline 流水线主要负责 Layotto 新版本发布以及校验,其中目前包含以下任务: + ++ Go Style Check:对代码进行 风格校验 ++ Go CI Linter:对代码进行 Linter 规范校验 ++ Go Unit Test 对代码进行 单元测试 ++ Coverage Analysis 对代码进行 Coverage 分析 ++ Integrate with WASM 对代码进行 WASM 集成测试 ++ Integrate with Runtime 对代码进行 Runtime 集成测试 ++ Darwin AMD64 Artifact 对代码构建 Darwin AMD64 Binary 校验 ++ Darwin ARM64 Artifact 对代码构建 Darwin ARM64 Binary 校验 ++ Linux AMD64 Artifact 对代码构建 Linux AMD64Binary 校验 ++ Linux ARM64 Artifact 对代码构建 Linux ARM64 Binary 校验 ++ Linux AMD64 WASM Artifact 对 Layotto WASM 构建 Linux AMD64 Binary 校验 ++ Linux AMD64 WASM Image 发布 Release 版本的 Layotto WASM 镜像,镜像规范为 layotto/faas-amd64:{latest_tagname} ++ Linux AMD64 Image 发布 Release 版本的 Layotto 镜像,镜像规范为 layotto/layotto:{latest_tagname} ++ Linux ARMD64 Image 发布 Release 版本的 Layotto 镜像,镜像规范为 layotto/layotto.arm64:{latest_tagname} + +#### Job 触发方式 + +``` + on: + create 创建 Tag 或 Branch,结合以下条件 + + if: ${{ startsWith(github.ref, 'refs/tags/') }} 变更为 Tag(忽略新 Branch 的创建) +``` + +> Layotto 的 github 工作流的配置文件在[这里](https://github.com/mosn/layotto/tree/main/.github/workflows) + +> TODO: need to translate. \ No newline at end of file diff --git a/docs/img/development/workflow/img.png b/docs/img/development/workflow/img.png deleted file mode 100644 index dcad7276ae..0000000000 Binary files a/docs/img/development/workflow/img.png and /dev/null differ diff --git a/docs/img/development/workflow/img_1.png b/docs/img/development/workflow/img_1.png deleted file mode 100644 index 915c963a9d..0000000000 Binary files a/docs/img/development/workflow/img_1.png and /dev/null differ diff --git a/docs/img/development/workflow/release.png b/docs/img/development/workflow/release.png new file mode 100644 index 0000000000..c03335fcac Binary files /dev/null and b/docs/img/development/workflow/release.png differ diff --git a/docs/img/development/workflow/workflow-dev.png b/docs/img/development/workflow/workflow-dev.png new file mode 100644 index 0000000000..41ae1f72b2 Binary files /dev/null and b/docs/img/development/workflow/workflow-dev.png differ diff --git a/docs/img/development/workflow/workflow-merge.png b/docs/img/development/workflow/workflow-merge.png new file mode 100644 index 0000000000..2bad2e9d31 Binary files /dev/null and b/docs/img/development/workflow/workflow-merge.png differ diff --git a/docs/img/development/workflow/workflow-release.png b/docs/img/development/workflow/workflow-release.png new file mode 100644 index 0000000000..9327d217be Binary files /dev/null and b/docs/img/development/workflow/workflow-release.png differ diff --git a/docs/zh/development/commands.md b/docs/zh/development/commands.md new file mode 100644 index 0000000000..095005b0f4 --- /dev/null +++ b/docs/zh/development/commands.md @@ -0,0 +1,64 @@ +# Layotto 命令指南: + +Layotto 提供了丰富的命令行工具,方便贡献者开发和测试 Layotto 代码,具体命令如下: + + +## 重要开发命令 + ++ 你可以执行 `make all` 去格式化你的代码,进行风格测试,linter 规范测试,单元测试,以及构建当前平台的二进制文件。 + ++ 你也可以执行 `make format` 去格式化你的代码 + ++ 执行 `make check` 进行风格测试,linter 规范测试,单元测试 + ++ 执行 `make build` 构建当前平台的二进制文件 + +具体细节可查看一下命令,或执行 `make help` 查看: + +``` +Layotto commands 👀: + +A fast and efficient cloud native application runtime 🚀. +Commands below are used in Development 💻 and GitHub workflow 🌊. + +Usage: make ... + +COMMANDS: + build Build layotto for host platform. + build.multiarch Build layotto for multiple platforms. See option PLATFORMS. + image Build docker images for host arch. + image.multiarch Build docker images for multiple platforms. See option PLATFORMS. + push Push docker images to registry. + push.multiarch Push docker images for multiple platforms to registry. + app Build app docker images for host arch. [`/docker/app` contains apps dockerfiles] + app.multiarch Build app docker images for multiple platforms. See option PLATFORMS. + wasm Build layotto wasm for linux arm64 platform. + wasm.multiarch Build layotto wasm for multiple platform. + wasm.image Build layotto wasm image for multiple platform. + wasm.image.push Push layotto wasm image for multiple platform. + check Run all go checks of code sources. + check.lint Run go syntax and styling of go sources. + check.unit Run go unit test. + check.style Run go style test. + style.coverage Run coverage analysis. + style.deadlink Run deadlink check test. + style.quickstart Run quickstart check test. + integrate.wasm Run integration test with wasm. + integrate.runtime Run integration test with runtime. + format Format layotto go codes style with gofmt and goimports. + clean Remove all files that are created by building. + all Run format codes, check codes, build Layotto codes for host platform with one command + help Show this help info. + +ARGS: + BINS The binaries to build. Default is all of cmd. + This option is available when using: make build/build.multiarch + Example: make build BINS="layotto_multiple_api layotto" + IMAGES Backend images to make. Default is all of cmds. + This option is available when using: make image/image.multiarch/push/push.multiarch + Example: make image.multiarch IMAGES="layotto_multiple_api layotto" + PLATFORMS The multiple platforms to build. Default is linux_amd64 and linux_arm64. + This option is available when using: make build.multiarch/image.multiarch/push.multiarch + Example: make image.multiarch IMAGES="layotto" PLATFORMS="linux_amd64 linux_arm64" + Supported Platforms: linux_amd64 linux_arm64 darwin_amd64 darwin_arm64 +``` \ No newline at end of file diff --git a/docs/zh/development/explanation-for-github-workflow.md b/docs/zh/development/explanation-for-github-workflow.md deleted file mode 100644 index ef552e8083..0000000000 --- a/docs/zh/development/explanation-for-github-workflow.md +++ /dev/null @@ -1,87 +0,0 @@ -本文档解释了Layotto的github工作流的每个组件。 - -注意:Layotto的github工作流的配置文件在[这里](https://github.com/mosn/layotto/tree/main/.github/workflows) - -## 1. 定时任务 -### stale bot -![img_1.png](../../img/development/workflow/img_1.png) - -我们将会[关闭超时的Issues](https://github.com/marketplace/actions/close-stale-issues) - -如果一个issue或PR在过去30天内没有最近的活动,它将自动标记为陈旧的。它将在7天后关闭,除非它被特殊 label 标记 (pinned,security,good first issue或help wanted) 或有其他活动发生。 - -**如果这个社区任务issue被这个自动程序关闭,那么这个任务将会被分配给其他人。** - -合并于 https://github.com/mosn/layotto/pull/246 - -## 2. 持续集成/持续交付 -![img.png](../../img/development/workflow/img.png) -### 2.1. Chore -#### <1> cla bot - -检查贡献者是否签署了贡献许可协议 - -#### TODO: 在修改proto文件时自动生成新的 API 文档 - -目前[我们必须手动完成](https://mosn.io/layotto/#/en/api_reference/how_to_generate_api_doc)。 - -生成的文件在[这里](https://github.com/mosn/layotto/blob/main/docs/en/api_reference/runtime_v1.md)或者[这里](https://github.com/mosn/layotto/blob/main/docs/en/api_reference/appcallback_v1.md) - -### 2.2. Test -#### <5> 执行单元测试 -#### <5> 检查你是否完成了`go fmt` -#### <2><3> 确保单元测试的覆盖率不会下降 - -具体请查看 https://docs.codecov.com/docs/commit-status#branches - -#### TODO: 集成测试 - - -### 2.3. Lint -#### <4> License checker -我们使用https://github.com/marketplace/actions/license-eye - -合并于https://github.com/mosn/layotto/pull/247 - -##### 如何为所有文件自动添加许可证头文件 - -在Layotto目录下执行: - -```shell -docker run -it --rm -v $(pwd):/github/workspace apache/skywalking-eyes header fix -``` - -它将递归地为代码文件添加许可头。 - -##### 如何配置许可证检查器忽略指定类型的文件 - -忽略检查列表在 `.licenserc.yaml`中,你可以添加新的类型进去。 - -##### 有关此工具的更多详细信息 -请查看 https://github.com/marketplace/actions/license-eye#docker-image 来获取详细信息。 - -#### PR title lint -为了规范PR标题,我们添加了这个检查操作。你可以在https://github.com/thehanimo/pr-title-checker获取更多详细信息。 - -##### 配置pr标题检查 -对于一个 pull request 如果标题在 `prefixes` 或 `regexp` 中,则检查通过。否则,一个标签`title needs formatting`将被添加到那个pull request中。 - -`regexpFlags` 意味着正则表达式, 例如 : `i`(Case-insensitive search) `g`(Global search) . - -``` -"CHECKS": { -"prefixes": ["fix: ", "feat: ","doc: "], -"regexp": "docs\\(v[0-9]\\): ", -"regexpFlags": "i", -"ignoreLabels" : ["dont-check-PRs-with-this-label", "meta"] -} -``` -~~#### TODO: PR body lint?~~ - -#### TODO: Code style lint -举个例子,找出 `go xxx()` 没有 `recover` - -我们可以使用 go lint, 参考MOSN的配置 - -#### ~~- Commit message lint~~ (reverted) -具体请查看 https://github.com/mosn/layotto/issues/243 \ No newline at end of file diff --git a/docs/zh/development/github-workflows.md b/docs/zh/development/github-workflows.md new file mode 100644 index 0000000000..e96372a60d --- /dev/null +++ b/docs/zh/development/github-workflows.md @@ -0,0 +1,179 @@ +# Layotto GitHub Workflows + +本文档解释了 Layotto 的 Github 四大工作流: ++ Layotto Env Pipeline 🌊 ++ Layotto Dev Pipeline 🌊 (Before Merged) ++ Layotto Dev Pipeline 🌊 (After Merged) ++ Layotto Release Pipeline 🌊 + +工作流中包含了一个或多个任务,提高了 Layotto 的代码规范度和安全性,简化了开发/构建/发布等重复步骤,以下为对上述四大工作流的详细解释。 + +### Layotto Env Pipeline 🌊 + +#### Job 任务内容 + +Layotto Env Pipeline 流水线主要负责 Layotto 的项目以及相关环境的规范,其中目前包含以下任务: ++ Title Validation (基于 Semantic 风格 检查 PR Title 的规范) ++ Quickstart Validation (QuickStart 文档的校验) ++ Update Stale Status (Issue/PR 状态的更新) ++ License Validation (License 的校验) ++ DeadLink Validation (文档中 DeadLink 的检查) ++ CodeQL (CodeQL 的分析) + +#### Job 触发方式 + +Layotto Env Pipeline 流水线任务触发方式: ++ Title Validation: + ``` + pull_request: + types: + - opened 开启 PR + - edited 编辑 PR + - synchronize 同步 PR + - labeled PR 添加 Label + - unlabeled PR 取消 Label + ``` ++ Quickstart Validation: + ``` + push: + branches: + - main 合并 PR + pull_request: + branches: + - main 提交 PR + ``` ++ Update Stale Status: + ``` + on: + schedule: + - cron: '30 1 * * *' 定时任务 + ``` ++ License Validation: + ``` + push: + branches: + - main 合并 PR + pull_request: + branches: + - main 提交 PR + ``` ++ DeadLink Validation: + ``` + pull_request: + branches: + - main 提交 PR + ``` ++ CodeQL: + ``` + schedule: + - cron: '0 4 * * 5' 定时任务 + ``` + +### Layotto Dev Pipeline 🌊 (Before Merged) + +![release.png](../../img/development/workflow/workflow-dev.png) + +#### Job 任务内容 + +Layotto Dev Pipeline (Before Merged) 流水线主要负责 Layotto 提交 PR 后对代码的校验,其中目前包含以下若干任务: + ++ Go Style Check:对代码进行 风格校验 ++ Go CI Linter:对代码进行 Linter 规范校验 ++ Go Unit Test 对代码进行 单元测试 ++ Coverage Analysis 对代码进行 Coverage 分析 ++ Integrate with WASM 对代码进行 WASM 集成测试 ++ Integrate with Runtime 对代码进行 Runtime 集成测试 ++ Darwin AMD64 Artifact 对代码构建 Darwin AMD64 Binary 校验 ++ Darwin ARM64 Artifact 对代码构建 Darwin ARM64 Binary 校验 ++ Linux AMD64 Artifact 对代码构建 Linux AMD64Binary 校验 ++ Linux ARM64 Artifact 对代码构建 Linux ARM64 Binary 校验 ++ Linux AMD64 WASM Artifact 对 Layotto WASM 构建 Linux AMD64 Binary 校验 + +#### Job 触发方式 + +``` + on: + push: + branches: [main] 合并 PR + paths-ignore: 忽略以下变更: docs 目录下文件,markdown 文件 + - 'docs/**' + - '**/*.md' + pull_request: + branches: "*" 提交 PR + paths-ignore: 忽略以下变更: docs 目录下文件,markdown 文件 + - 'docs/**' + - '**/*.md' +``` + +### Layotto Dev Pipeline 🌊 (After Merged) + +![release.png](../../img/development/workflow/workflow-merge.png) + +#### Job 任务内容 + +Layotto Dev Pipeline (After Merged) 流水线主要负责 Layotto 代码合并后的校验和发布,其中目前包含以下任务: + ++ Go Style Check:对代码进行 风格校验 ++ Go CI Linter:对代码进行 Linter 规范校验 ++ Go Unit Test 对代码进行 单元测试 ++ Coverage Analysis 对代码进行 Coverage 分析 ++ Integrate with WASM 对代码进行 WASM 集成测试 ++ Integrate with Runtime 对代码进行 Runtime 集成测试 ++ Darwin AMD64 Artifact 对代码构建 Darwin AMD64 Binary 校验 ++ Darwin ARM64 Artifact 对代码构建 Darwin ARM64 Binary 校验 ++ Linux AMD64 Artifact 对代码构建 Linux AMD64Binary 校验 ++ Linux ARM64 Artifact 对代码构建 Linux ARM64 Binary 校验 ++ Linux AMD64 WASM Artifact 对 Layotto WASM 构建 Linux AMD64 Binary 校验 ++ Linux AMD64 WASM Image 发布最新版本的 Layotto WASM 镜像,镜像规范为 layotto/faas-amd64:latest ++ Linux AMD64 Image 发布最新版本的 Layotto 镜像,镜像规范为 layotto/layotto:latest ++ Linux ARMD64 Image 发布最新版本的 Layotto 镜像,镜像规范为 layotto/layotto.arm64:latest + +#### Job 触发方式 + +``` + on: + push: + branches: [main] 合并 PR + paths-ignore: 忽略以下变更: docs 目录下文件,markdown 文件 + - 'docs/**' + - '**/*.md' + pull_request: + branches: "*" 提交 PR + paths-ignore: 忽略以下变更: docs 目录下文件,markdown 文件 + - 'docs/**' + - '**/*.md' +``` + +### Layotto Release Pipeline 🌊 + +![release.png](../../img/development/workflow/workflow-release.png) + +#### Job 任务内容 + +Layotto Release Pipeline 流水线主要负责 Layotto 新版本发布以及校验,其中目前包含以下任务: + ++ Go Style Check:对代码进行 风格校验 ++ Go CI Linter:对代码进行 Linter 规范校验 ++ Go Unit Test 对代码进行 单元测试 ++ Coverage Analysis 对代码进行 Coverage 分析 ++ Integrate with WASM 对代码进行 WASM 集成测试 ++ Integrate with Runtime 对代码进行 Runtime 集成测试 ++ Darwin AMD64 Artifact 对代码构建 Darwin AMD64 Binary 校验 ++ Darwin ARM64 Artifact 对代码构建 Darwin ARM64 Binary 校验 ++ Linux AMD64 Artifact 对代码构建 Linux AMD64Binary 校验 ++ Linux ARM64 Artifact 对代码构建 Linux ARM64 Binary 校验 ++ Linux AMD64 WASM Artifact 对 Layotto WASM 构建 Linux AMD64 Binary 校验 ++ Linux AMD64 WASM Image 发布 Release 版本的 Layotto WASM 镜像,镜像规范为 layotto/faas-amd64:{latest_tagname} ++ Linux AMD64 Image 发布 Release 版本的 Layotto 镜像,镜像规范为 layotto/layotto:{latest_tagname} ++ Linux ARMD64 Image 发布 Release 版本的 Layotto 镜像,镜像规范为 layotto/layotto.arm64:{latest_tagname} + +#### Job 触发方式 + +``` + on: + create 创建 Tag 或 Branch,结合以下条件 + + if: ${{ startsWith(github.ref, 'refs/tags/') }} 变更为 Tag(忽略新 Branch 的创建) +``` + +> Layotto 的 github 工作流的配置文件在[这里](https://github.com/mosn/layotto/tree/main/.github/workflows) \ No newline at end of file diff --git a/docs/zh/development/release-guide.md b/docs/zh/development/release-guide.md index 687688b732..2b2665512f 100644 --- a/docs/zh/development/release-guide.md +++ b/docs/zh/development/release-guide.md @@ -1,29 +1,57 @@ # 发布手册 本文介绍下发布新版本时,发布负责人需要做什么 + ## 发布周期 Layotto 发布周期暂定为每季度发布一次。 ## 发布 checklist -- [ ] 检查 [当前迭代的roadmap](https://github.com/mosn/layotto/projects) ,看看是否有进行中、没做完的事情,和负责人确认下能否带着一起发布 - -- [ ] 跑通所有测试(包括单元测试,集成测试和demo) +#### Step1: 检查当前迭代的 [Roadmap](https://github.com/mosn/layotto/projects) + +1. 检查进行中的任务 +2. 检查未完成的任务 +3. 与负责人确认任务状态和发布内容 -- [ ] 编译不同操作系统下的二进制 Layotto。 至少包括 Linux和 Mac(amd64)的: +#### Step2: 创建发布 tag, push 至 github 并检查工作流 -![img.png](../../img/development/release/img.png) - -- [ ] Draft a new release +1. 规范:请按照 `v{majorVersion}.{subVersion}.{latestVersion}` 格式创建 tag。 +2. 等待 CI 结束,确认以下内容: + + CI 测试 Jobs 全部通过: + + Go 代码风格校验 + + Go 代码规范校验 + + Go 单元测试 + + Go 集成测试 + + CI 多平台 Artifacts 构建 Jobs 全部通过: + + Linux/AMD64 Artifacts 成功 Build 并 Upload + + Linux/ARM64 Artifacts 成功 Build 并 Upload + + Darwin/AMD64 Artifacts 成功 Build 并 Upload + + Darwin/ARM64 Artifacts 成功 Build 并 Upload + + CI 多平台 Image 构建/发布 Jobs 全部通过: + + Linux/AMD64 Image 成功 Build 并 Push DockerHub + + Linux/ARM64 Image 成功 Build 并 Push DockerHub + + Image Tag 规范: + + AMD64/X86 架构的镜像:`layotto/layotto:{tag}` + + ARM64 架构的镜像:`layotto/layotto.arm64:{tag}` -![img_1.png](../../img/development/release/img_1.png) - -- [ ] 打tag、写发布报告 +![release.png](../../img/development/workflow/release.png) + +#### Step3: Draft a new release 并编写发布报告 -发布报告可以先用github的功能自动生成,再基于生成的内容做修改。 +> 发布报告可以先用 github 的功能自动生成,再基于生成的内容做修改。 + +> 可以参考以前的 [发版报告](https://github.com/mosn/layotto/releases) + +![img_1.png](../../img/development/release/img_1.png) + +#### Step4: 上传多平台架构的 Binaries + +> 不必手动构建,直接将 `步骤 2` 中构建的多平台 Artifacts 下载上传即可 + +![img.png](../../img/development/release/img.png) -可以参考以前的 [发版报告](https://github.com/mosn/layotto/releases) +#### Step5: 确认发布 -- [ ] 点按钮,发布 -- [ ] 群里发个消息通知下大家 -- [ ] 发布完成后,创建[下次迭代的roadmap](https://github.com/mosn/layotto/projects) (可能已经有了),可以把上个版本没做完的事项挪进来 -- [ ] 如果有相应的 SDK 需要发布,参考上述流程,在 SDK 仓库做发布,并上传中央仓库 (比如 java sdk需要上传到 Maven 中央仓库)。 \ No newline at end of file +1. 点击发布 +2. 社区周知 +3. 检查 [Roadmap](https://github.com/mosn/layotto/projects),修改上个版本未完成的任务,把 milestone 改为下个版本 +4. 如果有 SDK 发布,需在 SDK 仓库做发布,并上传中央仓库 (比如 Java SDK 需要上传到 Maven 中央仓库)。 \ No newline at end of file diff --git a/etc/script/test-quickstart.sh b/etc/script/test-quickstart.sh index 93c69e6d2b..8f8f7a8ca3 100644 --- a/etc/script/test-quickstart.sh +++ b/etc/script/test-quickstart.sh @@ -1,4 +1,3 @@ #!/usr/bin/env bash - -./mdsh.sh docs/en/start/state/start.md -./mdsh.sh docs/zh/start/state/start.md \ No newline at end of file +$(pwd)/etc/script/mdsh.sh docs/en/start/state/start.md +$(pwd)/etc/script/mdsh.sh docs/zh/start/state/start.md \ No newline at end of file diff --git a/go.mod b/go.mod index 8b6ff29fe9..4ec2e9bbfe 100644 --- a/go.mod +++ b/go.mod @@ -28,13 +28,13 @@ require ( github.com/urfave/cli v1.22.1 github.com/valyala/fasthttp v1.28.0 go.uber.org/automaxprocs v1.4.0 // indirect - golang.org/x/net v0.0.0-20211005001312-d4b1ae081e3b // indirect + golang.org/x/tools v0.1.10 // indirect google.golang.org/grpc v1.39.0 google.golang.org/grpc/examples v0.0.0-20210818220435-8ab16ef276a3 google.golang.org/protobuf v1.27.1 mosn.io/api v0.0.0-20220308091133-b233c56e98c7 mosn.io/layotto/components v0.0.0-20220413092851-55c58dbb1a23 - mosn.io/layotto/sdk/go-sdk v0.0.0-20220311052659-a386713c7c13 + mosn.io/layotto/sdk/go-sdk v0.0.0-20220422112241-cd96c75e590f mosn.io/layotto/spec v0.0.0-20220413092851-55c58dbb1a23 mosn.io/mosn v1.0.0 mosn.io/pkg v0.0.0-20220331064139-949046a47fa2 diff --git a/go.sum b/go.sum index db951bbad1..fff25ed029 100644 --- a/go.sum +++ b/go.sum @@ -1404,6 +1404,7 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/gopher-lua v0.0.0-20191220021717-ab39c6098bdb/go.mod h1:gqRgreBUhTSL0GeU64rtZ3Uq3wtjOa/TB2YfrtkCbVQ= github.com/yuin/gopher-lua v0.0.0-20200603152657-dc2b0ca8b37e/go.mod h1:gqRgreBUhTSL0GeU64rtZ3Uq3wtjOa/TB2YfrtkCbVQ= github.com/yuin/gopher-lua v0.0.0-20200816102855-ee81675732da h1:NimzV1aGyq29m5ukMK0AMWEhFaL/lrEOaephfuoiARg= @@ -1584,8 +1585,9 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o= +golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180406214816-61147c48b25b/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1643,8 +1645,8 @@ golang.org/x/net v0.0.0-20210331212208-0fccb6fa2b5c/go.mod h1:p54w0d4576C0XHj96b golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211005001312-d4b1ae081e3b h1:SXy8Ld8oKlcogOvUAh0J5Pm5RKzgYBMMxLxt6n5XW50= -golang.org/x/net v0.0.0-20211005001312-d4b1ae081e3b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f h1:OfiFi4JbukWwe3lzw+xunroH1mnC1e2Gy5cxNJApiSY= +golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1760,6 +1762,7 @@ golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210819135213-f52c844e1c1c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211020174200-9d6173849985/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220204135822-1c1b9b1eba6a h1:ppl5mZgokTT8uPkmYOyEUmPTr3ypaKkg5eFOGrAmxxE= golang.org/x/sys v0.0.0-20220204135822-1c1b9b1eba6a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1864,8 +1867,9 @@ golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.4 h1:cVngSRcfgyZCzys3KYOpCFa+4dqX/Oub9tAq00ttGVs= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.10 h1:QjFRCZxdOhBJ/UNgnBZLbNV13DlbnK0quyivTnXJM20= +golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -2115,11 +2119,9 @@ mosn.io/api v0.0.0-20211217011300-b851d129be01/go.mod h1:TBv4bz2f2RbpgdohbVAFRFV mosn.io/api v0.0.0-20220308091133-b233c56e98c7 h1:tfV6pjJaasWhcQVzjNrihQ9y9VWW6v82vPUE4RD7K1Y= mosn.io/api v0.0.0-20220308091133-b233c56e98c7/go.mod h1:TBv4bz2f2RbpgdohbVAFRFVOoN8YyEUiLH3jAh752Qc= mosn.io/holmes v0.0.0-20220314072258-139da3429e04/go.mod h1:pZjPamcZk4Z16xlZySG1rU9psLUCOx6MVNuj/3bfkEk= -mosn.io/layotto/sdk/go-sdk v0.0.0-20220311052659-a386713c7c13 h1:fc6ZJwISIjkhmbxemb4YK2wZYWaqYiXwrvGCgC6YqBg= -mosn.io/layotto/sdk/go-sdk v0.0.0-20220311052659-a386713c7c13/go.mod h1:mMrIBDCM2kTSCFC5a7rog00FPxCVCSh5Qtq81X4f9f8= +mosn.io/layotto/sdk/go-sdk v0.0.0-20220422112241-cd96c75e590f h1:YlTX+AVcE1IoRhHrl56rJnO0zhwyNwPqsHexYWJgSW8= +mosn.io/layotto/sdk/go-sdk v0.0.0-20220422112241-cd96c75e590f/go.mod h1:mMrIBDCM2kTSCFC5a7rog00FPxCVCSh5Qtq81X4f9f8= mosn.io/mosn v0.25.1-0.20211217125944-69b50c40af81/go.mod h1:JwLkls6oMaap0+P1uZ1d1ccdLPigdK8xH8gDSm3SEq4= -mosn.io/mosn v0.27.0 h1:AZaMP01l3PkxHqAjrvenrclR5ZeXqdjh0Gj3ulCZcAU= -mosn.io/mosn v0.27.0/go.mod h1:RLNWxwi80A+i7uh6/uQY9RaLohmNxO64YkKggwQb8ZU= mosn.io/mosn v1.0.0 h1:IJyhNJDhgWM9z1J8JOwbd9VRVr1ODOEEGg19ByigHEY= mosn.io/mosn v1.0.0/go.mod h1:RLNWxwi80A+i7uh6/uQY9RaLohmNxO64YkKggwQb8ZU= mosn.io/pkg v0.0.0-20211217101631-d914102d1baf/go.mod h1:tK3Vbw6CcVeJ9H/BGjJ1wn6hRXt4Oxjfq1+gkOM0zG8= diff --git a/make/ci.mk b/make/ci.mk new file mode 100644 index 0000000000..714fde9728 --- /dev/null +++ b/make/ci.mk @@ -0,0 +1,73 @@ +# Copyright 2021 Layotto Authors +# 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. + + +APPS ?= faas integrate +APP_PLATFORMS = linux_amd64 linux_arm64 + +.PHONY: app.image +app.image: image.verify $(addprefix app.image., $(addprefix $(IMAGE_PLAT)., $(APPS))) + +.PHONY: app.image.multiarch +app.image.multiarch: image.verify $(foreach p,$(APP_PLATFORMS),$(addprefix app.image., $(addprefix $(p)., $(APPS)))) + +.PHONY: app.image.% +app.image.%: + $(eval PLATFORM := $(word 1,$(subst ., ,$*))) + $(eval APP := $(word 2,$(subst ., ,$*))) + $(eval ARCH := $(word 2,$(subst _, ,$(PLATFORM)))) + $(eval IMAGE_PLAT := $(subst _,/,$(PLATFORM))) + @echo "===========> Building docker image $(APP) $(VERSION) for $(IMAGE_PLAT)" + @mkdir -p $(TMP_DIR)/$(APP) + @cat $(ROOT_DIR)/docker/app/$(APP)/Dockerfile\ + >$(TMP_DIR)/$(APP)/Dockerfile + $(eval BUILD_SUFFIX := $(_DOCKER_BUILD_EXTRA_ARGS) --pull -t $(REGISTRY_PREFIX)/$(APP)-$(ARCH):$(VERSION) $(TMP_DIR)/$(APP)) + $(DOCKER) build --platform $(IMAGE_PLAT) $(BUILD_SUFFIX) + +.PHONY: checker.deadlink +checker.deadlink: + @echo "===========> Checking Dead Links" + sh ${SCRIPT_DIR}/check-dead-link.sh + +.PHONY: checker.quickstart +checker.quickstart: + @echo "===========> Checking QuickStart Doc" + curl -o ${ROOT_DIR}/mdsh.sh https://raw.githubusercontent.com/seeflood/mdsh/master/bin/mdsh + mv ${ROOT_DIR}/mdsh.sh ${SCRIPT_DIR} + chmod +x ${SCRIPT_DIR}/mdsh.sh + sh ${SCRIPT_DIR}/test-quickstart.sh + +.PHONY: checker.coverage +checker.coverage: + @echo "===========> Coverage Analysis" + sh ${SCRIPT_DIR}/report.sh + +.PHONY: integration.wasm +integration.wasm: app.image.linux_amd64.faas + @echo "===========> Integration Test With WASM" + $(eval ACTION := sh ./wasm_test.sh) + $(eval ARCH := $(word 2,$(subst _, ,$(PLATFORM)))) + $(eval BUILD_IMAGE := $(REGISTRY_PREFIX)/faas-$(ARCH):$(VERSION)) + $(eval WORKDIR := -w /go/src/${PROJECT_NAME} ) + $(eval INTEGRATE_SUFFIX := -v $(ROOT_DIR):/go/src/${PROJECT_NAME} -v ${TEST_DIR}/wasm/wasm_test.sh:/go/src/${PROJECT_NAME}/wasm_test.sh $(WORKDIR)) + $(DOCKER) run --rm $(INTEGRATE_SUFFIX) $(BUILD_IMAGE) $(ACTION) + +.PHONY: integration.runtime +integration.runtime: app.image.linux_amd64.integrate + @echo "===========> Integration Test With Runtime" + $(eval ACTION := sh ./integrate_test.sh) + $(eval ARCH := $(word 2,$(subst _, ,$(PLATFORM)))) + $(eval BUILD_IMAGE := $(REGISTRY_PREFIX)/integrate-$(ARCH):$(VERSION)) + $(eval WORKDIR := -w /go/src/${PROJECT_NAME} ) + $(eval INTEGRATE_SUFFIX := -v $(ROOT_DIR):/go/src/${PROJECT_NAME} -v ${TEST_DIR}/runtime/integrate_test.sh:/go/src/${PROJECT_NAME}/integrate_test.sh $(WORKDIR)) + $(DOCKER) run --rm $(INTEGRATE_SUFFIX) ${BUILD_IMAGE} $(ACTION) diff --git a/make/common.mk b/make/common.mk new file mode 100644 index 0000000000..8a30ec62a0 --- /dev/null +++ b/make/common.mk @@ -0,0 +1,85 @@ +# Copyright 2021 Layotto Authors +# 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. + +SHELL := /bin/bash + +# include the common make file +COMMON_SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +PROJECT_NAME := mosn.io/layotto +BINARY_PREFIX := layotto + +ifeq ($(origin ROOT_DIR),undefined) +ROOT_DIR := $(abspath $(shell cd $(COMMON_SELF_DIR)/.. && pwd -P)) +endif +ifeq ($(origin OUTPUT_DIR),undefined) +OUTPUT_DIR := $(ROOT_DIR)/_output +$(shell mkdir -p $(OUTPUT_DIR)) +endif +ifeq ($(origin TMP_DIR),undefined) +TMP_DIR := $(OUTPUT_DIR)/tmp +$(shell mkdir -p $(TMP_DIR)) +endif +ifeq ($(origin DOCS_DIR),undefined) +DOCS_DIR := $(ROOT_DIR)/docs +endif +ifeq ($(origin TEST_DIR),undefined) +TEST_DIR := $(ROOT_DIR)/test +endif +ifeq ($(origin DEMO_DIR),undefined) +DEMO_DIR := $(ROOT_DIR)/demo +endif +ifeq ($(origin CONFIG_DIR),undefined) +CONFIG_DIR := $(ROOT_DIR)/configs +DEFAULT_CONFIG_FILE := $(CONFIG_DIR)/runtime_config.json +endif +ifeq ($(origin SCRIPT_DIR),undefined) +SCRIPT_DIR := $(ROOT_DIR)/etc/script +endif +ifeq ($(origin SUPERVISOR_DIR),undefined) +SUPERVISOR_DIR := $(ROOT_DIR)/etc/supervisor +endif + +# set the version number. you should not need to do this +# for the majority of scenarios. +ifeq ($(origin VERSION), undefined) +VERSION := $(shell git describe --abbrev=0 --dirty --always --tags | sed 's/-/./g') +endif +# Check if the tree is dirty. default to dirty +GIT_TREE_STATE:="dirty" +ifeq (, $(shell git status --porcelain 2>/dev/null)) + GIT_TREE_STATE="clean" +endif +GIT_COMMIT:=$(shell git rev-parse HEAD) + +PLATFORMS ?= darwin_amd64 darwin_arm64 linux_amd64 linux_arm64 + +# Set a specific PLATFORM +ifeq ($(origin PLATFORM), undefined) + ifeq ($(origin GOOS), undefined) + GOOS := $(shell go env GOOS) + endif + ifeq ($(origin GOARCH), undefined) + GOARCH := $(shell go env GOARCH) + endif + PLATFORM := $(GOOS)_$(GOARCH) + # Use linux as the default OS when building images + IMAGE_PLAT := linux_$(GOARCH) +else + GOOS := $(word 1, $(subst _, ,$(PLATFORM))) + GOARCH := $(word 2, $(subst _, ,$(PLATFORM))) + IMAGE_PLAT := $(PLATFORM) +endif + +COMMA := , +SPACE := +SPACE += diff --git a/make/golang.mk b/make/golang.mk new file mode 100644 index 0000000000..c56ab23553 --- /dev/null +++ b/make/golang.mk @@ -0,0 +1,110 @@ +# Copyright 2021 Layotto Authors +# 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. + +GO := go +GO_FMT := gofmt +GO_IMPORTS := goimports +GO_MODULE := github.com/mosn.io/layotto + +GO_LDFLAGS += -X $(VERSION_PACKAGE).GitVersion=$(VERSION) \ + -X $(VERSION_PACKAGE).GitCommit=$(GIT_COMMIT) \ + -X $(VERSION_PACKAGE).GitTreeState=$(GIT_TREE_STATE) \ + -X $(VERSION_PACKAGE).BuildDate=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ') \ + +ifeq ($(ROOT_PACKAGE),) + $(error the variable ROOT_PACKAGE must be set prior to including golang.mk) +endif + +GOPATH := $(shell go env GOPATH) +ifeq ($(origin GOBIN), undefined) + GOBIN := $(GOPATH)/bin +endif + +COMMANDS ?= $(filter-out %.md, $(wildcard ${ROOT_DIR}/cmd/*)) +BINS ?= $(foreach cmd,${COMMANDS},$(notdir ${cmd})) + +ifeq (${COMMANDS},) + $(error Could not determine COMMANDS, set ROOT_DIR or run in source dir) +endif +ifeq (${BINS},) + $(error Could not determine BINS, set ROOT_DIR or run in source dir) +endif + +.PHONY: go.build.% +go.build.%: + $(eval COMMAND := $(word 2,$(subst ., ,$*))) + $(eval PLATFORM := $(word 1,$(subst ., ,$*))) + $(eval OS := $(word 1,$(subst _, ,$(PLATFORM)))) + $(eval ARCH := $(word 2,$(subst _, ,$(PLATFORM)))) + @echo "===========> Building binary $(COMMAND) $(VERSION) for $(OS) $(ARCH)" + @mkdir -p $(OUTPUT_DIR)/$(OS)/$(ARCH) + @CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) $(GO) build -o $(OUTPUT_DIR)/$(OS)/$(ARCH)/$(COMMAND) -ldflags "$(GO_LDFLAGS)" $(ROOT_PACKAGE)/cmd/$(COMMAND) + +.PHONY: go.build +go.build: $(addprefix go.build., $(addprefix $(PLATFORM)., $(BINS))) + +.PHONY: go.build.multiarch +go.build.multiarch: $(foreach p,$(PLATFORMS),$(addprefix go.build., $(addprefix $(p)., $(BINS)))) + +.PHONY: go.clean +go.clean: + @echo "===========> Cleaning all build output" + @rm -rf $(OUTPUT_DIR) + @rm -rf $(ROOT_DIR)/cover.out + +.PHONY: go.lint.verify +go.lint.verify: +ifeq (,$(shell which golangci-lint)) + @echo "===========> Installing golangci lint" + @curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(${GO} env GOPATH)/bin +endif + +.PHONY: go.lint +go.lint: go.lint.verify + @echo "===========> Run golangci to lint source codes" + @golangci-lint run + +.PHONY: go.test.verify +go.test.verify: +ifeq ($(shell which go-junit-report), ) + @echo "===========> Installing go-junit-report" + @GO111MODULE=off $(GO) get -u github.com/jstemmer/go-junit-report +endif + +.PHONY: go.test +go.test: go.test.verify + @echo "===========> Run unit test in cmd" + $(GO) test -count=1 -timeout=10m -short -v `go list ./cmd/...` + @echo "===========> Run unit test in diagnostics" + $(GO) test -count=1 -timeout=10m -short -v `go list ./diagnostics/...` + @echo "===========> Run unit test in pkg" + $(GO) test -count=1 -timeout=10m -short -v `go list ./pkg/...` + +.PHONY: go.style +go.style: + @echo "===========> Running go style check" + $(GO) fmt ./... && git status && [[ -z `git status -s` ]] + +.PHONY: go.format.verify +go.format.verify: +ifeq ($(shell which goimports), ) + @echo "===========> Installing missing goimports" + @GO111MODULE=off $(GO) get -u golang.org/x/tools/cmd/goimports +endif + +.PHONY: go.format +go.format: go.format.verify + @echo "===========> Running go codes format" + $(GO_FMT) -s -w . + $(GO_IMPORTS) -w -local $(GO_MODULE) . + $(GO) mod tidy diff --git a/make/image.mk b/make/image.mk new file mode 100644 index 0000000000..f1688fca4f --- /dev/null +++ b/make/image.mk @@ -0,0 +1,98 @@ +# Copyright 2021 Layotto Authors +# 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. + +DOCKER := docker +DOCKER_SUPPORTED_API_VERSION ?= 1.32 + +REGISTRY_PREFIX ?= layotto + +EXTRA_ARGS ?= +_DOCKER_BUILD_EXTRA_ARGS := + +ifdef HTTP_PROXY +_DOCKER_BUILD_EXTRA_ARGS += --build-arg HTTP_PROXY=${HTTP_PROXY} +endif + +ifneq ($(EXTRA_ARGS), ) +_DOCKER_BUILD_EXTRA_ARGS += $(EXTRA_ARGS) +endif + +# Determine image files by looking into build/docker/*/Dockerfile +IMAGES_DIR ?= $(wildcard ${ROOT_DIR}/docker/*) +# Determine images names by stripping out the dir names +IMAGES ?= layotto +IMAGE_PLATFORMS ?= linux_amd64 linux_arm64 + +ifeq (${IMAGES},) + $(error Could not determine IMAGES, set ROOT_DIR or run in source dir) +endif + +.PHONY: image.daemon.verify +image.daemon.verify: + $(eval PASS := $(shell $(DOCKER) version | grep -q -E 'Experimental: {1,5}true' && echo 1 || echo 0)) + @if [ $(PASS) -ne 1 ]; then \ + echo "Experimental features of Docker daemon is not enabled. Please add \"experimental\": true in '/etc/docker/daemon.json' and then restart Docker daemon."; \ + exit 1; \ + fi + +.PHONY: image.verify +image.verify: + $(eval API_VERSION := $(shell $(DOCKER) version | grep -E 'API version: {1,6}[0-9]' | head -n1 | awk '{print $$3} END { if (NR==0) print 0}' )) + $(eval PASS := $(shell echo "$(API_VERSION) > $(DOCKER_SUPPORTED_API_VERSION)" | bc)) + @if [ $(PASS) -ne 1 ]; then \ + $(DOCKER) -v ;\ + echo "Unsupported docker version. Docker API version should be greater than $(DOCKER_SUPPORTED_API_VERSION)"; \ + exit 1; \ + fi + +.PHONY: image.build +image.build: image.verify $(addprefix image.build., $(addprefix $(IMAGE_PLAT)., $(IMAGES))) + +.PHONY: image.build.multiarch +image.build.multiarch: image.verify $(foreach p,$(IMAGE_PLATFORMS),$(addprefix image.build., $(addprefix $(p)., $(IMAGES)))) + +.PHONY: image.build.% +image.build.%: go.build.% + $(eval IMAGE := $(COMMAND)) + $(eval IMAGE_PLAT := $(subst _,/,$(PLATFORM))) + @echo "===========> Building docker image $(IMAGE) $(VERSION) for $(IMAGE_PLAT)" + @mkdir -p $(TMP_DIR)/$(IMAGE) + @cat $(ROOT_DIR)/docker/$(IMAGE)/Dockerfile\ + >$(TMP_DIR)/$(IMAGE)/Dockerfile + @cp $(OUTPUT_DIR)/$(IMAGE_PLAT)/$(IMAGE) $(TMP_DIR)/$(IMAGE)/ + $(eval BUILD_SUFFIX := $(_DOCKER_BUILD_EXTRA_ARGS) --pull -t $(REGISTRY_PREFIX)/$(IMAGE):$(VERSION) $(TMP_DIR)/$(IMAGE)) + $(eval BUILD_SUFFIX_ARM := $(_DOCKER_BUILD_EXTRA_ARGS) --pull -t $(REGISTRY_PREFIX)/$(IMAGE).$(ARCH):$(VERSION) $(TMP_DIR)/$(IMAGE)) + @if [ "$(ARCH)" == "amd64" ]; then \ + echo "===========> Creating docker image tag $(REGISTRY_PREFIX)/$(IMAGE):$(VERSION) for $(ARCH)"; \ + $(DOCKER) build --platform $(IMAGE_PLAT) $(BUILD_SUFFIX); \ + else \ + echo "===========> Creating docker image tag $(REGISTRY_PREFIX)/$(IMAGE).$(ARCH):$(VERSION) for $(ARCH)"; \ + $(DOCKER) build --platform $(IMAGE_PLAT) $(BUILD_SUFFIX_ARM); \ + fi + + +.PHONY: image.push +image.push: image.verify $(addprefix image.push., $(addprefix $(IMAGE_PLAT)., $(IMAGES))) + +.PHONY: image.push.multiarch +image.push.multiarch: image.verify $(foreach p,$(IMAGE_PLATFORMS),$(addprefix image.push., $(addprefix $(p)., $(IMAGES)))) + +.PHONY: image.push.% +image.push.%: + $(eval COMMAND := $(word 2,$(subst ., ,$*))) + $(eval IMAGE := $(COMMAND)) + $(eval PLATFORM := $(word 1,$(subst ., ,$*))) + $(eval ARCH := $(word 2,$(subst _, ,$(PLATFORM)))) + $(eval IMAGE_PLAT := $(subst _,/,$(PLATFORM))) + @echo "===========> Pushing image $(IMAGE) $(VERSION) to $(REGISTRY_PREFIX)" + $(DOCKER) push $(REGISTRY_PREFIX)/$(IMAGE).$(ARCH):$(VERSION) diff --git a/make/wasm.mk b/make/wasm.mk new file mode 100644 index 0000000000..7ddebdd334 --- /dev/null +++ b/make/wasm.mk @@ -0,0 +1,62 @@ +# Copyright 2021 Layotto Authors +# 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. + +WASM_PLATFORM ?= linux_amd64 +WASM_PLATFORMS ?= linux_amd64 +WASM_BUILD ?= faas + +.PHONY: go.wasm +go.wasm: $(addprefix go.wasm., $(addprefix $(WASM_PLATFORM)., $(WASM_BUILD))) + +.PHONY: go.wasm.multiarch +go.wasm.multiarch: $(foreach p,$(WASM_PLATFORMS),$(addprefix go.wasm., $(addprefix $(p)., $(WASM_BUILD)))) + +.PHONY: go.wasm.% +go.wasm.%: + $(eval COMMAND := $(word 2,$(subst ., ,$*))) + $(eval PLATFORM := $(word 1,$(subst ., ,$*))) + $(eval OS := $(word 1,$(subst _, ,$(PLATFORM)))) + $(eval ARCH := $(word 2,$(subst _, ,$(PLATFORM)))) + $(eval BUILD_IMAGE := $(REGISTRY_PREFIX)/faas-$(ARCH):$(VERSION)) + @mkdir -p $(TMP_DIR)/$(COMMAND) + @mkdir -p $(OUTPUT_DIR)/$(OS)/$(ARCH) + @cat $(ROOT_DIR)/docker/app/$(COMMAND)/Dockerfile\ + >$(TMP_DIR)/$(COMMAND)/Dockerfile + $(eval DOCKER_FILE := $(TMP_DIR)/$(COMMAND)/Dockerfile) + @echo "===========> Building wasm base image in $(VERSION) for $(OS) $(ARCH)" + $(DOCKER) build -f ${DOCKER_FILE} -t ${BUILD_IMAGE} . + @echo "===========> Building binary wasm in $(VERSION) for $(OS) $(ARCH)" + $(eval OUTPUT_PATH := ./_output/$(OS)/$(ARCH)/layotto) + $(eval ACTION := $(GO) build -o $(OUTPUT_PATH) -tags wasmer -ldflags "$(GO_LDFLAGS)" $(ROOT_PACKAGE)/cmd/layotto) + $(DOCKER) run --rm -v $(ROOT_DIR):/go/src/${PROJECT_NAME} -e GOOS=$(OS) -e GOARCH=$(ARCH) -w /go/src/${PROJECT_NAME} ${BUILD_IMAGE} ${ACTION} + +.PHONY: go.wasm.image +go.wasm.image: go.wasm + $(eval IMAGE := layotto) + $(eval IMAGE_PLAT := $(subst _,/,$(WASM_PLATFORM))) + $(eval ARCH := $(word 2,$(subst _, ,$(WASM_PLATFORM)))) + @echo "===========> Building docker image $(IMAGE) $(VERSION) for $(IMAGE_PLAT)" + @mkdir -p $(TMP_DIR)/$(IMAGE) + @cat $(ROOT_DIR)/docker/$(IMAGE)/Dockerfile\ + >$(TMP_DIR)/$(IMAGE)/Dockerfile + @cp $(OUTPUT_DIR)/$(IMAGE_PLAT)/layotto $(TMP_DIR)/$(IMAGE)/ + $(eval BUILD_SUFFIX := $(_DOCKER_BUILD_EXTRA_ARGS) --pull -t $(REGISTRY_PREFIX)/$(IMAGE).wasm.$(ARCH):$(VERSION) $(TMP_DIR)/$(IMAGE)) + $(DOCKER) buildx build --platform $(IMAGE_PLAT) $(BUILD_SUFFIX) + +.PHONY: go.wasm.image.push +go.wasm.image.push: + $(eval IMAGE := layotto) + $(eval ARCH := $(word 2,$(subst _, ,$(WASM_PLATFORM)))) + $(eval IMAGE_PLAT := $(subst _,/,$(WASM_PLATFORM))) + @echo "===========> Pushing image $(IMAGE) $(VERSION) to $(REGISTRY_PREFIX)" + $(DOCKER) push $(REGISTRY_PREFIX)/$(IMAGE).wasm.$(ARCH):$(VERSION) diff --git a/pkg/actuator/actuator_test.go b/pkg/actuator/actuator_test.go index 94b0a5a309..898490e37d 100644 --- a/pkg/actuator/actuator_test.go +++ b/pkg/actuator/actuator_test.go @@ -18,8 +18,9 @@ package actuator import ( "context" - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) type MockEndpoint struct { diff --git a/pkg/actuator/health/endpoint.go b/pkg/actuator/health/endpoint.go index 8c20f5126c..d34f329442 100644 --- a/pkg/actuator/health/endpoint.go +++ b/pkg/actuator/health/endpoint.go @@ -19,6 +19,7 @@ package health import ( "context" "errors" + "mosn.io/layotto/pkg/actuator" ) diff --git a/pkg/actuator/health/endpoint_test.go b/pkg/actuator/health/endpoint_test.go index 3553489537..d376bda149 100644 --- a/pkg/actuator/health/endpoint_test.go +++ b/pkg/actuator/health/endpoint_test.go @@ -18,8 +18,9 @@ package health import ( "context" - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) type mockIndicator struct { diff --git a/pkg/actuator/info/endpoint.go b/pkg/actuator/info/endpoint.go index e8f86027f2..3db7434cfc 100644 --- a/pkg/actuator/info/endpoint.go +++ b/pkg/actuator/info/endpoint.go @@ -18,6 +18,7 @@ package info import ( "context" + "mosn.io/layotto/pkg/actuator" "mosn.io/pkg/log" ) diff --git a/pkg/actuator/info/endpoint_test.go b/pkg/actuator/info/endpoint_test.go index c49dbd5861..3f66b43997 100644 --- a/pkg/actuator/info/endpoint_test.go +++ b/pkg/actuator/info/endpoint_test.go @@ -18,8 +18,9 @@ package info import ( "context" - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) type MockContributor struct { diff --git a/pkg/common/performance.go b/pkg/common/performance.go index f9ecb3ca15..7affdd5edf 100644 --- a/pkg/common/performance.go +++ b/pkg/common/performance.go @@ -18,10 +18,11 @@ package common import ( "fmt" - "github.com/shirou/gopsutil/cpu" - "github.com/shirou/gopsutil/mem" "runtime/debug" "time" + + "github.com/shirou/gopsutil/cpu" + "github.com/shirou/gopsutil/mem" ) func GetSystemUsageRate() (cpuRate float64, memRate float64, err error) { diff --git a/pkg/common/strings_test.go b/pkg/common/strings_test.go index a8772775b8..9eea316305 100644 --- a/pkg/common/strings_test.go +++ b/pkg/common/strings_test.go @@ -17,8 +17,9 @@ package common import ( - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func TestPointerToString(t *testing.T) { diff --git a/pkg/filter/network/tcpcopy/persistence/persistence.go b/pkg/filter/network/tcpcopy/persistence/persistence.go index 7cd2b1826d..f1d3384fc1 100644 --- a/pkg/filter/network/tcpcopy/persistence/persistence.go +++ b/pkg/filter/network/tcpcopy/persistence/persistence.go @@ -17,13 +17,14 @@ package persistence import ( - "mosn.io/layotto/pkg/common" - "mosn.io/layotto/pkg/filter/network/tcpcopy/model" - "mosn.io/layotto/pkg/filter/network/tcpcopy/strategy" "os" "sync" "sync/atomic" + "mosn.io/layotto/pkg/common" + "mosn.io/layotto/pkg/filter/network/tcpcopy/model" + "mosn.io/layotto/pkg/filter/network/tcpcopy/strategy" + "mosn.io/mosn/pkg/configmanager" "mosn.io/mosn/pkg/log" rlog "mosn.io/pkg/log" @@ -49,8 +50,8 @@ var ( staticConfPersistence rlog.ErrorLogger portraitDataPersistence rlog.ErrorLogger //md5 for diff - md5ValueOfMemDump string - md5ValueOfStaticConf string + md5ValueOfMemDump string + // md5ValueOfStaticConf string memConfDumpFilePath string diff --git a/pkg/filter/network/tcpcopy/persistence/persistence_test.go b/pkg/filter/network/tcpcopy/persistence/persistence_test.go index 040fa6d0d3..b8b86b3618 100644 --- a/pkg/filter/network/tcpcopy/persistence/persistence_test.go +++ b/pkg/filter/network/tcpcopy/persistence/persistence_test.go @@ -17,12 +17,12 @@ package persistence import ( - "fmt" - "mosn.io/layotto/pkg/filter/network/tcpcopy/strategy" - "mosn.io/pkg/log" "os" "path" "testing" + + "mosn.io/layotto/pkg/filter/network/tcpcopy/strategy" + "mosn.io/pkg/log" ) func InitForTest() { @@ -31,7 +31,7 @@ func InitForTest() { func getPathForTest(fileName string) string { logFolder, _ := os.Getwd() - logFolder = fmt.Sprintf(path.Join(logFolder, "logs/mosn")) + logFolder = path.Join(logFolder, "logs/mosn") logPath := logFolder + string(os.PathSeparator) + fileName return logPath } diff --git a/pkg/filter/network/tcpcopy/persistence/work_pool.go b/pkg/filter/network/tcpcopy/persistence/work_pool.go index 05de3c82e7..5e755a0314 100644 --- a/pkg/filter/network/tcpcopy/persistence/work_pool.go +++ b/pkg/filter/network/tcpcopy/persistence/work_pool.go @@ -18,11 +18,12 @@ package persistence import ( "math/rand" + "sync" + "time" + "mosn.io/layotto/pkg/common" "mosn.io/layotto/pkg/filter/network/tcpcopy/model" "mosn.io/pkg/utils" - "sync" - "time" ) func init() { @@ -49,12 +50,8 @@ func (g *WorkGoroutine) AddTask(key string, data *model.DumpUploadDynamicConfig) func (g *WorkGoroutine) Start() { utils.GoWithRecover(func() { tick := time.NewTicker(500 * time.Millisecond) - for { - select { - case <-tick.C: - g.work() - } - } + <-tick.C + g.work() }, func(r interface{}) { g.Start() }) diff --git a/pkg/filter/network/tcpcopy/persistence/work_pool_test.go b/pkg/filter/network/tcpcopy/persistence/work_pool_test.go index 95257bd653..91de794d06 100644 --- a/pkg/filter/network/tcpcopy/persistence/work_pool_test.go +++ b/pkg/filter/network/tcpcopy/persistence/work_pool_test.go @@ -18,11 +18,12 @@ package persistence import ( "fmt" + "testing" + "time" + "mosn.io/layotto/pkg/filter/network/tcpcopy/model" _type "mosn.io/layotto/pkg/filter/network/tcpcopy/type" "mosn.io/mosn/pkg/log" - "testing" - "time" ) func TestNewDefaultWorkPool(t *testing.T) { @@ -34,39 +35,39 @@ func TestNewDefaultWorkPool(t *testing.T) { go func() { for i := 0; i < 5; i++ { - model_1 := model.NewDumpUploadDynamicConfig("uuid_1", _type.RPC, "12200", nil, "1s") - model_2 := model.NewDumpUploadDynamicConfig("uuid_2", _type.RPC, "12200", nil, "2s") - model_3 := model.NewDumpUploadDynamicConfig("uuid_3", _type.RPC, "12200", nil, "3s") + model1 := model.NewDumpUploadDynamicConfig("uuid_1", _type.RPC, "12200", nil, "1s") + model2 := model.NewDumpUploadDynamicConfig("uuid_2", _type.RPC, "12200", nil, "2s") + model3 := model.NewDumpUploadDynamicConfig("uuid_3", _type.RPC, "12200", nil, "3s") go func() { - workPool.Schedule(model_1) - workPool.Schedule(model_2) - workPool.Schedule(model_3) + workPool.Schedule(model1) + workPool.Schedule(model2) + workPool.Schedule(model3) }() } }() go func() { for i := 0; i < 5; i++ { - model_4 := model.NewDumpUploadDynamicConfig("uuid_4", _type.RPC, "12200", nil, "4s") - model_5 := model.NewDumpUploadDynamicConfig("uuid_5", _type.RPC, "12200", nil, "5s") - model_6 := model.NewDumpUploadDynamicConfig("uuid_6", _type.RPC, "12200", nil, "6s") + model4 := model.NewDumpUploadDynamicConfig("uuid_4", _type.RPC, "12200", nil, "4s") + model5 := model.NewDumpUploadDynamicConfig("uuid_5", _type.RPC, "12200", nil, "5s") + model6 := model.NewDumpUploadDynamicConfig("uuid_6", _type.RPC, "12200", nil, "6s") go func() { - workPool.Schedule(model_4) - workPool.Schedule(model_5) - workPool.Schedule(model_6) + workPool.Schedule(model4) + workPool.Schedule(model5) + workPool.Schedule(model6) }() } }() go func() { for i := 0; i < 5; i++ { - model_7 := model.NewDumpUploadDynamicConfig("uuid_7", _type.CONFIGURATION, "12200", nil, "7s") - model_8 := model.NewDumpUploadDynamicConfig("uuid_8", _type.CONFIGURATION, "12200", nil, "8s") - model_9 := model.NewDumpUploadDynamicConfig("uuid_9", _type.CONFIGURATION, "12200", nil, "9s") + model7 := model.NewDumpUploadDynamicConfig("uuid_7", _type.CONFIGURATION, "12200", nil, "7s") + model8 := model.NewDumpUploadDynamicConfig("uuid_8", _type.CONFIGURATION, "12200", nil, "8s") + model9 := model.NewDumpUploadDynamicConfig("uuid_9", _type.CONFIGURATION, "12200", nil, "9s") go func() { - workPool.Schedule(model_7) - workPool.Schedule(model_8) - workPool.Schedule(model_9) + workPool.Schedule(model7) + workPool.Schedule(model8) + workPool.Schedule(model9) }() } }() diff --git a/pkg/filter/network/tcpcopy/portrait_data.go b/pkg/filter/network/tcpcopy/portrait_data.go index 63d567d3fe..bcb5902f8f 100644 --- a/pkg/filter/network/tcpcopy/portrait_data.go +++ b/pkg/filter/network/tcpcopy/portrait_data.go @@ -19,6 +19,10 @@ package tcpcopy import ( "context" "encoding/json" + "strconv" + "sync" + "sync/atomic" + "mosn.io/api" "mosn.io/layotto/pkg/filter/network/tcpcopy/model" "mosn.io/layotto/pkg/filter/network/tcpcopy/persistence" @@ -26,9 +30,6 @@ import ( _type "mosn.io/layotto/pkg/filter/network/tcpcopy/type" "mosn.io/mosn/pkg/log" "mosn.io/mosn/pkg/types" - "strconv" - "sync" - "sync/atomic" ) var lock sync.Mutex diff --git a/pkg/filter/network/tcpcopy/portrait_data_test.go b/pkg/filter/network/tcpcopy/portrait_data_test.go index f95c1b8a78..147b4d90a5 100644 --- a/pkg/filter/network/tcpcopy/portrait_data_test.go +++ b/pkg/filter/network/tcpcopy/portrait_data_test.go @@ -17,10 +17,11 @@ package tcpcopy import ( + "testing" + "mosn.io/layotto/pkg/filter/network/tcpcopy/strategy" _type "mosn.io/layotto/pkg/filter/network/tcpcopy/type" "mosn.io/pkg/log" - "testing" ) func Test_isHandle_switch_off(t *testing.T) { diff --git a/pkg/filter/network/tcpcopy/strategy/switch.go b/pkg/filter/network/tcpcopy/strategy/switch.go index abc304ceac..c3a37d6eb2 100644 --- a/pkg/filter/network/tcpcopy/strategy/switch.go +++ b/pkg/filter/network/tcpcopy/strategy/switch.go @@ -18,12 +18,13 @@ package strategy import ( "encoding/json" - "mosn.io/layotto/pkg/filter/network/tcpcopy/model" - "mosn.io/mosn/pkg/log" - "mosn.io/pkg/utils" "sync" "sync/atomic" "time" + + "mosn.io/layotto/pkg/filter/network/tcpcopy/model" + "mosn.io/mosn/pkg/log" + "mosn.io/pkg/utils" ) const ( diff --git a/pkg/filter/network/tcpcopy/strategy/switch_test.go b/pkg/filter/network/tcpcopy/strategy/switch_test.go index 71e6a52625..0aebc9f765 100644 --- a/pkg/filter/network/tcpcopy/strategy/switch_test.go +++ b/pkg/filter/network/tcpcopy/strategy/switch_test.go @@ -17,8 +17,9 @@ package strategy import ( - "mosn.io/pkg/log" "testing" + + "mosn.io/pkg/log" ) func TestUpdateAppDumpConfig_invalid_value(t *testing.T) { diff --git a/pkg/filter/network/tcpcopy/tcpcopy.go b/pkg/filter/network/tcpcopy/tcpcopy.go index f33730b42a..4ceeeb85e9 100644 --- a/pkg/filter/network/tcpcopy/tcpcopy.go +++ b/pkg/filter/network/tcpcopy/tcpcopy.go @@ -20,6 +20,9 @@ import ( "context" "encoding/json" "errors" + "net" + "strconv" + "mosn.io/api" "mosn.io/layotto/pkg/filter/network/tcpcopy/model" "mosn.io/layotto/pkg/filter/network/tcpcopy/persistence" @@ -27,8 +30,6 @@ import ( v2 "mosn.io/mosn/pkg/config/v2" "mosn.io/mosn/pkg/types" "mosn.io/pkg/log" - "net" - "strconv" ) func init() { diff --git a/pkg/filter/network/tcpcopy/tcpcopy_test.go b/pkg/filter/network/tcpcopy/tcpcopy_test.go index a7385da2f3..6b3b78c632 100644 --- a/pkg/filter/network/tcpcopy/tcpcopy_test.go +++ b/pkg/filter/network/tcpcopy/tcpcopy_test.go @@ -18,11 +18,12 @@ package tcpcopy import ( "encoding/json" + "testing" + "mosn.io/api" "mosn.io/layotto/pkg/filter/network/tcpcopy/strategy" "mosn.io/mosn/pkg/types" "mosn.io/pkg/buffer" - "testing" ) func TestCreateTcpcopyFactory(t *testing.T) { diff --git a/pkg/filter/stream/actuator/http/dispatch_filter.go b/pkg/filter/stream/actuator/http/dispatch_filter.go index e198bd5390..70c0853ef4 100644 --- a/pkg/filter/stream/actuator/http/dispatch_filter.go +++ b/pkg/filter/stream/actuator/http/dispatch_filter.go @@ -19,6 +19,7 @@ package http import ( "context" "encoding/json" + "github.com/valyala/fasthttp" "mosn.io/api" "mosn.io/layotto/pkg/actuator" diff --git a/pkg/filter/stream/actuator/http/factory.go b/pkg/filter/stream/actuator/http/factory.go index 8d42863c33..8645b75f87 100644 --- a/pkg/filter/stream/actuator/http/factory.go +++ b/pkg/filter/stream/actuator/http/factory.go @@ -18,6 +18,7 @@ package http import ( "context" + "mosn.io/api" "mosn.io/mosn/pkg/log" ) diff --git a/pkg/filter/stream/actuator/http/path_resolver_test.go b/pkg/filter/stream/actuator/http/path_resolver_test.go index a83a40b073..bdb9b9aaa8 100644 --- a/pkg/filter/stream/actuator/http/path_resolver_test.go +++ b/pkg/filter/stream/actuator/http/path_resolver_test.go @@ -17,8 +17,9 @@ package http import ( - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func Test_pathResolver_isEmpty(t *testing.T) { diff --git a/pkg/grpc/dapr/dapr_api.go b/pkg/grpc/dapr/dapr_api.go index 4c50196457..f2a0f5899b 100644 --- a/pkg/grpc/dapr/dapr_api.go +++ b/pkg/grpc/dapr/dapr_api.go @@ -19,6 +19,8 @@ package dapr import ( "context" "errors" + "strings" + "github.com/dapr/components-contrib/bindings" "github.com/dapr/components-contrib/pubsub" "github.com/dapr/components-contrib/secretstores" @@ -43,7 +45,6 @@ import ( dapr_v1pb "mosn.io/layotto/pkg/grpc/dapr/proto/runtime/v1" "mosn.io/layotto/pkg/messages" "mosn.io/pkg/log" - "strings" ) type DaprGrpcAPI interface { diff --git a/pkg/grpc/dapr/dapr_api_secret.go b/pkg/grpc/dapr/dapr_api_secret.go index 5190c2db9d..a46292c510 100644 --- a/pkg/grpc/dapr/dapr_api_secret.go +++ b/pkg/grpc/dapr/dapr_api_secret.go @@ -18,6 +18,7 @@ package dapr import ( "context" + "github.com/dapr/components-contrib/secretstores" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" diff --git a/pkg/grpc/dapr/dapr_api_secret_test.go b/pkg/grpc/dapr/dapr_api_secret_test.go index 4d910da02c..66be40f40d 100644 --- a/pkg/grpc/dapr/dapr_api_secret_test.go +++ b/pkg/grpc/dapr/dapr_api_secret_test.go @@ -17,6 +17,8 @@ package dapr import ( "context" + "testing" + "github.com/dapr/components-contrib/secretstores" "github.com/phayes/freeport" "github.com/stretchr/testify/assert" @@ -25,7 +27,6 @@ import ( grpc_api "mosn.io/layotto/pkg/grpc" dapr_v1pb "mosn.io/layotto/pkg/grpc/dapr/proto/runtime/v1" "mosn.io/layotto/pkg/mock/components/secret" - "testing" ) func TestNewDaprAPI_GetSecretStores(t *testing.T) { diff --git a/pkg/grpc/dapr/dapr_api_state_test.go b/pkg/grpc/dapr/dapr_api_state_test.go index 96c106bcbc..fce3b076fe 100644 --- a/pkg/grpc/dapr/dapr_api_state_test.go +++ b/pkg/grpc/dapr/dapr_api_state_test.go @@ -16,11 +16,12 @@ package dapr import ( + "testing" + "github.com/dapr/components-contrib/state" "github.com/stretchr/testify/assert" dapr_common_v1pb "mosn.io/layotto/pkg/grpc/dapr/proto/common/v1" dapr_v1pb "mosn.io/layotto/pkg/grpc/dapr/proto/runtime/v1" - "testing" ) func TestGetResponse2GetStateResponse(t *testing.T) { diff --git a/pkg/grpc/dapr/dapr_api_test.go b/pkg/grpc/dapr/dapr_api_test.go index 650f5678f1..09f0ced64d 100644 --- a/pkg/grpc/dapr/dapr_api_test.go +++ b/pkg/grpc/dapr/dapr_api_test.go @@ -19,6 +19,9 @@ package dapr import ( "context" "fmt" + "net" + "testing" + "github.com/dapr/components-contrib/bindings" "github.com/dapr/components-contrib/state" "github.com/golang/mock/gomock" @@ -26,14 +29,13 @@ import ( "github.com/stretchr/testify/assert" grpc_api "mosn.io/layotto/pkg/grpc" mock_state "mosn.io/layotto/pkg/mock/components/state" - "net" - "testing" "errors" + "time" + "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "time" dapr_v1pb "mosn.io/layotto/pkg/grpc/dapr/proto/runtime/v1" ) diff --git a/pkg/grpc/dapr/proto/common/v1/common.pb.go b/pkg/grpc/dapr/proto/common/v1/common.pb.go index a035edfead..aeb41142cf 100644 --- a/pkg/grpc/dapr/proto/common/v1/common.pb.go +++ b/pkg/grpc/dapr/proto/common/v1/common.pb.go @@ -12,12 +12,13 @@ package common import ( + reflect "reflect" + sync "sync" + proto "github.com/golang/protobuf/proto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" anypb "google.golang.org/protobuf/types/known/anypb" - reflect "reflect" - sync "sync" ) const ( diff --git a/pkg/grpc/dapr/proto/runtime/v1/appcallback.pb.go b/pkg/grpc/dapr/proto/runtime/v1/appcallback.pb.go index 6f07aaa29b..b08b0b4599 100644 --- a/pkg/grpc/dapr/proto/runtime/v1/appcallback.pb.go +++ b/pkg/grpc/dapr/proto/runtime/v1/appcallback.pb.go @@ -12,13 +12,14 @@ package runtime import ( + reflect "reflect" + sync "sync" + proto "github.com/golang/protobuf/proto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" emptypb "google.golang.org/protobuf/types/known/emptypb" v1 "mosn.io/layotto/pkg/grpc/dapr/proto/common/v1" - reflect "reflect" - sync "sync" ) const ( diff --git a/pkg/grpc/dapr/proto/runtime/v1/appcallback_grpc.pb.go b/pkg/grpc/dapr/proto/runtime/v1/appcallback_grpc.pb.go index d96a14d926..29dd3f6ab9 100644 --- a/pkg/grpc/dapr/proto/runtime/v1/appcallback_grpc.pb.go +++ b/pkg/grpc/dapr/proto/runtime/v1/appcallback_grpc.pb.go @@ -4,6 +4,7 @@ package runtime import ( context "context" + grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" diff --git a/pkg/grpc/dapr/proto/runtime/v1/dapr.pb.go b/pkg/grpc/dapr/proto/runtime/v1/dapr.pb.go index cc2fd85e88..6e88b468cd 100644 --- a/pkg/grpc/dapr/proto/runtime/v1/dapr.pb.go +++ b/pkg/grpc/dapr/proto/runtime/v1/dapr.pb.go @@ -12,14 +12,15 @@ package runtime import ( + reflect "reflect" + sync "sync" + proto "github.com/golang/protobuf/proto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" anypb "google.golang.org/protobuf/types/known/anypb" emptypb "google.golang.org/protobuf/types/known/emptypb" v1 "mosn.io/layotto/pkg/grpc/dapr/proto/common/v1" - reflect "reflect" - sync "sync" ) const ( diff --git a/pkg/grpc/dapr/proto/runtime/v1/dapr_grpc.pb.go b/pkg/grpc/dapr/proto/runtime/v1/dapr_grpc.pb.go index 7cc6e5370c..ee766c3fb0 100644 --- a/pkg/grpc/dapr/proto/runtime/v1/dapr_grpc.pb.go +++ b/pkg/grpc/dapr/proto/runtime/v1/dapr_grpc.pb.go @@ -4,6 +4,7 @@ package runtime import ( context "context" + grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" diff --git a/pkg/grpc/default_api/api.go b/pkg/grpc/default_api/api.go index 0aa0d50468..fdb7b6b5c7 100644 --- a/pkg/grpc/default_api/api.go +++ b/pkg/grpc/default_api/api.go @@ -19,9 +19,10 @@ package default_api import ( "context" "errors" - "github.com/dapr/components-contrib/secretstores" "sync" + "github.com/dapr/components-contrib/secretstores" + "github.com/dapr/components-contrib/bindings" "github.com/dapr/components-contrib/pubsub" "github.com/dapr/components-contrib/state" diff --git a/pkg/grpc/default_api/api_binding.go b/pkg/grpc/default_api/api_binding.go index c35eae8030..e527bb236d 100644 --- a/pkg/grpc/default_api/api_binding.go +++ b/pkg/grpc/default_api/api_binding.go @@ -18,6 +18,7 @@ package default_api import ( "context" + dapr_v1pb "mosn.io/layotto/pkg/grpc/dapr/proto/runtime/v1" runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" ) diff --git a/pkg/grpc/default_api/api_binding_test.go b/pkg/grpc/default_api/api_binding_test.go index a87da6a371..0976a9154f 100644 --- a/pkg/grpc/default_api/api_binding_test.go +++ b/pkg/grpc/default_api/api_binding_test.go @@ -19,13 +19,14 @@ package default_api import ( "context" "errors" + "testing" + "github.com/dapr/components-contrib/bindings" "github.com/phayes/freeport" "github.com/stretchr/testify/assert" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" - "testing" ) func TestInvokeBinding(t *testing.T) { diff --git a/pkg/grpc/default_api/api_configuration.go b/pkg/grpc/default_api/api_configuration.go index 033b5cf647..cde688d2e2 100644 --- a/pkg/grpc/default_api/api_configuration.go +++ b/pkg/grpc/default_api/api_configuration.go @@ -20,13 +20,14 @@ import ( "context" "errors" "fmt" + "strings" + "sync" + "google.golang.org/protobuf/types/known/emptypb" "mosn.io/layotto/components/configstores" runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" "mosn.io/pkg/log" "mosn.io/pkg/utils" - "strings" - "sync" ) // GetConfiguration gets configuration from configuration store. diff --git a/pkg/grpc/default_api/api_configuration_test.go b/pkg/grpc/default_api/api_configuration_test.go index 4beca903af..90db320b8b 100644 --- a/pkg/grpc/default_api/api_configuration_test.go +++ b/pkg/grpc/default_api/api_configuration_test.go @@ -18,12 +18,14 @@ package default_api import ( "context" + "testing" + "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" "google.golang.org/grpc" - "testing" "errors" + "mosn.io/layotto/components/configstores" "mosn.io/layotto/pkg/mock" runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" diff --git a/pkg/grpc/default_api/api_file.go b/pkg/grpc/default_api/api_file.go index ef84c019bd..b79f1a7b2c 100644 --- a/pkg/grpc/default_api/api_file.go +++ b/pkg/grpc/default_api/api_file.go @@ -18,11 +18,12 @@ package default_api import ( "context" + "io" + "github.com/golang/protobuf/ptypes/empty" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "google.golang.org/protobuf/types/known/emptypb" - "io" "mosn.io/layotto/components/file" runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" diff --git a/pkg/grpc/default_api/api_file_test.go b/pkg/grpc/default_api/api_file_test.go index 39b0c64afd..01ab65e71c 100644 --- a/pkg/grpc/default_api/api_file_test.go +++ b/pkg/grpc/default_api/api_file_test.go @@ -19,17 +19,18 @@ package default_api import ( "context" "errors" + "io" + "net" + "testing" + "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "io" "mosn.io/layotto/components/file" "mosn.io/layotto/pkg/mock" "mosn.io/layotto/pkg/mock/runtime" runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" - "net" - "testing" ) func SendData(w net.Conn) { diff --git a/pkg/grpc/default_api/api_lock.go b/pkg/grpc/default_api/api_lock.go index bb7fed5132..f93bb0552f 100644 --- a/pkg/grpc/default_api/api_lock.go +++ b/pkg/grpc/default_api/api_lock.go @@ -18,6 +18,7 @@ package default_api import ( "context" + "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "mosn.io/layotto/components/lock" diff --git a/pkg/grpc/default_api/api_lock_test.go b/pkg/grpc/default_api/api_lock_test.go index 0cb28f06a5..2ab45cee4e 100644 --- a/pkg/grpc/default_api/api_lock_test.go +++ b/pkg/grpc/default_api/api_lock_test.go @@ -18,9 +18,10 @@ package default_api import ( "context" + "testing" + "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" - "testing" "mosn.io/layotto/components/lock" mock_lock "mosn.io/layotto/pkg/mock/components/lock" diff --git a/pkg/grpc/default_api/api_pubsub.go b/pkg/grpc/default_api/api_pubsub.go index dc8b7cc7b0..bc709140d0 100644 --- a/pkg/grpc/default_api/api_pubsub.go +++ b/pkg/grpc/default_api/api_pubsub.go @@ -20,6 +20,7 @@ import ( "context" "errors" "fmt" + contrib_contenttype "github.com/dapr/components-contrib/contenttype" "github.com/dapr/components-contrib/pubsub" contrib_pubsub "github.com/dapr/components-contrib/pubsub" @@ -31,6 +32,7 @@ import ( l8_comp_pubsub "mosn.io/layotto/components/pubsub" "encoding/base64" + "github.com/dapr/components-contrib/contenttype" "mosn.io/layotto/pkg/messages" runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" diff --git a/pkg/grpc/default_api/api_pubsub_test.go b/pkg/grpc/default_api/api_pubsub_test.go index 355af87719..c768989018 100644 --- a/pkg/grpc/default_api/api_pubsub_test.go +++ b/pkg/grpc/default_api/api_pubsub_test.go @@ -20,6 +20,10 @@ import ( "context" "encoding/json" "fmt" + "net" + "testing" + "time" + "github.com/dapr/components-contrib/pubsub" "github.com/golang/mock/gomock" jsoniter "github.com/json-iterator/go" @@ -32,9 +36,6 @@ import ( mock_appcallback "mosn.io/layotto/pkg/mock/runtime/appcallback" runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" "mosn.io/pkg/log" - "net" - "testing" - "time" ) func TestPublishEvent(t *testing.T) { diff --git a/pkg/grpc/default_api/api_secret.go b/pkg/grpc/default_api/api_secret.go index 52dd84b23a..b179327701 100644 --- a/pkg/grpc/default_api/api_secret.go +++ b/pkg/grpc/default_api/api_secret.go @@ -18,6 +18,7 @@ package default_api import ( "context" + dapr_v1pb "mosn.io/layotto/pkg/grpc/dapr/proto/runtime/v1" runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" ) diff --git a/pkg/grpc/default_api/api_secret_test.go b/pkg/grpc/default_api/api_secret_test.go index 5cdccba7cc..da8f3427cf 100644 --- a/pkg/grpc/default_api/api_secret_test.go +++ b/pkg/grpc/default_api/api_secret_test.go @@ -18,6 +18,8 @@ package default_api import ( "context" + "testing" + "github.com/dapr/components-contrib/secretstores" "github.com/phayes/freeport" "github.com/stretchr/testify/assert" @@ -25,7 +27,6 @@ import ( "google.golang.org/grpc/status" moke_secret "mosn.io/layotto/pkg/mock/components/secret" runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" - "testing" ) func TestGetSecret(t *testing.T) { diff --git a/pkg/grpc/default_api/api_sequencer.go b/pkg/grpc/default_api/api_sequencer.go index 50aeccae09..b899381d0b 100644 --- a/pkg/grpc/default_api/api_sequencer.go +++ b/pkg/grpc/default_api/api_sequencer.go @@ -19,6 +19,7 @@ package default_api import ( "context" "errors" + "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "mosn.io/layotto/components/sequencer" diff --git a/pkg/grpc/default_api/api_sequencer_test.go b/pkg/grpc/default_api/api_sequencer_test.go index f1b99df7a6..d485ffd094 100644 --- a/pkg/grpc/default_api/api_sequencer_test.go +++ b/pkg/grpc/default_api/api_sequencer_test.go @@ -19,12 +19,13 @@ package default_api import ( "context" "fmt" + "testing" + "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" "mosn.io/layotto/components/sequencer" mock_sequencer "mosn.io/layotto/pkg/mock/components/sequencer" runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" - "testing" ) func TestGetNextId(t *testing.T) { diff --git a/pkg/grpc/default_api/api_state.go b/pkg/grpc/default_api/api_state.go index 1673be98f3..663878d902 100644 --- a/pkg/grpc/default_api/api_state.go +++ b/pkg/grpc/default_api/api_state.go @@ -18,6 +18,7 @@ package default_api import ( "context" + "github.com/golang/protobuf/ptypes/empty" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" diff --git a/pkg/grpc/default_api/api_state_test.go b/pkg/grpc/default_api/api_state_test.go index 2a4dbff1e4..8ee7569f75 100644 --- a/pkg/grpc/default_api/api_state_test.go +++ b/pkg/grpc/default_api/api_state_test.go @@ -19,12 +19,13 @@ package default_api import ( "context" "fmt" + "testing" + "github.com/dapr/components-contrib/state" "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" mock_state "mosn.io/layotto/pkg/mock/components/state" runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" - "testing" ) func TestSaveState(t *testing.T) { diff --git a/pkg/grpc/default_api/api_test.go b/pkg/grpc/default_api/api_test.go index 86e71bbc65..4f74002e9b 100644 --- a/pkg/grpc/default_api/api_test.go +++ b/pkg/grpc/default_api/api_test.go @@ -19,11 +19,12 @@ package default_api import ( "context" "fmt" + "net" + "testing" + "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" l8grpc "mosn.io/layotto/pkg/grpc" - "net" - "testing" "mosn.io/layotto/components/hello" "mosn.io/layotto/components/rpc" diff --git a/pkg/integrate/actuator/app_contributor.go b/pkg/integrate/actuator/app_contributor.go index 2ae3c273af..8b9932c583 100644 --- a/pkg/integrate/actuator/app_contributor.go +++ b/pkg/integrate/actuator/app_contributor.go @@ -17,9 +17,10 @@ package actuator import ( - "mosn.io/layotto/pkg/actuator/info" "sync/atomic" "time" + + "mosn.io/layotto/pkg/actuator/info" ) type AppContributor info.Contributor diff --git a/pkg/integrate/actuator/app_contributor_test.go b/pkg/integrate/actuator/app_contributor_test.go index d801c053a8..86e49df809 100644 --- a/pkg/integrate/actuator/app_contributor_test.go +++ b/pkg/integrate/actuator/app_contributor_test.go @@ -17,8 +17,9 @@ package actuator import ( - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func TestSetAppInfoSingleton(t *testing.T) { diff --git a/pkg/integrate/actuator/grpc.go b/pkg/integrate/actuator/grpc.go index a20626b6a2..a49e367516 100644 --- a/pkg/integrate/actuator/grpc.go +++ b/pkg/integrate/actuator/grpc.go @@ -17,8 +17,9 @@ package actuator import ( - mgrpc "mosn.io/mosn/pkg/filter/network/grpc" "net" + + mgrpc "mosn.io/mosn/pkg/filter/network/grpc" ) type GrpcServerWithActuator struct { diff --git a/pkg/integrate/actuator/runtime_indicator.go b/pkg/integrate/actuator/runtime_indicator.go index 37e181fb84..8b5004e60d 100644 --- a/pkg/integrate/actuator/runtime_indicator.go +++ b/pkg/integrate/actuator/runtime_indicator.go @@ -17,8 +17,9 @@ package actuator import ( - "mosn.io/layotto/pkg/actuator/health" "sync" + + "mosn.io/layotto/pkg/actuator/health" ) const ( diff --git a/pkg/mock/components/secret/secret.go b/pkg/mock/components/secret/secret.go index 5f1d0299ba..8a332d8ca0 100644 --- a/pkg/mock/components/secret/secret.go +++ b/pkg/mock/components/secret/secret.go @@ -2,6 +2,7 @@ package secret import ( "errors" + "github.com/dapr/components-contrib/secretstores" ) diff --git a/pkg/mock/components/state/in_memory.go b/pkg/mock/components/state/in_memory.go index d07113496f..b983bf0791 100644 --- a/pkg/mock/components/state/in_memory.go +++ b/pkg/mock/components/state/in_memory.go @@ -13,14 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package mock_state import ( "fmt" + "sync" + "github.com/dapr/components-contrib/state" "github.com/dapr/kit/logger" jsoniter "github.com/json-iterator/go" - "sync" ) type inMemStateStoreItem struct { @@ -70,7 +72,7 @@ func (store *inMemoryStore) Delete(req *state.DeleteRequest) error { } func (store *inMemoryStore) BulkDelete(req []state.DeleteRequest) error { - if req == nil || len(req) == 0 { + if len(req) == 0 { return nil } for _, dr := range req { @@ -91,8 +93,11 @@ func (store *inMemoryStore) Get(req *state.GetRequest) (*state.GetResponse, erro if item == nil { return &state.GetResponse{Data: nil, ETag: nil}, nil } - - return &state.GetResponse{Data: unmarshal(item.data), ETag: item.etag}, nil + if data, err := unmarshal(item.data); err != nil { + return nil, err + } else { + return &state.GetResponse{Data: data, ETag: item.etag}, nil + } } func (store *inMemoryStore) BulkGet(req []state.GetRequest) (bool, []state.BulkGetResponse, error) { @@ -179,15 +184,18 @@ func (store *inMemoryStore) Multi(request *state.TransactionalStateRequest) erro } func marshal(value interface{}) ([]byte, error) { - v, _ := jsoniter.MarshalToString(value) - - return []byte(v), nil + if v, err := jsoniter.MarshalToString(value); err != nil { + return nil, err + } else { + return []byte(v), nil + } } -func unmarshal(val interface{}) []byte { +func unmarshal(val interface{}) ([]byte, error) { var output string - jsoniter.UnmarshalFromString(string(val.([]byte)), &output) - - return []byte(output) + if err := jsoniter.UnmarshalFromString(string(val.([]byte)), &output); err != nil { + return nil, err + } + return []byte(output), nil } diff --git a/pkg/mock/components/state/in_memory_test.go b/pkg/mock/components/state/in_memory_test.go index 89f0c16d1c..9025a2782f 100644 --- a/pkg/mock/components/state/in_memory_test.go +++ b/pkg/mock/components/state/in_memory_test.go @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package mock_state import ( @@ -32,7 +33,9 @@ func TestReadAndWrite(t *testing.T) { defer ctl.Finish() store := New(logger.NewLogger("test")) - store.Init(state.Metadata{}) + if err := store.Init(state.Metadata{}); err != nil { + panic(err) + } t.Run("test set 1", func(t *testing.T) { setReq := &state.SetRequest{ diff --git a/pkg/mock/configstore.go b/pkg/mock/configstore.go index bb151dc88f..4ca45d6bb1 100644 --- a/pkg/mock/configstore.go +++ b/pkg/mock/configstore.go @@ -6,9 +6,10 @@ package mock import ( context "context" - "mosn.io/layotto/components/configstores" reflect "reflect" + "mosn.io/layotto/components/configstores" + gomock "github.com/golang/mock/gomock" ) diff --git a/pkg/runtime/config.go b/pkg/runtime/config.go index 6625d0d80b..f7e596634f 100644 --- a/pkg/runtime/config.go +++ b/pkg/runtime/config.go @@ -18,6 +18,7 @@ package runtime import ( "encoding/json" + "mosn.io/layotto/components/custom" "mosn.io/layotto/pkg/runtime/bindings" diff --git a/pkg/runtime/lock/factory_test.go b/pkg/runtime/lock/factory_test.go index eabf05518f..52a551032a 100644 --- a/pkg/runtime/lock/factory_test.go +++ b/pkg/runtime/lock/factory_test.go @@ -14,8 +14,9 @@ package lock import ( - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func TestNewFactory(t *testing.T) { diff --git a/pkg/runtime/lock/registry.go b/pkg/runtime/lock/registry.go index cba11d637e..8c9a942230 100644 --- a/pkg/runtime/lock/registry.go +++ b/pkg/runtime/lock/registry.go @@ -15,6 +15,7 @@ package lock import ( "fmt" + "mosn.io/layotto/components/lock" "mosn.io/layotto/components/pkg/info" ) diff --git a/pkg/runtime/lock/registry_test.go b/pkg/runtime/lock/registry_test.go index f74736a988..53fb92bbc9 100644 --- a/pkg/runtime/lock/registry_test.go +++ b/pkg/runtime/lock/registry_test.go @@ -14,10 +14,11 @@ package lock import ( - "mosn.io/layotto/components/lock" - "mosn.io/layotto/components/pkg/info" "strings" "testing" + + "mosn.io/layotto/components/lock" + "mosn.io/layotto/components/pkg/info" ) func TestNewRegistry(t *testing.T) { diff --git a/pkg/runtime/options_test.go b/pkg/runtime/options_test.go index c9157c57b7..62af28c0f8 100644 --- a/pkg/runtime/options_test.go +++ b/pkg/runtime/options_test.go @@ -17,8 +17,9 @@ package runtime import ( - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func TestWithErrInterceptor(t *testing.T) { diff --git a/pkg/runtime/pubsub/factory_test.go b/pkg/runtime/pubsub/factory_test.go index ac9d80f39a..0b3a05cade 100644 --- a/pkg/runtime/pubsub/factory_test.go +++ b/pkg/runtime/pubsub/factory_test.go @@ -14,8 +14,9 @@ package pubsub import ( - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func TestNewFactory(t *testing.T) { diff --git a/pkg/runtime/pubsub/registry.go b/pkg/runtime/pubsub/registry.go index 6fb873edd6..7a808bb5ce 100644 --- a/pkg/runtime/pubsub/registry.go +++ b/pkg/runtime/pubsub/registry.go @@ -18,6 +18,7 @@ package pubsub import ( "fmt" + dpubsub "github.com/dapr/components-contrib/pubsub" "mosn.io/layotto/components/pkg/info" ) diff --git a/pkg/runtime/pubsub/registry_test.go b/pkg/runtime/pubsub/registry_test.go index 9e01e84061..dd4400a75a 100644 --- a/pkg/runtime/pubsub/registry_test.go +++ b/pkg/runtime/pubsub/registry_test.go @@ -17,10 +17,11 @@ package pubsub import ( - "github.com/dapr/components-contrib/pubsub" - "mosn.io/layotto/components/pkg/info" "strings" "testing" + + "github.com/dapr/components-contrib/pubsub" + "mosn.io/layotto/components/pkg/info" ) func TestNewRegistry(t *testing.T) { diff --git a/pkg/runtime/runtime.go b/pkg/runtime/runtime.go index ae86b22e81..d295fc1aa7 100644 --- a/pkg/runtime/runtime.go +++ b/pkg/runtime/runtime.go @@ -20,11 +20,12 @@ import ( "context" "errors" "fmt" + "strings" + "time" + "github.com/dapr/components-contrib/secretstores" "mosn.io/layotto/components/custom" msecretstores "mosn.io/layotto/pkg/runtime/secretstores" - "strings" - "time" "github.com/dapr/components-contrib/bindings" mbindings "mosn.io/layotto/pkg/runtime/bindings" diff --git a/pkg/runtime/runtime_test.go b/pkg/runtime/runtime_test.go index 8e10df7568..f4fadb5a44 100644 --- a/pkg/runtime/runtime_test.go +++ b/pkg/runtime/runtime_test.go @@ -21,6 +21,9 @@ import ( "encoding/json" "errors" "fmt" + "net" + "testing" + "github.com/dapr/components-contrib/bindings" "google.golang.org/grpc/test/bufconn" "mosn.io/layotto/components/custom" @@ -34,8 +37,6 @@ import ( mbindings "mosn.io/layotto/pkg/runtime/bindings" runtime_sequencer "mosn.io/layotto/pkg/runtime/sequencer" runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" - "net" - "testing" "github.com/dapr/components-contrib/pubsub" "github.com/dapr/components-contrib/state" diff --git a/pkg/runtime/secretstores/registry_test.go b/pkg/runtime/secretstores/registry_test.go index f90402a77b..21a6666da1 100644 --- a/pkg/runtime/secretstores/registry_test.go +++ b/pkg/runtime/secretstores/registry_test.go @@ -16,10 +16,11 @@ package secretstores import ( - "mosn.io/layotto/components/pkg/info" "strings" "testing" + "mosn.io/layotto/components/pkg/info" + ss "github.com/dapr/components-contrib/secretstores" ) diff --git a/pkg/runtime/sequencer/cache.go b/pkg/runtime/sequencer/cache.go index e9d03cc12f..ea0e4b2f7c 100644 --- a/pkg/runtime/sequencer/cache.go +++ b/pkg/runtime/sequencer/cache.go @@ -16,11 +16,12 @@ package sequencer import ( "context" "errors" + "sync" + "time" + "mosn.io/layotto/components/sequencer" "mosn.io/pkg/log" "mosn.io/pkg/utils" - "sync" - "time" ) const defaultSize = 10000 diff --git a/pkg/runtime/sequencer/cache_test.go b/pkg/runtime/sequencer/cache_test.go index 608ce964e3..14875ce239 100644 --- a/pkg/runtime/sequencer/cache_test.go +++ b/pkg/runtime/sequencer/cache_test.go @@ -15,12 +15,13 @@ package sequencer import ( "context" + "testing" + "github.com/alicebob/miniredis/v2" "github.com/stretchr/testify/assert" "mosn.io/layotto/components/sequencer" "mosn.io/layotto/components/sequencer/redis" "mosn.io/pkg/log" - "testing" ) const keyXx = "resource_xxx" diff --git a/pkg/runtime/sequencer/factory_test.go b/pkg/runtime/sequencer/factory_test.go index 19cd77b920..d5f8cd468a 100644 --- a/pkg/runtime/sequencer/factory_test.go +++ b/pkg/runtime/sequencer/factory_test.go @@ -14,8 +14,9 @@ package sequencer import ( - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func TestNewFactory(t *testing.T) { diff --git a/pkg/runtime/sequencer/registry.go b/pkg/runtime/sequencer/registry.go index 7265879430..16c7749213 100644 --- a/pkg/runtime/sequencer/registry.go +++ b/pkg/runtime/sequencer/registry.go @@ -15,6 +15,7 @@ package sequencer import ( "fmt" + "mosn.io/layotto/components/pkg/info" "mosn.io/layotto/components/sequencer" ) diff --git a/pkg/runtime/sequencer/registry_test.go b/pkg/runtime/sequencer/registry_test.go index 9224b09ae1..43a702889f 100644 --- a/pkg/runtime/sequencer/registry_test.go +++ b/pkg/runtime/sequencer/registry_test.go @@ -14,10 +14,11 @@ package sequencer import ( - "mosn.io/layotto/components/pkg/info" - "mosn.io/layotto/components/sequencer" "strings" "testing" + + "mosn.io/layotto/components/pkg/info" + "mosn.io/layotto/components/sequencer" ) func TestNewRegistry(t *testing.T) { diff --git a/pkg/runtime/sequencer/sequencer_config.go b/pkg/runtime/sequencer/sequencer_config.go index eaf2a42391..b0f8337cd0 100644 --- a/pkg/runtime/sequencer/sequencer_config.go +++ b/pkg/runtime/sequencer/sequencer_config.go @@ -15,8 +15,9 @@ package sequencer import ( "fmt" - "github.com/pkg/errors" "strings" + + "github.com/pkg/errors" ) const ( diff --git a/pkg/runtime/state/factory_test.go b/pkg/runtime/state/factory_test.go index 2205e0c4d1..0127554460 100644 --- a/pkg/runtime/state/factory_test.go +++ b/pkg/runtime/state/factory_test.go @@ -14,8 +14,9 @@ package state import ( - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func TestNewFactory(t *testing.T) { diff --git a/pkg/runtime/state/registry.go b/pkg/runtime/state/registry.go index a1190c978c..f9551bde9e 100644 --- a/pkg/runtime/state/registry.go +++ b/pkg/runtime/state/registry.go @@ -18,6 +18,7 @@ package state import ( "fmt" + "github.com/dapr/components-contrib/state" "mosn.io/layotto/components/pkg/info" ) diff --git a/pkg/runtime/state/registry_test.go b/pkg/runtime/state/registry_test.go index 1ab8cb8a40..26b3bcc707 100644 --- a/pkg/runtime/state/registry_test.go +++ b/pkg/runtime/state/registry_test.go @@ -17,10 +17,11 @@ package state import ( - "github.com/dapr/components-contrib/state" - "mosn.io/layotto/components/pkg/info" "strings" "testing" + + "github.com/dapr/components-contrib/state" + "mosn.io/layotto/components/pkg/info" ) func TestNewRegistry(t *testing.T) { diff --git a/pkg/wasm/abi.go b/pkg/wasm/abi.go index b569c3b57a..c3f5fb9f7d 100644 --- a/pkg/wasm/abi.go +++ b/pkg/wasm/abi.go @@ -18,6 +18,7 @@ package wasm import ( "errors" + "mosn.io/mosn/pkg/types" "mosn.io/mosn/pkg/wasm/abi" v1 "mosn.io/mosn/pkg/wasm/abi/proxywasm010" diff --git a/pkg/wasm/factory_test.go b/pkg/wasm/factory_test.go index b5c0bd9345..cba9aba77f 100644 --- a/pkg/wasm/factory_test.go +++ b/pkg/wasm/factory_test.go @@ -15,12 +15,13 @@ package wasm import ( "encoding/json" + "testing" + "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" v2 "mosn.io/mosn/pkg/config/v2" "mosn.io/mosn/pkg/mock" "mosn.io/mosn/pkg/wasm" - "testing" ) func TestCreateProxyWasmFilterFactory(t *testing.T) { diff --git a/pkg/wasm/filter.go b/pkg/wasm/filter.go index 6a0d0349ac..5587393509 100644 --- a/pkg/wasm/filter.go +++ b/pkg/wasm/filter.go @@ -19,11 +19,12 @@ package wasm import ( "context" "fmt" - "mosn.io/mosn/pkg/variable" "reflect" "sync" "sync/atomic" + "mosn.io/mosn/pkg/variable" + "mosn.io/api" "mosn.io/mosn/pkg/log" "mosn.io/mosn/pkg/types" diff --git a/pkg/wasm/filter_test.go b/pkg/wasm/filter_test.go index b256b87870..6ef433eebc 100644 --- a/pkg/wasm/filter_test.go +++ b/pkg/wasm/filter_test.go @@ -17,9 +17,10 @@ package wasm import ( + "testing" + "github.com/stretchr/testify/assert" "mosn.io/proxy-wasm-go-host/proxywasm/common" - "testing" ) func TestMapEncodeAndDecode(t *testing.T) { diff --git a/pkg/wasm/imports.go b/pkg/wasm/imports.go index 90ebd43fc9..0b71810a5c 100644 --- a/pkg/wasm/imports.go +++ b/pkg/wasm/imports.go @@ -18,6 +18,7 @@ package wasm import ( "context" + anypb "github.com/golang/protobuf/ptypes/any" "mosn.io/layotto/pkg/grpc/default_api" runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" diff --git a/pkg/wasm/imports_test.go b/pkg/wasm/imports_test.go index 85dcbbce91..2b44f388e4 100644 --- a/pkg/wasm/imports_test.go +++ b/pkg/wasm/imports_test.go @@ -18,6 +18,8 @@ package wasm import ( "context" + "testing" + "github.com/dapr/components-contrib/state" "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" @@ -27,7 +29,6 @@ import ( mock_invoker "mosn.io/layotto/pkg/mock/components/invoker" mock_state "mosn.io/layotto/pkg/mock/components/state" proxywasm "mosn.io/proxy-wasm-go-host/proxywasm/v1" - "testing" ) func TestImportsHandler(t *testing.T) { diff --git a/pkg/wasm/watcher.go b/pkg/wasm/watcher.go index 6e7e5fee40..93fb2498c4 100644 --- a/pkg/wasm/watcher.go +++ b/pkg/wasm/watcher.go @@ -14,11 +14,12 @@ package wasm import ( - "mosn.io/pkg/utils" "os" "path/filepath" "strings" + "mosn.io/pkg/utils" + v2 "mosn.io/mosn/pkg/config/v2" "mosn.io/mosn/pkg/log" "mosn.io/mosn/pkg/wasm" diff --git a/sdk/go-sdk/client/client_test.go b/sdk/go-sdk/client/client_test.go index 7a5f1b2e23..0fb0803ada 100644 --- a/sdk/go-sdk/client/client_test.go +++ b/sdk/go-sdk/client/client_test.go @@ -19,6 +19,10 @@ package client import ( "context" "fmt" + "net" + "os" + "testing" + "github.com/stretchr/testify/assert" "google.golang.org/grpc" "google.golang.org/grpc/test/bufconn" @@ -26,9 +30,6 @@ import ( empty "google.golang.org/protobuf/types/known/emptypb" pb "mosn.io/layotto/spec/proto/runtime/v1" runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" - "net" - "os" - "testing" ) const ( diff --git a/sdk/go-sdk/client/configuration.go b/sdk/go-sdk/client/configuration.go index d1a91aa7fc..e0d8b562bd 100644 --- a/sdk/go-sdk/client/configuration.go +++ b/sdk/go-sdk/client/configuration.go @@ -18,6 +18,7 @@ package client import ( "context" + runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" ) diff --git a/sdk/go-sdk/client/configuration_test.go b/sdk/go-sdk/client/configuration_test.go index c7151ed4ec..8f8f9247ab 100644 --- a/sdk/go-sdk/client/configuration_test.go +++ b/sdk/go-sdk/client/configuration_test.go @@ -18,8 +18,9 @@ package client import ( "context" - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func TestSaveConfiguration(t *testing.T) { diff --git a/sdk/go-sdk/client/hello.go b/sdk/go-sdk/client/hello.go index 31960f8281..0cc59779e8 100644 --- a/sdk/go-sdk/client/hello.go +++ b/sdk/go-sdk/client/hello.go @@ -18,6 +18,7 @@ package client import ( "context" + runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" ) diff --git a/sdk/go-sdk/client/hello_test.go b/sdk/go-sdk/client/hello_test.go index 44b82a71da..36f902f698 100644 --- a/sdk/go-sdk/client/hello_test.go +++ b/sdk/go-sdk/client/hello_test.go @@ -18,8 +18,9 @@ package client import ( "context" - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func TestSayHello(t *testing.T) { diff --git a/sdk/go-sdk/client/lock.go b/sdk/go-sdk/client/lock.go index 2dd668e351..88a05849e8 100644 --- a/sdk/go-sdk/client/lock.go +++ b/sdk/go-sdk/client/lock.go @@ -15,6 +15,7 @@ package client import ( "context" + runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" ) diff --git a/sdk/go-sdk/client/secret.go b/sdk/go-sdk/client/secret.go index 4cb9b79a1f..91790d63ec 100644 --- a/sdk/go-sdk/client/secret.go +++ b/sdk/go-sdk/client/secret.go @@ -17,6 +17,7 @@ package client import ( "context" + "google.golang.org/grpc" runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" ) diff --git a/sdk/go-sdk/client/secret_test.go b/sdk/go-sdk/client/secret_test.go index a786ee0a08..4fd1fbe447 100644 --- a/sdk/go-sdk/client/secret_test.go +++ b/sdk/go-sdk/client/secret_test.go @@ -17,9 +17,10 @@ package client import ( "context" + "testing" + "github.com/stretchr/testify/assert" runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" - "testing" ) var secretKey = "secret-key" diff --git a/sdk/go-sdk/client/sequencer.go b/sdk/go-sdk/client/sequencer.go index f46befc82e..b14756a51d 100644 --- a/sdk/go-sdk/client/sequencer.go +++ b/sdk/go-sdk/client/sequencer.go @@ -15,6 +15,7 @@ package client import ( "context" + runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" ) diff --git a/sdk/go-sdk/client/state.go b/sdk/go-sdk/client/state.go index 046b6b695d..a70962309d 100755 --- a/sdk/go-sdk/client/state.go +++ b/sdk/go-sdk/client/state.go @@ -18,9 +18,10 @@ package client import ( "context" - runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" "time" + runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" + "github.com/golang/protobuf/ptypes/duration" "github.com/pkg/errors" ) diff --git a/spec/proto/runtime/v1/appcallback.pb.go b/spec/proto/runtime/v1/appcallback.pb.go index 1e9cdf5756..c41982798a 100644 --- a/spec/proto/runtime/v1/appcallback.pb.go +++ b/spec/proto/runtime/v1/appcallback.pb.go @@ -8,14 +8,15 @@ package runtime import ( context "context" + reflect "reflect" + sync "sync" + grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" emptypb "google.golang.org/protobuf/types/known/emptypb" - reflect "reflect" - sync "sync" ) const ( diff --git a/spec/proto/runtime/v1/runtime.pb.go b/spec/proto/runtime/v1/runtime.pb.go index c52b31e507..85cdab2b40 100644 --- a/spec/proto/runtime/v1/runtime.pb.go +++ b/spec/proto/runtime/v1/runtime.pb.go @@ -8,6 +8,9 @@ package runtime import ( context "context" + reflect "reflect" + sync "sync" + grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -15,8 +18,6 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" anypb "google.golang.org/protobuf/types/known/anypb" emptypb "google.golang.org/protobuf/types/known/emptypb" - reflect "reflect" - sync "sync" ) const ( diff --git a/test/runtime/redis_integrate_test.go b/test/runtime/redis_integrate_test.go index 46d1cc0a42..2fbdc85747 100644 --- a/test/runtime/redis_integrate_test.go +++ b/test/runtime/redis_integrate_test.go @@ -18,12 +18,13 @@ package runtime import ( "context" + "sync" + "testing" + "github.com/google/uuid" "github.com/stretchr/testify/assert" "mosn.io/layotto/sdk/go-sdk/client" runtimev1pb "mosn.io/layotto/spec/proto/runtime/v1" - "sync" - "testing" ) var componentName = "redis" @@ -75,12 +76,12 @@ func TestLockApi(t *testing.T) { owner1 := uuid.New().String() owner2 := uuid.New().String() - resourceId := "MyLock" + resourceID := "MyLock" // 1. client1 tryLock resp, err := cli.TryLock(ctx, &runtimev1pb.TryLockRequest{ StoreName: componentName, - ResourceId: resourceId, + ResourceId: resourceID, LockOwner: owner1, Expire: 100000, }) @@ -93,7 +94,7 @@ func TestLockApi(t *testing.T) { go func() { resp, err := cli.TryLock(ctx, &runtimev1pb.TryLockRequest{ StoreName: componentName, - ResourceId: resourceId, + ResourceId: resourceID, LockOwner: owner2, Expire: 1000, }) @@ -105,7 +106,7 @@ func TestLockApi(t *testing.T) { // 3. client1 unlock unlockResp, err := cli.Unlock(ctx, &runtimev1pb.UnlockRequest{ StoreName: componentName, - ResourceId: resourceId, + ResourceId: resourceID, LockOwner: owner1, }) assert.Nil(t, err) @@ -116,7 +117,7 @@ func TestLockApi(t *testing.T) { go func() { resp, err := cli.TryLock(ctx, &runtimev1pb.TryLockRequest{ StoreName: componentName, - ResourceId: resourceId, + ResourceId: resourceID, LockOwner: owner2, Expire: 10, }) @@ -125,7 +126,7 @@ func TestLockApi(t *testing.T) { // 5. client2 unlock unlockResp, err := cli.Unlock(ctx, &runtimev1pb.UnlockRequest{ StoreName: componentName, - ResourceId: resourceId, + ResourceId: resourceID, LockOwner: owner2, }) assert.Nil(t, err) diff --git a/test/wasm/wasm_test.go b/test/wasm/wasm_test.go index cbe038fc2c..6372aa8585 100644 --- a/test/wasm/wasm_test.go +++ b/test/wasm/wasm_test.go @@ -19,10 +19,11 @@ package wasm import ( "context" "io/ioutil" - "mosn.io/layotto/components/pkg/utils" "net/http" "testing" + "mosn.io/layotto/components/pkg/utils" + "github.com/stretchr/testify/assert" )