Skip to content

Commit 5e9ff2e

Browse files
authored
Merge pull request #808 from marle3003/develop
Develop
2 parents 980ae35 + b3b1995 commit 5e9ff2e

118 files changed

Lines changed: 7355 additions & 3257 deletions

File tree

Some content is hidden

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

.github/actions/build-mokapi-image/action.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ inputs:
1414
runs:
1515
using: "composite"
1616
steps:
17+
- uses: actions/setup-go@v5
18+
with:
19+
go-version: 1.25.5
20+
- name: Build CLI doc
21+
run: go run ./cmd/internal/gen-cli-docs/main.go
22+
shell: bash
23+
- name: Add CLI Flags nav entry
24+
run: |
25+
jq '.Configuration.items.Static.items["CLI Flags"] = "configuration/static/mokapi.md"' ./config.json > ./tmp.json
26+
mv ./tmp.json ./config.json
27+
working-directory: ./docs
28+
shell: bash
1729
- name: Build docker alpha image
1830
run: docker build --build-arg VERSION=${{ inputs.version }} -t ${{ inputs.image-name }} -t mokapi/mokapi:alpha -f ./images/alpha.Dockerfile .
1931
shell: bash

.github/actions/publish-website/action.yml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ runs:
2929
repository: marle3003/mokapi
3030
excludes: prerelease, draft
3131
token: ${{ inputs.token }}
32+
- name: Download image
33+
id: download
34+
uses: actions/download-artifact@v4
35+
with:
36+
name: ${{ env.image-artifact-name }}
37+
path: /tmp
38+
- name: Load image
39+
run: docker load --input /tmp/mokapi.tar
40+
shell: bash
3241
- name: Run mokapi image
3342
run: docker run --name mokapi --rm -d -p 80:80 -p 8080:8080 -p 9092:9092 -p 8389:8389 -p 8025:8025 --mount type=bind,source=$(pwd)/webui/scripts/dashboard-demo/demo-configs,target=/data --env MOKAPI_Providers_File_Directory=/data ${{ inputs.image-name }}
3443
shell: bash
@@ -42,11 +51,25 @@ runs:
4251
if: always()
4352
run: docker stop mokapi || true
4453
shell: bash
45-
- name: build website
54+
- name: build webui
4655
working-directory: ./webui
4756
run: |
4857
npm install
4958
npm version ${{ steps.release.outputs.release }}
59+
npm run build
60+
shell: bash
61+
- name: Build CLI doc
62+
run: go run ./cmd/internal/gen-cli-docs/main.go
63+
shell: bash
64+
- name: Add CLI Flags nav entry
65+
run: |
66+
jq '.Configuration.items.Static.items["CLI Flags"] = "configuration/static/mokapi.md"' ./config.json > ./tmp.json
67+
mv ./tmp.json ./config.json
68+
working-directory: ./docs
69+
shell: bash
70+
- name: build website
71+
working-directory: ./webui
72+
run: |
5073
npm run copy-docs
5174
npm run build-sitemap
5275
npm run build-website
@@ -55,6 +78,16 @@ runs:
5578
working-directory: ./webui
5679
run: npx playwright install --with-deps
5780
shell: bash
81+
- name: test website
82+
working-directory: ./webui
83+
run: npx playwright test --project=website
84+
shell: bash
85+
- name: Upload test results
86+
if: always()
87+
uses: actions/upload-artifact@v4
88+
with:
89+
name: website-test-report
90+
path: webui/playwright-report
5891
- name: prerender
5992
working-directory: ./webui/ssg
6093
run: node index.js

acceptance/ldap_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ package acceptance
22

33
import (
44
"fmt"
5-
"github.com/stretchr/testify/require"
65
"mokapi/config/static"
76
"mokapi/ldap"
87
"mokapi/runtime/metrics"
98
"mokapi/try"
109
"net/http"
1110
"time"
11+
12+
"github.com/stretchr/testify/require"
1213
)
1314

