Skip to content

Commit 62e1c83

Browse files
committed
Merge remote-tracking branch 'origin/master' into front-api-re
1 parent 2eaf313 commit 62e1c83

File tree

100 files changed

+13577
-803
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+13577
-803
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Unix-style newlines with a newline ending every file
7+
[*]
8+
end_of_line = lf
9+
insert_final_newline = true
10+
charset = utf-8
11+
12+
# 4 space indentation
13+
[*.{py,proto,go,js,ts,json,vue}]
14+
indent_style = space
15+
indent_size = 4

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
Make sure you run the `make test` command before committing the pr.
33
Making sure that your local build is OK before committing will help you reduce debugging time
44
and make it easier for maintainers to review.
5-
6-
If you are committing pr for the first time,
7-
please read the contributor's documentation: https://github.com/LinuxSuRen/api-testing/blob/master/CONTRIBUTION.md
85
-->
96

7+
> We highly recommend you read [the contributor's documentation](https://github.com/LinuxSuRen/api-testing/blob/master/CONTRIBUTING.md) before starting the review process especially since this is your first contribution to this project.
8+
>
9+
> It was updated on 2024/5/27
10+
1011
**What type of PR is this?**
1112
<!--
1213
Your PR title should be descriptive, and generally start with type that contains a subsystem name with `()` if necessary

.github/workflows/build.yaml

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
env:
66
IMG_TOOL: docker
77

8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
10+
cancel-in-progress: true
11+
812
jobs:
913
Test:
1014
runs-on: ubuntu-22.04
@@ -39,8 +43,7 @@ jobs:
3943
env:
4044
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4145
run: |
42-
make build
43-
make copy
46+
make build copy
4447
sudo atest service install
4548
sudo atest service restart
4649
sudo atest service status
@@ -73,7 +76,7 @@ jobs:
7376
# - name: Operator
7477
# run: cd operator && make build
7578

76-
BuildImage:
79+
E2E:
7780
runs-on: ubuntu-22.04
7881
steps:
7982
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
@@ -92,7 +95,7 @@ jobs:
9295
fi
9396
make helm-pkg
9497
- name: Core Image
95-
run: GOPROXY=direct IMG_TOOL=docker make build
98+
run: GOPROXY=direct IMG_TOOL=docker TAG=master REGISTRY=ghcr.io make image
9699
- name: Run e2e
97100
env:
98101
GITEE_TOKEN: ${{ secrets.GITEE_TOKEN }}
@@ -102,11 +105,11 @@ jobs:
102105
sudo curl -L https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
103106
sudo chmod u+x /usr/local/bin/docker-compose
104107
make test-e2e
105-
# - name: Operator Image
106-
# run: cd operator && make docker-build
108+
- name: Code Generator Test
109+
run: cd e2e/code-generator && ./start.sh
107110

108111
BuildEmbedUI:
109-
runs-on: ubuntu-22.04
112+
runs-on: ubuntu-latest
110113
steps:
111114
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
112115
- uses: ./tools/github-actions/setup-deps
@@ -118,8 +121,36 @@ jobs:
118121
cache-dependency-path: console/atest-ui/package-lock.json
119122
- name: Build
120123
run: |
121-
make build-embed-ui
124+
make build-embed-ui copy
122125
sudo atest service install
123126
sudo atest service restart
124127
- name: Test
125128
run: make test-ui
129+
130+
BuildDesktop:
131+
strategy:
132+
matrix:
133+
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
134+
runs-on: ${{ matrix.os }}
135+
steps:
136+
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
137+
- uses: ./tools/github-actions/setup-deps
138+
- name: Use Node.js
139+
uses: actions/setup-node@v3
140+
with:
141+
node-version: 18.x
142+
# for fixing Error: Cannot find module 'appdmg'
143+
- name: Install Python 3.11.4
144+
uses: actions/setup-python@v4
145+
with:
146+
python-version: '3.11.4'
147+
- name: Build Desktop on Windows
148+
if: runner.os == 'Windows'
149+
env:
150+
BINARY: atest.exe
151+
run: |
152+
make desktop-package desktop-make
153+
- name: Build Desktop
154+
if: runner.os != 'Windows'
155+
run: |
156+
make desktop-package desktop-make desktop-test

.github/workflows/qodana_code_quality.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ on:
55
push:
66
branches:
77
- master
8-
- feat/mock-timer
98

109
jobs:
1110
qodana:
1211
runs-on: ubuntu-latest
12+
if: github.actor == 'linuxsuren'
1313
steps:
1414
- uses: actions/checkout@v3
1515
with:

.github/workflows/release.yaml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ env:
1111
REGISTRY: ghcr.io
1212
REGISTRY_DOCKERHUB: docker.io
1313
REGISTRY_ALIYUN: registry.aliyuncs.com
14+
REGISTRY_TENCENT: ccr.ccs.tencentyun.com
1415
IMAGE_NAME: ${{ github.repository }}
1516

1617
jobs:
@@ -85,6 +86,13 @@ jobs:
8586
registry: ${{ env.REGISTRY_ALIYUN }}
8687
username: ${{ secrets.REGISTRY_ALIYUN_USER }}
8788
password: ${{ secrets.REGISTRY_ALIYUN_PUBLISH_SECRETS }}
89+
- name: Log into registry ${{ env.REGISTRY_TENCENT }}
90+
if: github.event_name != 'pull_request'
91+
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
92+
with:
93+
registry: ${{ env.REGISTRY_TENCENT }}
94+
username: 100002400732
95+
password: ${{ secrets.REGISTRY_TENCENT_PUBLISH_SECRETS }}
8896
- name: Extract Docker metadata
8997
id: meta
9098
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
@@ -93,6 +101,7 @@ jobs:
93101
${{ env.REGISTRY }}/linuxsuren/api-testing
94102
${{ env.REGISTRY_DOCKERHUB }}/${{ env.IMAGE_NAME }}
95103
${{ env.REGISTRY_ALIYUN }}/${{ env.IMAGE_NAME }}
104+
${{ env.REGISTRY_TENCENT }}/${{ env.IMAGE_NAME }}
96105
- name: Build and push Docker image
97106
id: build-and-push
98107
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
@@ -117,6 +126,90 @@ jobs:
117126
fi
118127
make helm-pkg helm-push
119128
129+
BuildDesktop:
130+
strategy:
131+
fail-fast: false
132+
matrix:
133+
# see https://github.com/actions/runner-images
134+
os: [ubuntu-latest, windows-latest, macos-latest, macos-13]
135+
runs-on: ${{ matrix.os }}
136+
steps:
137+
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
138+
- uses: ./tools/github-actions/setup-deps
139+
- name: Use Node.js
140+
uses: actions/setup-node@v3
141+
with:
142+
node-version: 18.x
143+
- name: Build Server on Windows
144+
if: runner.os == 'Windows'
145+
env:
146+
BINARY: atest.exe
147+
run: |
148+
make desktop-package
149+
- name: Build Server
150+
if: runner.os != 'Windows'
151+
run: |
152+
make desktop-package
153+
# for fixing Error: Cannot find module 'appdmg'
154+
- name: Install Python 3.11.4
155+
uses: actions/setup-python@v4
156+
with:
157+
python-version: '3.11.4'
158+
- name: Upload to Draft
159+
env:
160+
GITHUB_TOKEN: ${{ secrets.GH_PUBLISH_SECRETS }}
161+
if: github.ref == 'refs/heads/master' && runner.os != 'Windows'
162+
run: |
163+
cd console/atest-desktop
164+
export TAG=$(gh release list -L 1 | awk '{print $4}')
165+
export TAG=${TAG#"v"}
166+
jq '.version = env.TAG' package.json > package.json.new && mv package.json.new package.json
167+
npm i
168+
npm run publish
169+
- name: Upload to Draft on Windows
170+
env:
171+
GITHUB_TOKEN: ${{ secrets.GH_PUBLISH_SECRETS }}
172+
if: github.ref == 'refs/heads/master' && runner.os == 'Windows'
173+
run: |
174+
cd console/atest-desktop
175+
$TAG = (gh release list -L 1).Split(' ')[0]
176+
if ($TAG -like "v*") {
177+
$TAG = $TAG -replace "^v", ""
178+
}
179+
Set-Content -Path "env:TAG" -Value "$TAG"
180+
jq '.version = env.TAG' package.json > package.json.new
181+
rm package.json
182+
Rename-Item -Path package.json.new -NewName package.json
183+
npm i
184+
npm run publish
185+
- name: Upload
186+
env:
187+
GITHUB_TOKEN: ${{ secrets.GH_PUBLISH_SECRETS }}
188+
if: github.ref != 'refs/heads/master' && runner.os != 'Windows'
189+
run: |
190+
cd console/atest-desktop
191+
export TAG=$(git describe --tags --abbrev=0)
192+
export TAG=${TAG#"v"}
193+
jq '.version = env.TAG' package.json > package.json.new && mv package.json.new package.json
194+
npm i
195+
npm run publish
196+
- name: Upload on Windows
197+
env:
198+
GITHUB_TOKEN: ${{ secrets.GH_PUBLISH_SECRETS }}
199+
if: github.ref != 'refs/heads/master' && runner.os == 'Windows'
200+
run: |
201+
cd console/atest-desktop
202+
$TAG = git describe --tags --abbrev=0
203+
if ($TAG -like "v*") {
204+
$TAG = $TAG -replace "^v", ""
205+
}
206+
Set-Content -Path "env:TAG" -Value "$TAG"
207+
jq '.version = env.TAG' package.json > package.json.new
208+
rm package.json
209+
Rename-Item -Path package.json.new -NewName package.json
210+
npm i
211+
npm run publish
212+
120213
# image-operator:
121214
# runs-on: ubuntu-20.04
122215
# steps:

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,8 @@ helm/*.tgz
1515
helm/api-testing/*.tgz
1616
oryxBuildBinary
1717
/helm/api-testing/charts/
18+
console/atest-desktop/out
19+
console/atest-desktop/node_modules
20+
console/atest-desktop/atest
21+
console/atest-desktop/atest.exe
22+
console/atest-desktop/coverage

CONTRIBUTING-ZH.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
| [Helm chart](https://helm.sh/) | The [Kubernetes](https://kubernetes.io/docs/home/) application package |
2121
| [GitHub Actions](https://docs.github.com/en/actions) | The continuous integration |
2222
| [make](https://www.gnu.org/software/make/) | The automated Build Tools |
23+
| [Docs Guide](https://github.com/LinuxSuRen/api-testing.git) | 文档编写指南 |
2324

2425
## 设置开发环境
2526

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ You might need to know the following tech before get started.
2020
| [Helm chart](https://helm.sh/) | The [Kubernetes](https://kubernetes.io/docs/home/) application package |
2121
| [GitHub Actions](https://docs.github.com/en/actions) | The continuous integration |
2222
| [make](https://www.gnu.org/software/make/) | The automated Build Tools |
23+
| [Docs Guide](https://github.com/LinuxSuRen/api-testing.git) | Documentation Guidelines |
2324

2425
## Setup development environment
2526

cmd/mock.go

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ limitations under the License.
1717
package cmd
1818

1919
import (
20-
"errors"
2120
"os"
2221
"os/signal"
2322
"syscall"
@@ -29,37 +28,29 @@ import (
2928
type mockOption struct {
3029
port int
3130
prefix string
32-
files []string
3331
}
3432

3533
func createMockCmd() (c *cobra.Command) {
3634
opt := &mockOption{}
3735

3836
c = &cobra.Command{
39-
Use: "mock",
40-
Short: "Start a mock server",
41-
PreRunE: opt.preRunE,
42-
RunE: opt.runE,
37+
Use: "mock",
38+
Short: "Start a mock server",
39+
Args: cobra.ExactArgs(1),
40+
RunE: opt.runE,
4341
}
4442

4543
flags := c.Flags()
4644
flags.IntVarP(&opt.port, "port", "", 6060, "The mock server port")
4745
flags.StringVarP(&opt.prefix, "prefix", "", "/mock", "The mock server API prefix")
48-
flags.StringSliceVarP(&opt.files, "files", "", nil, "The mock config files")
49-
return
50-
}
51-
52-
func (o *mockOption) preRunE(c *cobra.Command, args []string) (err error) {
53-
if len(o.files) == 0 {
54-
err = errors.New("at least one file is required")
55-
}
5646
return
5747
}
5848

5949
func (o *mockOption) runE(c *cobra.Command, args []string) (err error) {
60-
reader := mock.NewLocalFileReader(o.files[0])
50+
reader := mock.NewLocalFileReader(args[0])
6151
server := mock.NewInMemoryServer(o.port)
6252

53+
c.Println("start listen", o.port)
6354
if err = server.Start(reader, o.prefix); err != nil {
6455
return
6556
}

cmd/run.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ See also https://github.com/LinuxSuRen/api-testing/tree/master/sample`,
114114
flags.DurationVarP(&opt.duration, "duration", "", 0, "Running duration")
115115
flags.DurationVarP(&opt.requestTimeout, "request-timeout", "", time.Minute, "Timeout for per request")
116116
flags.BoolVarP(&opt.requestIgnoreError, "request-ignore-error", "", false, "Indicate if ignore the request error")
117-
flags.StringVarP(&opt.report, "report", "", "", "The type of target report. Supported: markdown, md, html, json, discard, std, prometheus, http")
117+
flags.StringVarP(&opt.report, "report", "", "", "The type of target report. Supported: markdown, md, html, json, discard, std, prometheus, http, grpc")
118118
flags.StringVarP(&opt.reportFile, "report-file", "", "", "The file path of the report")
119119
flags.BoolVarP(&opt.reportIgnore, "report-ignore", "", false, "Indicate if ignore the report output")
120120
flags.StringVarP(&opt.reportTemplate, "report-template", "", "", "The template used to render the report")
@@ -166,15 +166,20 @@ func (o *runOption) preRunE(cmd *cobra.Command, args []string) (err error) {
166166
case "http":
167167
templateOption := runner.NewTemplateOption(o.reportTemplate, "json")
168168
o.reportWriter = runner.NewHTTPResultWriter(http.MethodPost, o.reportDest, nil, templateOption)
169+
case "grpc":
170+
if o.reportDest == "" {
171+
err = fmt.Errorf("report gRPC server url is required for prometheus report")
172+
}
173+
o.reportWriter = runner.NewGRPCResultWriter(o.context, o.reportDest)
169174
default:
170175
err = fmt.Errorf("not supported report type: '%s'", o.report)
171176
}
172177

173178
if err == nil {
174-
var swaggerAPI apispec.APIConverage
179+
var swaggerAPI apispec.SwaggerAPI
175180
if o.swaggerURL != "" {
176-
if swaggerAPI, err = apispec.ParseURLToSwagger(o.swaggerURL); err == nil {
177-
o.reportWriter.WithAPIConverage(swaggerAPI)
181+
if swaggerAPI.Swagger, err = apispec.ParseURLToSwagger(o.swaggerURL); err == nil {
182+
o.reportWriter.WithAPIConverage(&swaggerAPI)
178183
}
179184
}
180185
}

0 commit comments

Comments
 (0)