🚀 Enhancements in Offline Deployment Documentation, CICD Process Upgrades, Deployment Optimization, and Additional Fixes (#1721)
* feat: support openim prom enbels Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * feat: support openim prom enbels Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * feat: support openim prom enbels Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * feat: support openim prom enbels Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * feat: support openim prom enbels Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * feat: support openim prom enbels Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * feat: support openim prom enbels Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * feat: support openim prom enbels Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * feat: add go formity checker Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * feat: add openim offline deployment docs Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * feat: add openim offline deployment docs Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * feat: add openim offline deployment docs Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * feat: add openim support arm arch Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * fix: fox openim support arm arch Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * fix: fox openim support arm arch Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * feat: add openim v3.4 and v3.5 changelog Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * feat: add devcontainer.json file Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * feat: add openim v3.4 and v3.5 changelog Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * feat: add openim v3.4 and v3.5 changelog Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * Update util.sh amend shell get pid command fd on mac. * feat: Add To start developing OpenIM Docs Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * docs: update openim readme and dov container Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * feat: set openim lint Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * feat: fix go release scripts Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * feat: fix go release scripts Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * docs(changelog): add CHANGELOG-3.5.0+6.a09200e.md * docs(changelog): add CHANGELOG-3.5.0+2.e0bd54f.md * docs(changelog): add CHANGELOG-3.5.0+2.e0bd54f-1-g4ce6a0fa6.md * feat: set openim lint Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * docs(changelog): add CHANGELOG-3.5.0+2.e0bd54f-3-g52f9fc209.md * docs(changelog): add CHANGELOG-3.5.0+2.e0bd54f-4-g87f685b17.md * docs(changelog): add CHANGELOG-3.5.0.md * feat: set openim lint Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * fix: fix scripts functions upload Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * fix: fix scripts functions upload Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * docs(changelog): add CHANGELOG-3.5.0.md * fix: fix scripts functions upload Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * fix: fix scripts functions upload Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> * feat: set openim lint Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> --------- Signed-off-by: Xinwei Xiong (cubxxw) <3293172751nss@gmail.com> Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> Co-authored-by: mrwenhui <mr.wenhui@gmail.com>pull/1756/head
parent
bf46412c5a
commit
c795304df1
@ -0,0 +1,140 @@
|
||||
# OpenIM - OSS Development Container
|
||||
|
||||
[![Open in Dev Containers](https://img.shields.io/static/v1?label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/openimsdk/open-im-server)
|
||||
|
||||
This repository includes configuration for a development container for working with OpenIM - OSS in a local container or using [GitHub Codespaces](https://github.com/features/codespaces).
|
||||
|
||||
> **Tip:** The default VNC password is `openIM123`. The VNC server runs on port `5901` and a web client is available on port `11001`, openim-admin on port `11002`.
|
||||
|
||||
## Quick start - local
|
||||
|
||||
If you already have VS Code and Docker installed, you can click the badge above or [here](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/openimsdk/open-im-server) to get started. Clicking these links will cause VS Code to automatically install the Dev Containers extension if needed, clone the source code into a container volume, and spin up a dev container for use.
|
||||
|
||||
1. Install Docker Desktop or Docker for Linux on your local machine. (See [docs](https://aka.ms/vscode-remote/containers/getting-started) for additional details.)
|
||||
|
||||
2. **Important**: Docker needs at least **4 Cores and 8 GB of RAM** to run a full build with **9 GB of RAM** being recommended. If you are on macOS, or are using the old Hyper-V engine for Windows, update these values for Docker Desktop by right-clicking on the Docker status bar item and going to **Preferences/Settings > Resources > Advanced**.
|
||||
|
||||
> **Note:** The [Resource Monitor](https://marketplace.visualstudio.com/items?itemName=mutantdino.resourcemonitor) extension is included in the container so you can keep an eye on CPU/Memory in the status bar.
|
||||
|
||||
3. Install [Visual Studio Code Stable](https://code.visualstudio.com/) or [Insiders](https://code.visualstudio.com/insiders/) and the [Dev Containers](https://aka.ms/vscode-remote/download/containers) extension.
|
||||
|
||||
![Image of Dev Containers extension](https://microsoft.github.io/vscode-remote-release/images/dev-containers-extn.png)
|
||||
|
||||
> **Note:** The Dev Containers extension requires the Visual Studio Code distribution of OpenIM - OSS. See the [FAQ](https://aka.ms/vscode-remote/faq/license) for details.
|
||||
|
||||
4. Press <kbd>Ctrl/Cmd</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd> or <kbd>F1</kbd> and select **Dev Containers: Clone Repository in Container Volume...**.
|
||||
|
||||
> **Tip:** While you can use your local source tree instead, operations like `yarn install` can be slow on macOS or when using the Hyper-V engine on Windows. We recommend using the WSL filesystem on Windows or the "clone repository in container" approach on Windows and macOS instead since it uses "named volume" rather than the local filesystem.
|
||||
|
||||
5. Type `https://github.com/openimsdk/open-im-server` (or a branch or PR URL) in the input box and press <kbd>Enter</kbd>.
|
||||
|
||||
6. After the container is running:
|
||||
1. If you have the `DISPLAY` or `WAYLAND_DISPLAY` environment variables set locally (or in WSL on Windows), desktop apps in the container will be shown in local windows.
|
||||
2. If these are not set, open a web browser and go to [http://localhost:11001](http://localhost:11001), or use a [VNC Viewer][def] to connect to `localhost:11001` and enter `vscode` as the password. Anything you start in VS Code, or the integrated terminal, will appear here.
|
||||
|
||||
Next: **[Try it out!](#try-it)**
|
||||
|
||||
## Quick start - GitHub Codespaces
|
||||
|
||||
1. From the [openimsdk/open-im-server GitHub repository](https://github.com/openimsdk/open-im-server), click on the **Code** dropdown, select **Open with Codespaces**, and then click on **New codespace**. If prompted, select the **Standard** machine size (which is also the default).
|
||||
|
||||
> **Note:** You will not see these options within GitHub if you are not in the Codespaces beta.
|
||||
|
||||
2. After the codespace is up and running in your browser, press <kbd>Ctrl/Cmd</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd> or <kbd>F1</kbd> and select **Ports: Focus on Ports View**.
|
||||
|
||||
3. You should see **VNC web client (11001)** under in the list of ports. Select the line and click on the globe icon to open it in a browser tab.
|
||||
|
||||
> **Tip:** If you do not see the port, <kbd>Ctrl/Cmd</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd> or <kbd>F1</kbd>, select **Forward a Port** and enter port `11001`.
|
||||
|
||||
4. In the new tab, you should see noVNC. Click **Connect** and enter `vscode` as the password.
|
||||
|
||||
Anything you start in VS Code, or the integrated terminal, will appear here.
|
||||
|
||||
Next: **[Try it out!](#try-it)**
|
||||
|
||||
### Using VS Code with GitHub Codespaces
|
||||
|
||||
You may see improved VNC responsiveness when accessing a codespace from VS Code client since you can use a [VNC Viewer][def]. Here's how to do it.
|
||||
|
||||
1. Install [Visual Studio Code Stable](https://code.visualstudio.com/) or [Insiders](https://code.visualstudio.com/insiders/) and the the [GitHub Codespaces extension](https://marketplace.visualstudio.com/items?itemName=GitHub.codespaces).
|
||||
|
||||
> **Note:** The GitHub Codespaces extension requires the Visual Studio Code distribution of OpenIM - OSS.
|
||||
|
||||
2. After the VS Code is up and running, press <kbd>Ctrl/Cmd</kbd> + <kbd>Shift</kbd> + <kbd>P</kbd> or <kbd>F1</kbd>, choose **Codespaces: Create New Codespace**, and use the following settings:
|
||||
|
||||
- `openimsdk/open-im-server` for the repository.
|
||||
- Select any branch (e.g. **main**) - you can select a different one later.
|
||||
- Choose **Standard** (4-core, 8GB) as the size.
|
||||
|
||||
3. After you have connected to the codespace, you can use a [VNC Viewer][def] to connect to `localhost:5901` and enter `vscode` as the password.
|
||||
|
||||
> **Tip:** You may also need change your VNC client's **Picture Quality** setting to **High** to get a full color desktop.
|
||||
|
||||
4. Anything you start in VS Code, or the integrated terminal, will appear here.
|
||||
|
||||
Next: **[Try it out!](#try-it)**
|
||||
|
||||
## Try it
|
||||
|
||||
This container uses the [Fluxbox](http://fluxbox.org/) window manager to keep things lean. **Right-click on the desktop** to see menu options. It works with GNOME and GTK applications, so other tools can be installed if needed.
|
||||
|
||||
> **Note:** You can also set the resolution from the command line by typing `set-resolution`.
|
||||
|
||||
To start working with OpenIM - OSS, follow these steps:
|
||||
|
||||
1. In your local VS Code client, open a terminal (<kbd>Ctrl/Cmd</kbd> + <kbd>Shift</kbd> + <kbd>\`</kbd>) and type the following commands:
|
||||
|
||||
```bash
|
||||
yarn install
|
||||
bash scripts/code.sh
|
||||
```
|
||||
|
||||
2. After the build is complete, open a web browser or a [VNC Viewer][def] to connect to the desktop environment as described in the quick start and enter `vscode` as the password.
|
||||
|
||||
3. You should now see OpenIM - OSS!
|
||||
|
||||
Next, let's try debugging.
|
||||
|
||||
1. Shut down OpenIM - OSS by clicking the box in the upper right corner of the OpenIM - OSS window through your browser or VNC viewer.
|
||||
|
||||
2. Go to your local VS Code client, and use the **Run / Debug** view to launch the **VS Code** configuration. (Typically the default, so you can likely just press <kbd>F5</kbd>).
|
||||
|
||||
> **Note:** If launching times out, you can increase the value of `timeout` in the "VS Code", "Attach Main Process", "Attach Extension Host", and "Attach to Shared Process" configurations in [launch.json](../../.vscode/launch.json). However, running `./scripts/code.sh` first will set up Electron which will usually solve timeout issues.
|
||||
|
||||
3. After a bit, OpenIM - OSS will appear with the debugger attached!
|
||||
|
||||
Enjoy!
|
||||
|
||||
|
||||
### Dotfiles
|
||||
|
||||
Dotfiles are files and folders on Unix-like systems starting with `.` that control the configuration of applications and shells on your system. You can store and manage your dotfiles in a repository on GitHub. For advice and tutorials about what to include in your dotfiles repository, see [GitHub does dotfiles](https://dotfiles.github.io/).
|
||||
|
||||
Your dotfiles repository might include your shell aliases and preferences, any tools you want to install, or any other codespace personalization you want to make.
|
||||
|
||||
You can configure GitHub Codespaces to use dotfiles from any repository you own by selecting that repository in your [personal GitHub Codespaces settings](https://github.com/settings/codespaces).
|
||||
|
||||
When you create a new codespace, GitHub clones your selected dotfiles repository to the codespace environment, and looks for one of the following files to set up the environment.
|
||||
|
||||
- *install.sh*
|
||||
- *install*
|
||||
- *bootstrap.sh*
|
||||
- *bootstrap*
|
||||
- *script/bootstrap*
|
||||
- *setup.sh*
|
||||
- *setup*
|
||||
- *script/setup*
|
||||
|
||||
If none of these files are found, then any files or folders in your selected dotfiles repository starting with `.` are symlinked to the codespace's `~` or `$HOME` directory.
|
||||
|
||||
Any changes to your selected dotfiles repository will apply only to each new codespace, and do not affect any existing codespace.
|
||||
|
||||
**Note:** Currently, Codespaces does not support personalizing the User-scoped settings for VS Code with your `dotfiles` repository. You can set default Workspace and Remote [Codespaces] settings for a specific project in the project's repository. For more information, see "[Introduction to dev containers](https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/adding-a-dev-container-configuration/introduction-to-dev-containers#creating-a-custom-dev-container-configuration)."
|
||||
|
||||
In addition, you can also configure Codespaces secrets on your personal profile page at [github.com/settings/codespaces](https://github.com/settings/codespaces). Development environment secrets are environment variables that are encrypted, and they are accessible to any codespace you create using repositories that have access to these secrets.
|
||||
|
||||
### Notes
|
||||
|
||||
The container comes with VS Code Insiders installed. To run it from an Integrated Terminal use `VSCODE_IPC_HOOK_CLI= /usr/bin/code-insiders .`.
|
||||
|
||||
[def]: https://www.realvnc.com/en/connect/download/viewer/
|
@ -0,0 +1,83 @@
|
||||
{
|
||||
// Reference Doc: https://code.visualstudio.com/remote/advancedcontainers/overview
|
||||
"name": "OpenIM Dev Environment",
|
||||
// Update the container version when you publish dev-container
|
||||
"dockerComposeFile": "docker-compose.yml",
|
||||
"build": { "dockerfile": "Dockerfile" },
|
||||
// Replace with uncommented line below to build your own local copy of the image
|
||||
// "dockerFile": "../docker/Dockerfile-dev",
|
||||
"containerEnv": {
|
||||
// Uncomment to overwrite devcontainer .kube/config and .minikube certs with the localhost versions
|
||||
// each time the devcontainer starts, if the respective .kube-localhost/config and .minikube-localhost
|
||||
// folders respectively are bind mounted to the devcontainer.
|
||||
// "SYNC_LOCALHOST_KUBECONFIG": "true"
|
||||
|
||||
// Uncomment to disable docker-in-docker and automatically proxy default /var/run/docker.sock to
|
||||
// the localhost bind-mount /var/run/docker-host.sock.
|
||||
// "BIND_LOCALHOST_DOCKER": "true"
|
||||
},
|
||||
"remoteEnv": {
|
||||
"GO111MODULE": "on",
|
||||
"GOPROXY": "https://goproxy.cn",
|
||||
"GOSUMDB": "sum.golang.org",
|
||||
"GONOPROXY": "github.com/openimsdk",
|
||||
"GONOSUMDB": "github.com/openimsdk",
|
||||
"GOPRIVATE": "github.com/openimsdk"
|
||||
},
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"extensions": [
|
||||
"davidanson.vscode-markdownlint",
|
||||
"golang.go",
|
||||
"ms-azuretools.vscode-dapr",
|
||||
"ms-azuretools.vscode-docker",
|
||||
"ms-kubernetes-tools.vscode-kubernetes-tools"
|
||||
],
|
||||
"settings": {
|
||||
"go.toolsManagement.checkForUpdates": "local",
|
||||
"go.useLanguageServer": true,
|
||||
"go.gopath": "/go"
|
||||
}
|
||||
}
|
||||
},
|
||||
"mounts": [
|
||||
// Mount docker-in-docker library volume
|
||||
"type=volume,source=dind-var-lib-docker,target=/var/lib/docker",
|
||||
|
||||
// Bind mount docker socket under an alias to support docker-from-docker
|
||||
"type=bind,source=/var/run/docker.sock,target=/var/run/docker-host.sock",
|
||||
|
||||
// Bind mount docker socket under an alias to support docker-from-docker
|
||||
// "type=bind,source=${env:HOME}${env:USERPROFILE}/.minikube/cache,target=/home/openim/.minikube/cache",
|
||||
|
||||
// Uncomment to clone local .kube/config into devcontainer
|
||||
"type=bind,source=${env:HOME}${env:USERPROFILE}/.kube,target=/home/openim/.kube-localhost"
|
||||
|
||||
// Uncomment to additionally clone minikube certs into devcontainer for use with .kube/config
|
||||
// "type=bind,source=${env:HOME}${env:USERPROFILE}/.minikube,target=/home/openim/.minikube-localhost"
|
||||
],
|
||||
// Always run image-defined default command
|
||||
"overrideCommand": false,
|
||||
// On Linux, this will prevent new files getting created as root, but you
|
||||
// may need to update the USER_UID and USER_GID in docker/Dockerfile-dev
|
||||
// to match your user if not 1000.
|
||||
// "remoteUser": "openimsdk",
|
||||
"runArgs": [
|
||||
// Enable ptrace-based debugging for go
|
||||
"--cap-add=SYS_PTRACE",
|
||||
"--security-opt",
|
||||
"seccomp=unconfined",
|
||||
|
||||
// Uncomment to bind to host network for local devcontainer; this is necessary if using the
|
||||
// bind-mounted /var/run/docker-host.sock directly.
|
||||
"--net=host",
|
||||
|
||||
// Enable docker-in-docker configuration. Comment out if not using for better security.
|
||||
"--privileged",
|
||||
|
||||
// Run the entrypoint defined in container image.
|
||||
"--init"
|
||||
],
|
||||
"workspaceFolder": "/workspaces/openim",
|
||||
"workspaceMount": "type=bind,source=${localWorkspaceFolder},target=/workspaces/openim"
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
# Version logging for OpenIM
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_TOC -->
|
||||
|
||||
<!-- END MUNGE: GENERATED_TOC -->
|
||||
|
||||
<a name="unreleased"></a>
|
||||
## [Unreleased]
|
||||
|
||||
|
||||
<a name="v3.4.2"></a>
|
||||
## [v3.4.2] - 2023-12-14
|
||||
|
||||
<a name="v3.4.0"></a>
|
||||
## [v3.4.0] - 2023-11-10
|
||||
|
||||
<a name="v3.4.0-rc.1"></a>
|
||||
## [v3.4.0-rc.1] - 2023-11-09
|
||||
|
||||
<a name="v3.4.0-rc.0"></a>
|
||||
## v3.4.0-rc.0 - 2023-11-09
|
||||
### Reverts
|
||||
- update etcd to v3.5.2 ([#206](https://github.com/openimsdk/open-im-server/issues/206))
|
||||
|
||||
### Pull Requests
|
||||
- Merge branch 'tuoyun'
|
||||
|
||||
|
||||
[Unreleased]: https://github.com/openimsdk/open-im-server/compare/v3.4.2...HEAD
|
||||
[v3.4.2]: https://github.com/openimsdk/open-im-server/compare/v3.4.0...v3.4.2
|
||||
[v3.4.0]: https://github.com/openimsdk/open-im-server/compare/v3.4.0-rc.1...v3.4.0
|
||||
[v3.4.0-rc.1]: https://github.com/openimsdk/open-im-server/compare/v3.4.0-rc.0...v3.4.0-rc.1
|
@ -0,0 +1,15 @@
|
||||
# Version logging for OpenIM
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_TOC -->
|
||||
|
||||
<!-- END MUNGE: GENERATED_TOC -->
|
||||
|
||||
<a name="unreleased"></a>
|
||||
## [Unreleased]
|
||||
|
||||
|
||||
<a name="v3.5.0+3.97baaac"></a>
|
||||
## [v3.5.0+3.97baaac] - 2024-01-12
|
||||
|
||||
[Unreleased]: https://github.com/openimsdk/open-im-server/compare/v3.5.0+3.97baaac...HEAD
|
||||
[v3.5.0+3.97baaac]: https://github.com/openimsdk/open-im-server/compare/v3.5.0+5.950e970...v3.5.0+3.97baaac
|
@ -0,0 +1,76 @@
|
||||
# Version logging for OpenIM
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_TOC -->
|
||||
|
||||
<!-- END MUNGE: GENERATED_TOC -->
|
||||
|
||||
<a name="unreleased"></a>
|
||||
## [Unreleased]
|
||||
|
||||
|
||||
<a name="v3.5.1-alpha.1"></a>
|
||||
## [v3.5.1-alpha.1] - 2024-01-09
|
||||
|
||||
<a name="v3.5.0"></a>
|
||||
## [v3.5.0] - 2024-01-02
|
||||
|
||||
<a name="v3.5.1"></a>
|
||||
## [v3.5.1] - 2024-01-02
|
||||
|
||||
<a name="v3.5.1-bate.1"></a>
|
||||
## [v3.5.1-bate.1] - 2024-01-02
|
||||
|
||||
<a name="v3.5.1-rc.0"></a>
|
||||
## [v3.5.1-rc.0] - 2023-12-30
|
||||
|
||||
<a name="v3.5.0-rc.8"></a>
|
||||
## [v3.5.0-rc.8] - 2023-12-28
|
||||
|
||||
<a name="v3.5.0-rc.7"></a>
|
||||
## [v3.5.0-rc.7] - 2023-12-18
|
||||
|
||||
<a name="v3.5.0-rc.6"></a>
|
||||
## [v3.5.0-rc.6] - 2023-12-15
|
||||
|
||||
<a name="v3.5.0-rc.5"></a>
|
||||
## [v3.5.0-rc.5] - 2023-12-15
|
||||
|
||||
<a name="v3.5.0-rc.4"></a>
|
||||
## [v3.5.0-rc.4] - 2023-12-14
|
||||
|
||||
<a name="v3.5.0-rc.3"></a>
|
||||
## [v3.5.0-rc.3] - 2023-12-14
|
||||
|
||||
<a name="v3.5.0-rc.2"></a>
|
||||
## [v3.5.0-rc.2] - 2023-12-14
|
||||
|
||||
<a name="v3.5.0-rc.1"></a>
|
||||
## [v3.5.0-rc.1] - 2023-12-14
|
||||
|
||||
<a name="v3.5.0-rc.0"></a>
|
||||
## [v3.5.0-rc.0] - 2023-12-14
|
||||
|
||||
<a name="v3.5.0-beta.1"></a>
|
||||
## v3.5.0-beta.1 - 2023-11-29
|
||||
### Reverts
|
||||
- update etcd to v3.5.2 ([#206](https://github.com/openimsdk/open-im-server/issues/206))
|
||||
|
||||
### Pull Requests
|
||||
- Merge branch 'tuoyun'
|
||||
|
||||
|
||||
[Unreleased]: https://github.com/openimsdk/open-im-server/compare/v3.5.1-alpha.1...HEAD
|
||||
[v3.5.1-alpha.1]: https://github.com/openimsdk/open-im-server/compare/v3.5.0...v3.5.1-alpha.1
|
||||
[v3.5.0]: https://github.com/openimsdk/open-im-server/compare/v3.5.1...v3.5.0
|
||||
[v3.5.1]: https://github.com/openimsdk/open-im-server/compare/v3.5.1-bate.1...v3.5.1
|
||||
[v3.5.1-bate.1]: https://github.com/openimsdk/open-im-server/compare/v3.5.1-rc.0...v3.5.1-bate.1
|
||||
[v3.5.1-rc.0]: https://github.com/openimsdk/open-im-server/compare/v3.5.0-rc.8...v3.5.1-rc.0
|
||||
[v3.5.0-rc.8]: https://github.com/openimsdk/open-im-server/compare/v3.5.0-rc.7...v3.5.0-rc.8
|
||||
[v3.5.0-rc.7]: https://github.com/openimsdk/open-im-server/compare/v3.5.0-rc.6...v3.5.0-rc.7
|
||||
[v3.5.0-rc.6]: https://github.com/openimsdk/open-im-server/compare/v3.5.0-rc.5...v3.5.0-rc.6
|
||||
[v3.5.0-rc.5]: https://github.com/openimsdk/open-im-server/compare/v3.5.0-rc.4...v3.5.0-rc.5
|
||||
[v3.5.0-rc.4]: https://github.com/openimsdk/open-im-server/compare/v3.5.0-rc.3...v3.5.0-rc.4
|
||||
[v3.5.0-rc.3]: https://github.com/openimsdk/open-im-server/compare/v3.5.0-rc.2...v3.5.0-rc.3
|
||||
[v3.5.0-rc.2]: https://github.com/openimsdk/open-im-server/compare/v3.5.0-rc.1...v3.5.0-rc.2
|
||||
[v3.5.0-rc.1]: https://github.com/openimsdk/open-im-server/compare/v3.5.0-rc.0...v3.5.0-rc.1
|
||||
[v3.5.0-rc.0]: https://github.com/openimsdk/open-im-server/compare/v3.5.0-beta.1...v3.5.0-rc.0
|
@ -0,0 +1,149 @@
|
||||
# Mac Developer Deployment Guide for OpenIM
|
||||
|
||||
## Introduction
|
||||
|
||||
This guide aims to assist Mac-based developers in contributing effectively to OpenIM. It covers the setup of a development environment tailored for Mac, including the use of GitHub for development workflow and `devcontainer` for a consistent development experience.
|
||||
|
||||
Before contributing to OpenIM through issues and pull requests, make sure you are familiar with GitHub and the [pull request workflow](https://docs.github.com/en/get-started/quickstart/github-flow).
|
||||
|
||||
## Prerequisites
|
||||
|
||||
### System Requirements
|
||||
|
||||
- macOS (latest stable version recommended)
|
||||
- Internet connection
|
||||
- Administrator access
|
||||
|
||||
### Knowledge Requirements
|
||||
|
||||
- Basic understanding of Git and GitHub
|
||||
- Familiarity with Docker and containerization
|
||||
- Experience with Go programming language
|
||||
|
||||
## Setting up the Development Environment
|
||||
|
||||
### Installing Homebrew
|
||||
|
||||
Homebrew is an essential package manager for macOS. Install it using:
|
||||
|
||||
```sh
|
||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||
```
|
||||
|
||||
### Installing and Configuring Git
|
||||
|
||||
1. Install Git:
|
||||
|
||||
```sh
|
||||
brew install git
|
||||
```
|
||||
|
||||
2. Configure Git with your user details:
|
||||
|
||||
```sh
|
||||
git config --global user.name "Your Name"
|
||||
git config --global user.email "your.email@example.com"
|
||||
```
|
||||
|
||||
### Forking and Cloning the Repository
|
||||
|
||||
1. Fork the OpenIM repository on GitHub to your account.
|
||||
2. Clone your fork to your local machine:
|
||||
|
||||
```sh
|
||||
git clone https://github.com/<your-username>/open-im-server.git
|
||||
# The Docker bridging network mode for Mac is slightly different and needs to be set:
|
||||
export DOCKER_BRIDGE_SUBNET=127.0.0.0/16
|
||||
# Set OpenIM IP
|
||||
export OPENIM_IP=<your-ip>
|
||||
# Init Config
|
||||
make init
|
||||
|
||||
# Start Components
|
||||
docker compose up -d
|
||||
|
||||
# Start OpenIM Server
|
||||
make start
|
||||
```
|
||||
|
||||
### Setting Up the Devcontainer
|
||||
|
||||
`Devcontainers` provide a Docker-based isolated development environment.
|
||||
|
||||
Read [README.md](https://github.com/openimsdk/open-im-server/tree/main/.devcontainer) in the `.devcontainer` directory of the project to learn more about the devcontainer.
|
||||
|
||||
To set it up:
|
||||
|
||||
1. Install Docker Desktop for Mac from [Docker Hub](https://docs.docker.com/desktop/install/mac-install/).
|
||||
2. Install Visual Studio Code and the Remote - Containers extension.
|
||||
3. Open the cloned OpenIM repository in VS Code.
|
||||
4. VS Code will prompt to reopen the project in a container. Accept this to set up the environment automatically.
|
||||
|
||||
### Installing Go and Dependencies
|
||||
|
||||
Use Homebrew to install Go:
|
||||
|
||||
```sh
|
||||
brew install go
|
||||
```
|
||||
|
||||
Ensure the version of Go is compatible with the version required by OpenIM (refer to the main documentation for version requirements).
|
||||
|
||||
### Additional Tools
|
||||
|
||||
Install other required tools like Docker, Vagrant, and necessary GNU utils as described in the main documentation.
|
||||
|
||||
## GitHub Development Workflow
|
||||
|
||||
### Creating a New Branch
|
||||
|
||||
For new features or fixes, create a new branch:
|
||||
|
||||
```sh
|
||||
git checkout -b feat/your-feature-name
|
||||
```
|
||||
|
||||
### Making Changes and Committing
|
||||
|
||||
1. Make your changes in the code.
|
||||
2. Stage your changes:
|
||||
|
||||
```sh
|
||||
git add .
|
||||
```
|
||||
|
||||
3. Commit with a meaningful message:
|
||||
|
||||
```sh
|
||||
git commit -m "Add a brief description of your changes"
|
||||
```
|
||||
|
||||
### Pushing Changes and Creating Pull Requests
|
||||
|
||||
1. Push your branch to GitHub:
|
||||
|
||||
```sh
|
||||
git push origin feat/your-feature-name
|
||||
```
|
||||
|
||||
2. Go to your fork on GitHub and create a pull request to the main OpenIM repository.
|
||||
|
||||
### Keeping Your Fork Updated
|
||||
|
||||
Regularly sync your fork with the main repository:
|
||||
|
||||
```sh
|
||||
git fetch upstream
|
||||
git checkout main
|
||||
git rebase upstream/main
|
||||
```
|
||||
|
||||
More read: [https://github.com/openimsdk/open-im-server/blob/main/CONTRIBUTING.md](https://github.com/openimsdk/open-im-server/blob/main/CONTRIBUTING.md)
|
||||
|
||||
## Testing and Quality Assurance
|
||||
|
||||
Run tests as described in the OpenIM documentation to ensure your changes do not break existing functionality.
|
||||
|
||||
## Conclusion
|
||||
|
||||
This guide provides a comprehensive overview for Mac developers to set up and contribute to OpenIM. By following these steps, you can ensure a smooth and efficient development experience. Happy coding!
|
@ -0,0 +1,251 @@
|
||||
# OpenIM Release Automation Design Document
|
||||
|
||||
This document outlines the automation process for releasing OpenIM. You can use the `make release` command for automated publishing. We will discuss how to use the `make release` command and Github Actions CICD separately, while also providing insight into the design principles involved.
|
||||
|
||||
## Github Actions Automation
|
||||
|
||||
In our CICD pipeline, we have implemented logic for automating the release process using the goreleaser tool. To achieve this, follow these steps on your local machine or server:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/openimsdk/open-im-server
|
||||
cd open-im-server
|
||||
git tag -a v3.6.0 -s -m "release: xxx"
|
||||
# For pre-release versions: git tag -a v3.6.0-rc.0 -s -m "pre-release: xxx"
|
||||
git push origin v3.6.0
|
||||
```
|
||||
|
||||
The remaining tasks are handled by automated processes:
|
||||
|
||||
+ Automatically complete the release publication on Github
|
||||
+ Automatically build the `v3.6.0` version image and push it to aliyun, dockerhub, and github
|
||||
|
||||
Through these automated steps, we achieve rapid and efficient OpenIM version releases, simplifying the release process and enhancing productivity.
|
||||
|
||||
|
||||
Certainly, here is the continuation of the document in English:
|
||||
|
||||
## Local Make Release Design
|
||||
|
||||
There are two primary scenarios for local usage:
|
||||
|
||||
+ Advanced compilation and release, manually executed locally
|
||||
+ Quick compilation verification and version release, manually executed locally
|
||||
|
||||
**These two scenarios can also be combined, for example, by tagging locally and then releasing:**
|
||||
|
||||
```bash
|
||||
git add .
|
||||
git commit -a -s -m "release(v3.6.0): ......"
|
||||
git tag v3.6.0
|
||||
git release
|
||||
git push origin main
|
||||
```
|
||||
|
||||
In a local environment, you can use the `make release` command to complete the release process. The main implementation logic can be found in the `/data/workspaces/open-im-server/scripts/lib/release.sh` file. First, let's explore its usage through the help information.
|
||||
|
||||
### Help Information
|
||||
|
||||
To view the help information, execute the following command:
|
||||
|
||||
```bash
|
||||
$ ./scripts/release.sh --help
|
||||
Usage: release.sh [options]
|
||||
Options:
|
||||
-h, --help Display this help message
|
||||
-se, --setup-env Execute environment setup
|
||||
-vp, --verify-prereqs Execute prerequisite verification
|
||||
-bc, --build-command Execute build command
|
||||
-bi, --build-image Execute build image (default is not executed)
|
||||
-pt, --package-tarballs Execute tarball packaging
|
||||
-ut, --upload-tarballs Execute tarball upload
|
||||
-gr, --github-release Execute GitHub release
|
||||
-gc, --generate-changelog Execute changelog generation
|
||||
```
|
||||
|
||||
### Default Behavior
|
||||
|
||||
If no options are provided, all operations are executed by default:
|
||||
|
||||
```bash
|
||||
# If no options are provided, enable all operations by default
|
||||
if [ "$#" -eq 0 ]; then
|
||||
perform_setup_env=true
|
||||
perform_verify_prereqs=true
|
||||
perform_build_command=true
|
||||
perform_package_tarballs=true
|
||||
perform_upload_tarballs=true
|
||||
perform_github_release=true
|
||||
perform_generate_changelog=true
|
||||
# TODO: Defaultly not enable build_image
|
||||
# perform_build_image=true
|
||||
fi
|
||||
```
|
||||
|
||||
### Environment Variable Setup
|
||||
|
||||
Before starting, you need to set environment variables:
|
||||
|
||||
```bash
|
||||
export TENCENT_SECRET_KEY=OZZ****************************
|
||||
export TENCENT_SECRET_ID=AKI****************************
|
||||
```
|
||||
|
||||
### Modifying COS Account and Password
|
||||
|
||||
If you need to change the COS account, password, and bucket information, please modify the following section in the `/data/workspaces/open-im-server/scripts/lib/release.sh` file:
|
||||
|
||||
```bash
|
||||
readonly BUCKET="openim-1306374445"
|
||||
readonly REGION="ap-guangzhou"
|
||||
readonly COS_RELEASE_DIR="openim-release"
|
||||
```
|
||||
|
||||
### GitHub Release Configuration
|
||||
|
||||
If you intend to use the GitHub Release feature, you also need to set the environment variable:
|
||||
|
||||
```bash
|
||||
export GITHUB_TOKEN="your_github_token"
|
||||
```
|
||||
|
||||
### Modifying GitHub Release Basic Information
|
||||
|
||||
If you need to modify the basic information of GitHub Release, please edit the following section in the `/data/workspaces/open-im-server/scripts/lib/release.sh` file:
|
||||
|
||||
```bash
|
||||
# OpenIM GitHub account information
|
||||
readonly OPENIM_GITHUB_ORG=openimsdk
|
||||
readonly OPENIM_GITHUB_REPO=open-im-server
|
||||
```
|
||||
|
||||
This setup allows you to configure and execute the local release process according to your specific needs.
|
||||
|
||||
|
||||
### GitHub Release Versioning Rules
|
||||
|
||||
Firstly, it's important to note that GitHub Releases should primarily be for pre-release versions. However, goreleaser might provide a `prerelease: auto` option, which automatically marks versions with pre-release indicators like `-rc1`, `-beta`, etc., as pre-releases.
|
||||
|
||||
So, if your most recent tag does not have pre-release indicators such as `-rc1` or `-beta`, even if you use `make release` for pre-release versions, goreleaser might still consider them as formal releases.
|
||||
|
||||
To avoid this issue, I have added the `--draft` flag to github-release. This way, all releases are created as drafts.
|
||||
|
||||
## CICD Release Documentation Design
|
||||
|
||||
The release records still require manual composition for GitHub Release. This is different from github-release.
|
||||
|
||||
This approach ensures that all releases are initially created as drafts, allowing you to manually review and edit the release documentation on GitHub. This manual step provides more control and allows you to curate release notes and other information before making them public.
|
||||
|
||||
|
||||
## Makefile Section
|
||||
|
||||
This document aims to elaborate and explain key sections of the OpenIM Release automation design, including the Makefile section and functions within the code. Below, we will provide a detailed explanation of the logic and functions of each section.
|
||||
|
||||
In the project's root directory, the Makefile imports a subdirectory:
|
||||
|
||||
```makefile
|
||||
include scripts/make-rules/release.mk
|
||||
```
|
||||
|
||||
And defines the `release` target as follows:
|
||||
|
||||
```makefile
|
||||
## release: release the project ✨
|
||||
.PHONY: release release: release.verify release.ensure-tag
|
||||
@scripts/release.sh
|
||||
```
|
||||
|
||||
### Importing Subdirectory
|
||||
|
||||
At the beginning of the Makefile, the `include scripts/make-rules/release.mk` statement imports the `release.mk` file from the subdirectory. This file contains rules and configurations related to releases to be used in subsequent operations.
|
||||
|
||||
### The `release` Target
|
||||
|
||||
The Makefile defines a target named `release`, which is used to execute the project's release operation. This target is marked as a phony target (`.PHONY`), meaning it doesn't represent an actual file or directory but serves as an identifier for executing a series of actions.
|
||||
|
||||
In the `release` target, two dependency targets are executed first: `release.verify` and `release.ensure-tag`. Afterward, the `scripts/release.sh` script is called to perform the actual release operation.
|
||||
|
||||
## Logic of `release.verify` and `release.ensure-tag`
|
||||
|
||||
```makefile
|
||||
## release.verify: Check if a tool is installed and install it
|
||||
.PHONY: release.verify
|
||||
release.verify: tools.verify.git-chglog tools.verify.github-release tools.verify.coscmd tools.verify.coscli
|
||||
|
||||
## release.ensure-tag: ensure tag
|
||||
.PHONY: release.ensure-tag
|
||||
release.ensure-tag: tools.verify.gsemver
|
||||
@scripts/ensure-tag.sh
|
||||
```
|
||||
|
||||
### `release.verify` Target
|
||||
|
||||
The `release.verify` target is used to check and install tools. It depends on four sub-targets: `tools.verify.git-chglog`, `tools.verify.github-release`, `tools.verify.coscmd`, and `tools.verify.coscli`. These sub-targets aim to check if specific tools are installed and attempt to install them if they are not.
|
||||
|
||||
The purpose of this target is to ensure that the necessary tools required for the release process are available so that subsequent operations can be executed smoothly.
|
||||
|
||||
### `release.ensure-tag` Target
|
||||
|
||||
The `release.ensure-tag` target is used to ensure that the project has a version tag. It depends on the sub-target `tools.verify.gsemver`, indicating that it should check if the `gsemver` tool is installed before executing.
|
||||
|
||||
When the `release.ensure-tag` target is executed, it calls the `scripts/ensure-tag.sh` script to ensure that the project has a version tag. Version tags are typically used to identify specific versions of the project for management and release in version control systems.
|
||||
|
||||
## Logic of `release.sh` Script
|
||||
|
||||
```bash
|
||||
openim::golang::setup_env
|
||||
openim::build::verify_prereqs
|
||||
openim::release::verify_prereqs
|
||||
#openim::build::build_image
|
||||
openim::build::build_command
|
||||
openim::release::package_tarballs
|
||||
openim::release::upload_tarballs
|
||||
git push origin ${VERSION}
|
||||
#openim::release::github_release
|
||||
#openim::release::generate_changelog
|
||||
```
|
||||
|
||||
The `release.sh` script is responsible for executing the actual release operations. Below is the logic of this script:
|
||||
|
||||
1. `openim::golang::setup_env`: This function sets up some configurations for the Golang development environment.
|
||||
|
||||
2. `openim::build::verify_prereqs`: This function is used to verify whether the prerequisites for building are met. This includes checking dependencies, environment variables, and more.
|
||||
|
||||
3. `openim::release::verify_prereqs`: Similar to the previous function, this one is used to verify whether the prerequisites for the release are met. It focuses on conditions relevant to the release.
|
||||
|
||||
4. `openim::build::build_command`: This function is responsible for building the project's command, which typically involves compiling the project or performing other build operations.
|
||||
|
||||
5. `openim::release::package_tarballs`: This function is used to package tarball files required for the release. These tarballs are usually used for distribution packages during the release.
|
||||
|
||||
6. `openim::release::upload_tarballs`: This function is used to upload the packaged tarball files, typically to a distribution platform or repository.
|
||||
|
||||
7. `git push origin ${VERSION}`: This line of command pushes the version tag to the remote Git repository's `origin` branch, marking this release in the version control system.
|
||||
|
||||
In the comments, you can see that there are some operations that are commented out, such as `openim::build::build_image`, `openim::release::github_release`, and `openim::release::generate_changelog`. These operations are related to building images, releasing to GitHub, and generating changelogs, and they can be enabled in the release process as needed.
|
||||
|
||||
Let's take a closer look at the function responsible for packaging the tarball files:
|
||||
|
||||
```bash
|
||||
function openim::release::package_tarballs() {
|
||||
# Clean out any old releases
|
||||
rm -rf "${RELEASE_STAGE}" "${RELEASE_TARS}" "${RELEASE_IMAGES}"
|
||||
mkdir -p "${RELEASE_TARS}"
|
||||
openim::release::package_src_tarball &
|
||||
openim::release::package_client_tarballs &
|
||||
openim::release::package_openim_manifests_tarball &
|
||||
openim::release::package_server_tarballs &
|
||||
openim::util::wait-for-jobs || { openim::log::error "previous tarball phase failed"; return 1; }
|
||||
|
||||
openim::release::package_final_tarball & # _final depends on some of the previous phases
|
||||
openim::util::wait-for-jobs || { openim::log::error "previous tarball phase failed"; return 1; }
|
||||
}
|
||||
```
|
||||
|
||||
The `openim::release::package_tarballs()` function is responsible for packaging the tarball files required for the release. Here is the specific logic of this function:
|
||||
|
||||
1. `rm -rf "${RELEASE_STAGE}" "${RELEASE_TARS}" "${RELEASE_IMAGES}"`: First, the function removes any old release directories and files to ensure a clean starting state.
|
||||
|
||||
2. `mkdir -p "${RELEASE_TARS}"`: Next, it creates a directory `${RELEASE_TARS}` to store the packaged tarball files. If the directory doesn't exist, it will be created.
|
||||
|
||||
3. `openim::release::package_final_tarball &`: This is an asynchronous operation that depends on some of the previous phases. It is likely used to package the final tarball file, which includes the contents of all previous asynchronous operations.
|
||||
|
||||
4. `openim::util::wait-for-jobs`: It waits for all asynchronous operations to complete. If any of the previous asynchronous operations fail, an error will be returned.
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,102 @@
|
||||
# Development of a Go-Based Conformity Checker for Project File and Directory Naming Standards
|
||||
|
||||
### 1. Project Overview
|
||||
|
||||
#### Project Name
|
||||
|
||||
- `GoConformityChecker`
|
||||
|
||||
#### Functionality Description
|
||||
|
||||
- Checks if the file and subdirectory names in a specified directory adhere to specific naming conventions.
|
||||
- Supports specific file types (e.g., `.go`, `.yml`, `.yaml`, `.md`, `.sh`, etc.).
|
||||
- Allows users to specify directories to be checked and directories to be ignored.
|
||||
- More read https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/code-conventions.md
|
||||
|
||||
#### Naming Conventions
|
||||
|
||||
- Go files: Only underscores are allowed.
|
||||
- YAML, YML, and Markdown files: Only hyphens are allowed.
|
||||
- Directories: Only underscores are allowed.
|
||||
|
||||
### 2. File Structure
|
||||
|
||||
- `main.go`: Entry point of the program, handles command-line arguments.
|
||||
- `checker/checker.go`: Contains the core logic.
|
||||
- `config/config.go`: Parses and stores configuration information.
|
||||
|
||||
### 3. Core Code Design
|
||||
|
||||
#### main.go
|
||||
|
||||
- Parses command-line arguments, including the directory to be checked and directories to be ignored.
|
||||
- Calls the `checker` module for checking.
|
||||
|
||||
#### config.go
|
||||
|
||||
- Defines a configuration structure, such as directories to check and ignore.
|
||||
|
||||
#### checker.go
|
||||
|
||||
- Iterates through the specified directory.
|
||||
- Applies different naming rules based on file types and directory names.
|
||||
- Records files or directories that do not conform to the standards.
|
||||
|
||||
### 4. Pseudocode Example
|
||||
|
||||
#### main.go
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"GoConformityChecker/checker"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Parse command-line arguments
|
||||
var targetDir string
|
||||
var ignoreDirs string
|
||||
flag.StringVar(&targetDir, "target", ".", "Directory to check")
|
||||
flag.StringVar(&ignoreDirs, "ignore", "", "Directories to ignore")
|
||||
flag.Parse()
|
||||
|
||||
// Call the checker
|
||||
err := checker.CheckDirectory(targetDir, ignoreDirs)
|
||||
if err != nil {
|
||||
fmt.Println("Error:", err)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### checker.go
|
||||
|
||||
```go
|
||||
package checker
|
||||
|
||||
import (
|
||||
// Import necessary packages
|
||||
)
|
||||
|
||||
func CheckDirectory(targetDir, ignoreDirs string) error {
|
||||
// Iterate through the directory, applying rules to check file and directory names
|
||||
// Return any found errors or non-conformities
|
||||
return nil
|
||||
}
|
||||
```
|
||||
|
||||
### 5. Implementation Details
|
||||
|
||||
- **File and Directory Traversal**: Use Go's `path/filepath` package to traverse directories and subdirectories.
|
||||
- **Naming Rules Checking**: Apply different regex expressions for naming checks based on file extensions.
|
||||
- **Error Handling and Reporting**: Record files or directories that do not conform and report to the user.
|
||||
|
||||
### 6. Future Development and Extensions
|
||||
|
||||
- Support more file types and naming rules.
|
||||
- Provide more detailed error reports, such as showing line numbers and specific naming mistakes.
|
||||
- Add a graphical or web interface for non-command-line users.
|
||||
|
||||
The above is an overview of the entire project's design. Following this design, specific coding implementation can begin. Note that the actual implementation may need adjustments based on real-world conditions.
|
@ -0,0 +1,97 @@
|
||||
package checker
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/openimsdk/open-im-server/tools/formitychecker/config"
|
||||
)
|
||||
|
||||
var (
|
||||
underscoreRegex = regexp.MustCompile(`^[a-zA-Z0-9_]+\.[a-zA-Z0-9]+$`)
|
||||
hyphenRegex = regexp.MustCompile(`^[a-zA-Z0-9\-]+\.[a-zA-Z0-9]+$`)
|
||||
)
|
||||
|
||||
// CheckDirectoCheckDirectoryries initiates the checking process for the specified directories using configuration from config.Config.
|
||||
func CheckDirectory(cfg *config.Config) error {
|
||||
ignoreMap := make(map[string]struct{})
|
||||
for _, dir := range cfg.IgnoreDirs {
|
||||
ignoreMap[dir] = struct{}{}
|
||||
}
|
||||
|
||||
for _, targetDir := range cfg.TargetDirs {
|
||||
err := filepath.Walk(targetDir, func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Skip if the directory is in the ignore list
|
||||
dirName := filepath.Base(filepath.Dir(path))
|
||||
if _, ok := ignoreMap[dirName]; ok && info.IsDir() {
|
||||
return filepath.SkipDir
|
||||
}
|
||||
|
||||
// Check the naming convention
|
||||
if err := checkNamingConvention(path, info); err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("error checking directory '%s': %w", targetDir, err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// checkNamingConvention checks if the file or directory name conforms to the standard naming conventions.
|
||||
func checkNamingConvention(path string, info os.FileInfo) error {
|
||||
fileName := info.Name()
|
||||
|
||||
// Handle special cases for directories like .git
|
||||
if info.IsDir() && strings.HasPrefix(fileName, ".") {
|
||||
return nil // Skip special directories
|
||||
}
|
||||
|
||||
// Extract the main part of the name (without extension for files)
|
||||
mainName := fileName
|
||||
if !info.IsDir() {
|
||||
mainName = strings.TrimSuffix(fileName, filepath.Ext(fileName))
|
||||
}
|
||||
|
||||
// Determine the type of file and apply corresponding naming rule
|
||||
switch {
|
||||
case info.IsDir():
|
||||
if !isValidName(mainName, "_") { // Directory names must only contain underscores
|
||||
return fmt.Errorf("!!! invalid directory name: %s", path)
|
||||
}
|
||||
case strings.HasSuffix(fileName, ".go"):
|
||||
if !isValidName(mainName, "_") { // Go files must only contain underscores
|
||||
return fmt.Errorf("!!! invalid Go file name: %s", path)
|
||||
}
|
||||
case strings.HasSuffix(fileName, ".yml"), strings.HasSuffix(fileName, ".yaml"), strings.HasSuffix(fileName, ".md"):
|
||||
if !isValidName(mainName, "-") { // YML, YAML, and Markdown files must only contain hyphens
|
||||
return fmt.Errorf("!!! invalid file name: %s", path)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// isValidName checks if the file name conforms to the specified rule (underscore or hyphen).
|
||||
func isValidName(name, charType string) bool {
|
||||
switch charType {
|
||||
case "_":
|
||||
return underscoreRegex.MatchString(name)
|
||||
case "-":
|
||||
return hyphenRegex.MatchString(name)
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Config holds all the configuration parameters for the checker.
|
||||
type Config struct {
|
||||
TargetDirs []string // Directories to check
|
||||
IgnoreDirs []string // Directories to ignore
|
||||
}
|
||||
|
||||
// NewConfig creates and returns a new Config instance.
|
||||
func NewConfig(targetDirs, ignoreDirs string) *Config {
|
||||
return &Config{
|
||||
TargetDirs: parseDirs(targetDirs),
|
||||
IgnoreDirs: parseDirs(ignoreDirs),
|
||||
}
|
||||
}
|
||||
|
||||
// parseDirs splits a comma-separated string into a slice of directory names.
|
||||
func parseDirs(dirs string) []string {
|
||||
if dirs == "" {
|
||||
return nil
|
||||
}
|
||||
return strings.Split(dirs, ",")
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
"github.com/openimsdk/open-im-server/tools/formitychecker/checker"
|
||||
"github.com/openimsdk/open-im-server/tools/formitychecker/config"
|
||||
)
|
||||
|
||||
func main() {
|
||||
defaultTargetDirs := "."
|
||||
defaultIgnoreDirs := "components,.git"
|
||||
|
||||
var targetDirs string
|
||||
var ignoreDirs string
|
||||
flag.StringVar(&targetDirs, "target", defaultTargetDirs, "Directories to check (default: current directory)")
|
||||
flag.StringVar(&ignoreDirs, "ignore", defaultIgnoreDirs, "Directories to ignore (default: A/, B/)")
|
||||
flag.Parse()
|
||||
|
||||
conf := config.NewConfig(targetDirs, ignoreDirs)
|
||||
|
||||
err := checker.CheckDirectory(conf)
|
||||
if err != nil {
|
||||
fmt.Println("Error:", err)
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
module github.com/openimsdk/open-im-server/tools/formitychecker
|
||||
|
||||
go 1.19
|
@ -0,0 +1,8 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
|
||||
fmt.Println("imctl")
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
# See the OWNERS docs at https://go.k8s.io/owners
|
||||
|
||||
reviewers:
|
||||
- cubxxw
|
||||
- kubbot
|
||||
approvers:
|
||||
- cubxxw
|
||||
labels:
|
||||
- sig/testing
|
||||
- sig/contributor-experience
|
Loading…
Reference in new issue