1415
type LdapSuite struct {
@@ -18,8 +19,7 @@ type LdapSuite struct {
1819

1920
func (suite *LdapSuite) SetupSuite() {
2021
cfg := static.NewConfig()
21-
port := try.GetFreePort()
22-
cfg.Api.Port = fmt.Sprintf("%v", port)
22+
cfg.Api.Port = try.GetFreePort()
2323
cfg.Providers.File.Directories = []string{"./ldap"}
2424
suite.initCmd(cfg)
2525
// ensure scripts are executed

acceptance/mail_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ type MailSuite struct{ BaseSuite }
2323

2424
func (suite *MailSuite) SetupSuite() {
2525
cfg := static.NewConfig()
26-
port := try.GetFreePort()
27-
cfg.Api.Port = fmt.Sprintf("%v", port)
26+
cfg.Api.Port = try.GetFreePort()
2827
wd, err := os.Getwd()
2928
require.NoError(suite.T(), err)
3029
cfg.ConfigFile = path.Join(wd, "mokapi.yaml")

acceptance/petstore_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ type PetStoreSuite struct{ BaseSuite }
2323

2424
func (suite *PetStoreSuite) SetupSuite() {
2525
cfg := static.NewConfig()
26-
port := try.GetFreePort()
27-
cfg.Api.Port = fmt.Sprintf("%v", port)
26+
cfg.Api.Port = try.GetFreePort()
2827
cfg.Providers.File.Directories = []string{"./petstore"}
2928
cfg.Api.Search.Enabled = true
3029
suite.initCmd(cfg)
@@ -172,7 +171,7 @@ func (suite *PetStoreSuite) TestJsHttpHandler() {
172171
try.BodyContains(`"name":"Zoe"`))
173172

174173
// test http metrics
175-
try.GetRequest(suite.T(), fmt.Sprintf("http://127.0.0.1:%s/api/metrics/http?path=/pet/{petId}", suite.cfg.Api.Port), nil,
174+
try.GetRequest(suite.T(), fmt.Sprintf("http://127.0.0.1:%d/api/metrics/http?path=/pet/{petId}", suite.cfg.Api.Port), nil,
176175
try.BodyContains(`http_requests_total{service=\"Swagger Petstore\",endpoint=\"/pet/{petId}\"}","value":4}`),
177176
)
178177
}
@@ -307,12 +306,12 @@ func (suite *PetStoreSuite) TestKafkaEventAndMetrics() {
307306
time.Sleep(3 * time.Second)
308307

309308
// test kafka metrics
310-
try.GetRequest(suite.T(), fmt.Sprintf("http://127.0.0.1:%s/api/metrics/kafka", suite.cfg.Api.Port), nil,
309+
try.GetRequest(suite.T(), fmt.Sprintf("http://127.0.0.1:%d/api/metrics/kafka", suite.cfg.Api.Port), nil,
311310
try.BodyContains(`kafka_messages_total{service=\"A sample AsyncApi Kafka streaming api\",topic=\"petstore.order-event\"}","value":1}`),
312311
)
313312

314313
// test kafka events, header added by JavaScript event handler
315-
try.GetRequest(suite.T(), fmt.Sprintf("http://127.0.0.1:%s/api/events?namespace=kafka", suite.cfg.Api.Port), nil,
314+
try.GetRequest(suite.T(), fmt.Sprintf("http://127.0.0.1:%d/api/events?namespace=kafka", suite.cfg.Api.Port), nil,
316315
try.BodyContains(`"headers":{"foo":{"value":"bar","binary":"YmFy"}`),
317316
try.BodyContains(`"messageId":"order"`),
318317
)

api/handler_test.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package api_test
22

33
import (
4-
"github.com/stretchr/testify/require"
54
"mokapi/api"
65
"mokapi/config/static"
76
"mokapi/providers/openapi"
@@ -11,6 +10,8 @@ import (
1110
"net/http"
1211
"net/http/httptest"
1312
"testing"
13+
14+
"github.com/stretchr/testify/require"
1415
)
1516

1617
func TestHandler_ServeHTTP(t *testing.T) {
@@ -57,7 +58,7 @@ func TestHandler_ServeHTTP(t *testing.T) {
5758
h,
5859
try.HasStatusCode(200),
5960
try.HasHeader("Content-Type", "application/json"),
60-
try.HasBody(`{"version":"","buildTime":"","search":{"enabled":false}}`))
61+
try.HasBody(`{"version":"0.0.0","buildTime":"","search":{"enabled":false}}`))
6162
},
6263
},
6364
{
@@ -120,7 +121,7 @@ func TestHandler_Api_Info(t *testing.T) {
120121
h,
121122
try.HasStatusCode(200),
122123
try.HasHeader("Content-Type", "application/json"),
123-
try.HasBody(`{"version":"","buildTime":"","activeServices":["http"],"search":{"enabled":false}}`))
124+
try.HasBody(`{"version":"0.0.0","buildTime":"","activeServices":["http"],"search":{"enabled":false}}`))
124125
},
125126
},
126127
{
@@ -135,7 +136,7 @@ func TestHandler_Api_Info(t *testing.T) {
135136
h,
136137
try.HasStatusCode(200),
137138
try.HasHeader("Content-Type", "application/json"),
138-
try.HasBody(`{"version":"","buildTime":"","activeServices":["kafka"],"search":{"enabled":false}}`))
139+
try.HasBody(`{"version":"0.0.0","buildTime":"","activeServices":["kafka"],"search":{"enabled":false}}`))
139140
},
140141
},
141142
{
@@ -150,7 +151,7 @@ func TestHandler_Api_Info(t *testing.T) {
150151
h,
151152
try.HasStatusCode(200),
152153
try.HasHeader("Content-Type", "application/json"),
153-
try.HasBody(`{"version":"","buildTime":"","activeServices":["mail"],"search":{"enabled":false}}`))
154+
try.HasBody(`{"version":"0.0.0","buildTime":"","activeServices":["mail"],"search":{"enabled":false}}`))
154155
},
155156
},
156157
{
@@ -165,7 +166,7 @@ func TestHandler_Api_Info(t *testing.T) {
165166
h,
166167
try.HasStatusCode(200),
167168
try.HasHeader("Content-Type", "application/json"),
168-
try.HasBody(`{"version":"","buildTime":"","activeServices":["ldap"],"search":{"enabled":false}}`))
169+
try.HasBody(`{"version":"0.0.0","buildTime":"","activeServices":["ldap"],"search":{"enabled":false}}`))
169170
},
170171
},
171172
}
@@ -204,5 +205,5 @@ func TestHandler_SearchEnabled(t *testing.T) {
204205
h,
205206
try.HasStatusCode(200),
206207
try.HasHeader("Content-Type", "application/json"),
207-
try.HasBody(`{"version":"","buildTime":"","search":{"enabled":true}}`))
208+
try.HasBody(`{"version":"0.0.0","buildTime":"","search":{"enabled":true}}`))
208209
}

cmd/internal/gen-cli-docs/main.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package main
2+
3+
import (
4+
"mokapi/pkg/cmd/mokapi"
5+
"os"
6+
)
7+
8+
func main() {
9+
err := mokapi.NewGenCliDocCmd().Execute()
10+
if err != nil {
11+
_, _ = os.Stderr.Write([]byte(err.Error()))
12+
}
13+
}

cmd/mokapi/help.go

Lines changed: 0 additions & 85 deletions
This file was deleted.

0 commit comments

Comments
 (0)