diff --git a/.github/workflows/compile-assets.yml b/.github/workflows/compile-assets.yml new file mode 100644 index 00000000..f8b9ab81 --- /dev/null +++ b/.github/workflows/compile-assets.yml @@ -0,0 +1,12 @@ +name: build app + +on: + pull_request: + branches: [ master ] + +jobs: + ui: + permissions: + contents: write + uses: bavix/.github/.github/workflows/compile-assets.yml@0.0.5 + secrets: inherit \ No newline at end of file diff --git a/docs/README.md b/docs/README.md deleted file mode 120000 index 32d46ee8..00000000 --- a/docs/README.md +++ /dev/null @@ -1 +0,0 @@ -../README.md \ No newline at end of file diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 00000000..096b8f2b --- /dev/null +++ b/docs/README.md @@ -0,0 +1,16 @@ +# GripMock User Documentation + +--- + +![GripMock](https://placehold.co/1120x440/EEE/31343C) + +`GripMock` is a mock server for GRPC services. + +## Support + +Please ask questions on the [Github issues page](https://github.com/bavix/gripmock/issues). + +--- +Supported by + +[![Supported by JetBrains](https://cdn.rawgit.com/bavix/development-through/46475b4b/jetbrains.svg)](https://www.jetbrains.com/) \ No newline at end of file diff --git a/docs/_sidebar.md b/docs/_sidebar.md index 433b74eb..b152bd99 100644 --- a/docs/_sidebar.md +++ b/docs/_sidebar.md @@ -1,2 +1,3 @@ - Getting started - - [Introduction](README) + - [Overview](overview) + - [Quick Usage](quick-usage) diff --git a/docs/overview.md b/docs/overview.md new file mode 100644 index 00000000..fd474a90 --- /dev/null +++ b/docs/overview.md @@ -0,0 +1,20 @@ +# Overview + +GripMock is a **mock server** for **GRPC** services. It's using a `.proto` file to generate implementation of gRPC service for you. +You can use gripmock for setting up end-to-end testing or as a dummy server in a software development phase. +The server implementation is in GoLang but the client can be any programming language that support gRPC. + +This service is a fork of the service [tokopedia/gripmock](https://github.com/tokopedia/gripmock). + +## Fork key features +- Updated all deprecated dependencies [tokopedia#64](https://github.com/tokopedia/gripmock/issues/64); +- Add yaml as json alternative for static stab's; +- Add endpoint for healthcheck (/health); +- Add grpc error code [tokopedia#125](https://github.com/tokopedia/gripmock/issues/125); +- Added gzip encoding support for grpc server [tokopedia#134](https://github.com/tokopedia/gripmock/pull/134); +- Fixed issues with int64/uint64 [tokopedia#67](https://github.com/tokopedia/gripmock/pull/148); +- Add 404 error for stubs not found [tokopedia#142](https://github.com/tokopedia/gripmock/issues/142); +- Support for deleting specific stub [tokopedia#123](https://github.com/tokopedia/gripmock/issues/123); +- Reduced image size [tokopedia#91](https://github.com/tokopedia/gripmock/issues/91); +- Active support [tokopedia#82](https://github.com/tokopedia/gripmock/issues/82); +- Added documentation; diff --git a/docs/quick-usage.md b/docs/quick-usage.md new file mode 100644 index 00000000..ab40e013 --- /dev/null +++ b/docs/quick-usage.md @@ -0,0 +1,87 @@ +## Quick Usage + +I suspect if you have reached this page, then you already have a grpc server and a proto contract. Do not delay the contract far, now you will need it. + +Let's imagine that our contract `simple.proto` looks something like this: +```protobuf +syntax = "proto3"; +option go_package = "github.com/bavix/gripmock/protogen/example/simple"; + +package simple; + +service Gripmock { + rpc SayHello (Request) returns (Reply); +} + +message Request { + string name = 1; +} + +message Reply { + string message = 1; + int32 return_code = 2; +} +``` + +At the moment, there is no standalone version of gripmock, only a docker image. + +I will skip the details of installing docker and using it. Read documentation: https://docs.docker.com/engine/install/. + +Let's start the GripMock server: +```bash +docker run -p 4770:4770 -p 4771:4771 -v ./simple.proto:/proto/simple.proto:ro bavix/gripmock /proto/simple.proto +``` + +After launch, you will see something like this: +```bash +➜ simple git:(docs) ✗ docker run -p 4770:4770 -p 4771:4771 -v ./api:/proto:ro bavix/gripmock /proto/simple.proto +Starting GripMock +Serving stub admin on http://:4771 +grpc server pid: 38 +Serving gRPC on tcp://:4770 +``` + +What is important to understand? +1. GRPC Mock server started on port 4770; +2. HTTP server for working with the stub server is running on port 4771; + +This means that everything went well. Now let's add the first stub: +```bash +curl -X POST -d '{"service":"Gripmock","method":"SayHello","input":{"equals":{"name":"gripmock"}},"output":{"data":{"message":"Hello GripMock"}}}' 127.0.0.1:4771/api/stubs +``` + +The stub has been successfully added, you have received a stub ID: +```bash +["6c85b0fa-caaf-4640-a672-f56b7dd8074d"] +``` + +You can check the added stubs at the link: http://127.0.0.1:4771/api/stubs. +The result will not make you wait long, you should see the following: +```json +[ + { + "id": "6c85b0fa-caaf-4640-a672-f56b7dd8074d", + "service": "Gripmock", + "method": "SayHello", + "input": { + "equals": { + "name": "gripmock" + }, + "contains": null, + "matches": null + }, + "output": { + "data": { + "message": "Hello GripMock" + }, + "error": "" + } + } +] +``` + +Now try to use the grpc client to our service with the data from the input. + +Happened? Well done. You are a fast learner. + +It worked! \ No newline at end of file diff --git a/docs/src/index.js b/docs/src/index.js index fa068e13..235eb906 100644 --- a/docs/src/index.js +++ b/docs/src/index.js @@ -2,5 +2,7 @@ import 'docsify' import 'docsify/lib/plugins/emoji' import 'docsify/lib/plugins/search' import 'prismjs/components/prism-go' +import 'prismjs/components/prism-json' import 'prismjs/components/prism-bash' +import 'prismjs/components/prism-protobuf' import 'docsify/lib/themes/vue.css'