From 511ffdeba18f330b8d14520488025d6463890355 Mon Sep 17 00:00:00 2001
From: "Xinwei Xiong(cubxxw)" <3293172751nss@gmail.com>
Date: Sat, 4 Nov 2023 17:05:05 +0800
Subject: [PATCH] feat(main): add openim server test cicd
---
.github/workflows/auto-gh-pr.yml | 77 ++++---
.github/workflows/auto-invite.yml | 2 +-
.github/workflows/auto-tag.yml | 2 +-
.github/workflows/bot-auto-cherry-pick.yml | 2 +-
.github/workflows/check-coverage.yml | 2 +-
.github/workflows/cla.yml | 4 +-
.github/workflows/create_branch_on_tag.yml | 65 +++---
.github/workflows/deploy.yml | 55 -----
.github/workflows/depsreview.yaml | 2 +-
.github/workflows/e2e-test.yml | 2 +-
.github/workflows/greetings.yml | 2 +-
.github/workflows/issue-robot.yml | 2 +-
.github/workflows/opencommit.yml | 20 +-
.github/workflows/pull-request.yml | 29 +--
.github/workflows/scripts-verify.yml | 76 -------
CODE_OF_CONDUCT.md | 2 +-
CONTRIBUTING.md | 4 +-
scripts/init-config.sh | 2 -
scripts/make-rules/common.mk | 15 +-
scripts/template/footer.md.tmpl | 6 +-
test/api.sh | 250 +++++++++++++++++++++
21 files changed, 364 insertions(+), 257 deletions(-)
delete mode 100644 .github/workflows/deploy.yml
delete mode 100644 .github/workflows/scripts-verify.yml
create mode 100644 test/api.sh
diff --git a/.github/workflows/auto-gh-pr.yml b/.github/workflows/auto-gh-pr.yml
index 767e35fe6..d58f35510 100644
--- a/.github/workflows/auto-gh-pr.yml
+++ b/.github/workflows/auto-gh-pr.yml
@@ -24,38 +24,49 @@ on:
types: [created]
jobs:
- create-pr:
+ sync-issue-to-pr:
runs-on: ubuntu-latest
- if: github.event.pull_request.base.ref == 'main'
- # && github.event.pull_request.merged == true
steps:
- - name: Check out code
- uses: actions/checkout@v4
- with:
- fetch-depth: 0
-
- - name: Create PR to release branch
- run: |
- ISSUEID=$(gh pr view ${{ github.event.pull_request.number }} --repo $OWNER/$REPO | grep -oP 'Fixes #\K\d+')
- echo "===========> $ISSUEID"
- ISSUE=$(gh issue view $ISSUEID --repo $OWNER/$REPO --json labels,assignees,milestone,title)
- echo "===========> $ISSUE"
-
- LABELS=$(echo $ISSUE | jq -r '.labels[] | select(.name) | .name' | jq -R -r -s -c 'split("\n")[:-1] | join(",")')
- ASSIGNEES=$(echo $ISSUE | jq -r '.assignees[] | select(.login) | .login' | jq -R -s -c 'split("\n")[:-1] | join(",")')
- MILESTONE=$(echo $ISSUE | jq -r '.milestone | select(.title) | .title')
- TITLE=$(echo $ISSUE | jq -r '.title')
-
- gh pr edit ${{ github.event.pull_request.number }} --repo $OWNER/$REPO --add-label "$LABELS" --add-assignee "$ASSIGNEES" --milestone "$MILESTONE"
-
- # git checkout -b bot/merge-to-release-$ISSUEID
- # git push origin bot/merge-to-release-$ISSUEID
- # gh pr create --base release --head bot/merge-to-release-$ISSUEID --title "Merge main to release" --body ""
- # gh pr create --base main --head feat/auto-release-pr-624 --title "The bug is fixed" --body "$x" --repo openimsdk/open-im-server --reviewer "cubxxw"
- continue-on-error: true
- env:
- GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
- GH_TOKEN: ${{ github.token }}
- ISSUE: ${{ github.event.issue.html_url }}
- OWNER: ${{ github.repository_owner }}
- REPO: ${{ github.event.repository.name }}
+ - name: Checkout code
+ uses: actions/checkout@v2
+
+ - name: Sync Issue to PR
+ if: github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main'
+ run: |
+ PR_BODY="${{ github.event.pull_request.body }}"
+
+ ISSUE_NUMBER=$(echo "$PR_BODY" | grep -oP 'Fixes #\K\d+')
+ if [[ -z "$ISSUE_NUMBER" ]]; then
+ echo "No Issue number found."
+ exit 1
+ fi
+
+ echo "Issue number found: $ISSUE_NUMBER"
+
+ # Using GitHub CLI to get issue details
+ gh issue view "$ISSUE_NUMBER" --repo "${{ github.repository }}" --json labels,assignees,milestone,title > issue_data.json
+
+ # Check if jq is installed
+ if ! command -v jq &> /dev/null; then
+ echo "Installing jq..."
+ sudo apt-get install -y jq
+ fi
+
+ # Parse data with jq
+ LABELS=$(jq -r '.labels | map(.name) | join(",")' issue_data.json)
+ ASSIGNEES=$(jq -r '.assignees | map(.login) | join(",")' issue_data.json)
+ MILESTONE=$(jq -r '.milestone.title' issue_data.json)
+
+ # Check if any of the fields are empty and set them to None
+ LABELS=${LABELS:-None}
+ ASSIGNEES=${ASSIGNEES:-None}
+ MILESTONE=${MILESTONE:-None}
+
+ # Edit the PR with issue details, handling empty fields
+ gh pr edit "${{ github.event.pull_request.number }}" --repo "${{ github.repository }}" \
+ ${LABELS:+--add-label "$LABELS"} \
+ ${ASSIGNEES:+--add-assignee "$ASSIGNEES"} \
+ ${MILESTONE:+--milestone "$MILESTONE"}
+ continue-on-error: true
+ env:
+ GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
diff --git a/.github/workflows/auto-invite.yml b/.github/workflows/auto-invite.yml
index 79e84f301..0276a33a4 100644
--- a/.github/workflows/auto-invite.yml
+++ b/.github/workflows/auto-invite.yml
@@ -39,7 +39,7 @@ jobs:
In addition to Slack, we also offer the following ways to get in touch:
+
We also have Slack channels for you to communicate and discuss. To join, visit https://slack.com/ and join our [👀 Open-IM-Server slack](https://join.slack.com/t/openimsdk/shared_invite/zt-22720d66b-o_FvKxMTGXtcnnnHiMqe9Q) team channel.
- +
Get in touch with us on [Gmail](https://mail.google.com/mail/u/0/?fs=1&tf=cm&to=winxu81@gmail.com). If you have any questions or issues that need resolving, or any suggestions and feedback for our open source projects, please feel free to contact us via email.
+ +
Get in touch with us on [Gmail](https://mail.google.com/mail/u/0/?fs=1&tf=cm&to=winxu81@gmail.com). If you have any questions or issues that need resolving, or any suggestions and feedback for our open source projects, please feel free to contact us via email.
+
Read our [blog](https://doc.rentsoft.cn/). Our blog is a great place to stay up-to-date with Open-IM-Server projects and trends. On the blog, we share our latest developments, tech trends, and other interesting information.
+
Add [Wechat](https://github.com/OpenIMSDK/OpenIM-Docs/blob/main/docs/images/WechatIMG20.jpeg) and indicate that you are a user or developer of Open-IM-Server. We will process your request as soon as possible.
diff --git a/.github/workflows/auto-tag.yml b/.github/workflows/auto-tag.yml
index 96c06c4ce..3decba7ab 100644
--- a/.github/workflows/auto-tag.yml
+++ b/.github/workflows/auto-tag.yml
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-name: Create Tag
+name: OpenIM Create Tag
on:
issue_comment:
diff --git a/.github/workflows/bot-auto-cherry-pick.yml b/.github/workflows/bot-auto-cherry-pick.yml
index 6861872e4..7c2ad49ca 100644
--- a/.github/workflows/bot-auto-cherry-pick.yml
+++ b/.github/workflows/bot-auto-cherry-pick.yml
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-name: 'Github Rebot for Cherry Pick when PR is merged'
+name: Github Rebot for Cherry Pick when PR is merged
on:
pull_request_target:
types:
diff --git a/.github/workflows/check-coverage.yml b/.github/workflows/check-coverage.yml
index c875b7a9f..7b3935730 100644
--- a/.github/workflows/check-coverage.yml
+++ b/.github/workflows/check-coverage.yml
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-name: Check-Coverage
+name: OpenIM Check Coverage
on:
workflow_dispatch:
diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml
index 4d2a16056..540c8a48b 100644
--- a/.github/workflows/cla.yml
+++ b/.github/workflows/cla.yml
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-name: "OpenIM CLA Assistant"
+name: OpenIM CLA Assistant
on:
issue_comment:
types: [created]
@@ -33,7 +33,7 @@ env:
OPEN_IM_SERVER_CLA_DOCUMENT: https://github.com/openim-sigs/cla/blob/main/README.md
OPEN_IM_SERVER_SIGNATURES_PATH: signatures/${{ github.event.repository.name }}/cla.json
- OPEN_IM_SERVER_ALLOWLIST: kubbot,bot*
+ OPEN_IM_SERVER_ALLOWLIST: kubbot,bot*,bot-*,bot/*,bot-/*,bot,*[bot]
jobs:
CLAAssistant:
diff --git a/.github/workflows/create_branch_on_tag.yml b/.github/workflows/create_branch_on_tag.yml
index 1ea5583bb..0d8b0d91a 100644
--- a/.github/workflows/create_branch_on_tag.yml
+++ b/.github/workflows/create_branch_on_tag.yml
@@ -1,17 +1,3 @@
-# Copyright © 2023 OpenIM. All rights reserved.
-#
-# 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.
-
name: Create Branch on Tag
on:
@@ -19,6 +5,10 @@ on:
tags:
- 'v*.*.0'
+permissions:
+ contents: write
+ actions: write
+
jobs:
create-branch:
runs-on: ubuntu-latest
@@ -36,41 +26,38 @@ jobs:
- name: Install git-chglog
run: make install.git-chglog
- - name: Create Branch
+ - name: Create Branch and Push
+ env:
+ TAG_NAME: ${{ github.ref_name }}
run: |
- TAG_NAME=${GITHUB_REF/refs\/tags\//}
IFS='.' read -ra VERSION_PARTS <<< "$TAG_NAME"
if [[ "${VERSION_PARTS[2]}" = "0" ]]; then
BRANCH_NAME="release-v${VERSION_PARTS[0]}.${VERSION_PARTS[1]}"
echo "Creating branch $BRANCH_NAME"
git checkout -b "$BRANCH_NAME"
git push origin "$BRANCH_NAME"
+ else
+ echo "Not a release tag. Skipping branch creation."
fi
+ continue-on-error: true
- - name: Push Changes
- uses: stefanzweifel/git-auto-commit-action@v5
- with:
- commit_message: "Auto Commit CHANGELOG"
- branch: release-v${VERSION_PARTS[0]}.${VERSION_PARTS[1]}
- env:
- GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
-
- - name: Create and Push CHANGELOG
+ - name: Create and Commit CHANGELOG
+ if: endsWith(github.ref_name, '.0')
run: |
- git checkout main
- TAG_NAME=${GITHUB_REF/refs\/tags\//}
+ git fetch --all
+ TAG_NAME=${GITHUB_REF#refs/tags/}
IFS='.' read -ra VERSION_PARTS <<< "$TAG_NAME"
- if [[ "${VERSION_PARTS[2]}" = "0" ]]; then
- cd CHANGELOG
- git-chglog --tag-filter-pattern "v${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.*" -o "CHANGELOG-${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.md"
- git add "CHANGELOG-${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.md"
- git commit -m "Update CHANGELOG for $TAG_NAME"
- fi
-
- - name: Push Changes
- uses: stefanzweifel/git-auto-commit-action@v5
+ git checkout main
+ cd CHANGELOG
+ git-chglog --tag-filter-pattern "v${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.*" -o "CHANGELOG-${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.md"
+ git add "CHANGELOG-${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.md"
+ git commit -m "Update CHANGELOG for $TAG_NAME" || echo "No changes to commit."
+ continue-on-error: true
+
+ - name: Push CHANGELOG to Main
+ if: steps.create-and-commit-changelog.outputs.changes == 'true'
+ uses: ad-m/github-push-action@v0.6.0
with:
- commit_message: "Auto Commit CHANGELOG"
+ github_token: ${{ secrets.BOT_GITHUB_TOKEN }}
branch: main
- env:
- GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
\ No newline at end of file
+ continue-on-error: true
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
deleted file mode 100644
index 1fe1bb169..000000000
--- a/.github/workflows/deploy.yml
+++ /dev/null
@@ -1,55 +0,0 @@
-# Copyright © 2023 OpenIM open source community. All rights reserved.
-#
-# 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.
-
-name: OpenIM Deploy for dev
-
-on:
- push:
- branches:
- - 'devops' # Only for the dev branch
- - 'main'
- paths:
- - '.github/workflows/*'
- # - '__test__/**' # dev No immediate testing is required
- - 'src/**'
- - 'Dockerfile'
- - 'docker-compose.yml'
- - 'bin/*'
-
-jobs:
- deploy-dev:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v4
- - name: executing remote ssh commands using password
- uses: appleboy/ssh-action@v1.0.0
- env:
- OWNER: ${{ github.repository_owner }}
- REPO: ${{ github.event.repository.name }}
- with:
- host: "${{ secrets.SG_M1_HOST }}, ${{ secrets.SG_N1_HOST }}, ${{ secrets.SG_N2_HOST}}"
- username: ${{ secrets.SG_USERNAME }}
- password: ${{ secrets.SG_PASSWORD }}
- port: ${{ secrets.SG_PORT }}
- envs: OWNER,REPO
- script_stop: true
- script: |
- mkdir -p /test/openim
- cd /test/openim
- pwd;ls -al
- echo "OWNER: $OWNER"
- echo "REPO: $REPO"
- git clone -b develop https://github.com/${OWNER}/${REPO}.git; cd ${REPO}
- docker compose up -d
- continue-on-error: true
\ No newline at end of file
diff --git a/.github/workflows/depsreview.yaml b/.github/workflows/depsreview.yaml
index 7b70595ad..c80929c8c 100644
--- a/.github/workflows/depsreview.yaml
+++ b/.github/workflows/depsreview.yaml
@@ -2,7 +2,7 @@
# Licensed under the MIT License (the "License");
# you may not use this file except in compliance with the License.
-name: Dependency Review
+name: OpenIM Dependency Review
on: [pull_request]
permissions:
diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml
index 7028003c5..1e5949edf 100644
--- a/.github/workflows/e2e-test.yml
+++ b/.github/workflows/e2e-test.yml
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-name: e2e
+name: OpenIM E2E Test
on:
workflow_dispatch:
diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml
index 0b1106ece..a92ed40ad 100644
--- a/.github/workflows/greetings.yml
+++ b/.github/workflows/greetings.yml
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-name: first-interaction
+name: OpenIM First Interaction
on:
issues:
diff --git a/.github/workflows/issue-robot.yml b/.github/workflows/issue-robot.yml
index b421a5314..2a956ed19 100644
--- a/.github/workflows/issue-robot.yml
+++ b/.github/workflows/issue-robot.yml
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-name: 'issue translator'
+name: OpenIM Issue Aotu Translator
on:
issue_comment:
types: [created]
diff --git a/.github/workflows/opencommit.yml b/.github/workflows/opencommit.yml
index 6496bd2ce..11bc00524 100644
--- a/.github/workflows/opencommit.yml
+++ b/.github/workflows/opencommit.yml
@@ -12,12 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-name: 'OpenIM Commit Action'
+name: OpenIM OpenCommit Action
on:
push:
- branches:
- - main
+ # this list of branches is often enough,
+ # but you may still ignore other public branches
+ branches-ignore: [main master dev development release]
jobs:
opencommit:
@@ -27,20 +28,20 @@ jobs:
permissions: write-all
steps:
- name: Setup Node.js Environment
- uses: actions/setup-node@v4
+ uses: actions/setup-node@v2
with:
node-version: '16'
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: di-sukharev/opencommit@github-action-v1.0.4
with:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
env:
# set openAI api key in repo actions secrets,
# for openAI keys go to: https://platform.openai.com/account/api-keys
- # for repo secret go to: https://github.com/kuebcub/settings/secrets/actions
+ # for repo secret go to: /settings/secrets/actions
OCO_OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
# customization
@@ -48,5 +49,6 @@ jobs:
OCO_OPENAI_BASE_PATH: ''
OCO_DESCRIPTION: false
OCO_EMOJI: false
- OCO_MODEL: gpt-3.5-turbo
- OCO_LANGUAGE: en
\ No newline at end of file
+ OCO_MODEL: gpt-3.5-turbo-16k
+ OCO_LANGUAGE: en
+ OCO_PROMPT_MODULE: conventional-commit
\ No newline at end of file
diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml
index 045f269d6..a03eade82 100644
--- a/.github/workflows/pull-request.yml
+++ b/.github/workflows/pull-request.yml
@@ -41,7 +41,9 @@ jobs:
run: |
git config user.name 'openimbot'
git config user.email 'openimsdk@qq.com'
- git checkout -b cicd/patch-${{ github.event.number }}
+ BRANCH_NAME="auto-pr-$(date +'%Y%m%d%H%M%S')"
+ git checkout -b $BRANCH_NAME
+
- uses: actions/setup-node@v4
- name: Setup Go
uses: actions/setup-go@v4
@@ -50,6 +52,7 @@ jobs:
sudo make tidy
sudo make tools.verify.go-gitlint
echo "Run go modules tidy successfully"
+ continue-on-error: true
- name: Run go format
run: |
@@ -75,13 +78,8 @@ jobs:
echo "Run unit test and get test coverage successfully"
continue-on-error: true
- # - name: Initialize CodeQL
- # uses: github/codeql-action/init@v2
- # with:
- # languages: go
-
- # - name: Perform CodeQL Analysis
- # uses: github/codeql-action/analyze@v2
+ - name: Perform CodeQL Analysis
+ uses: github/codeql-action/analyze@v2
- name: OpenIM verify copyright
run: |
@@ -89,31 +87,26 @@ jobs:
sudo make add-copyright
echo "OpenIM verify successfully"
continue-on-error: true
-
- # - name: Commit code
- # run: |
- # git add .
- # git commit -m "cicd: bump League Patch to cicd/patch-${{ github.event.number }}"
-
+
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.BOT_GITHUB_TOKEN }}
- commit-message: "cicd: bump League Patch to cicd/patch-${{ github.event.number }}"
- title: Bump League Patch to cicd/patch-${{ github.event.number }}
+ commit-message: "cicd: bump League Patch"
author: kubbot
signoff: false
draft: false
- branch: "cicd/patch-${{ github.event.number }}"
+ branch: ''
assignees: cubxxw
reviewers: cubxxw
delete-branch: true
+ title: "Bump League Patch auto PR: $(date +'%Y%m%d')"
body: |
Review criteria:
- [ ] Disenchanter can connect and issue actions
- This is an automated PR. @ ${{ github.actor }}
+ This is an automated PR. @ $(date +'%Y%m%d')
[workflow](https://github.com/openimsdk/open-im-server/blob/main/.github/workflows/pull-request.yml).
base: main
labels: |
diff --git a/.github/workflows/scripts-verify.yml b/.github/workflows/scripts-verify.yml
deleted file mode 100644
index db8a64757..000000000
--- a/.github/workflows/scripts-verify.yml
+++ /dev/null
@@ -1,76 +0,0 @@
-# Copyright © 2023 OpenIM. All rights reserved.
-#
-# 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.
-
-name: OpenIM executes the script validation code
-
-on:
- push:
- branches:
- - main
- paths-ignore:
- - "docs/**"
- - "README.md"
- - "README_zh-CN.md"
- - "CONTRIBUTING.md"
- pull_request:
- branches:
- - main
- paths-ignore:
- - "README.md"
- - "README_zh-CN.md"
- - "CONTRIBUTING.md"
- - "docs/**"
-
-env:
- GO_VERSION: "1.19"
- GOLANGCI_VERSION: "v1.50.1"
-
-jobs:
- openim:
- name: Test with go ${{ matrix.go_version }} on ${{ matrix.os }}
- runs-on: ${{ matrix.os }}
- permissions:
- contents: write
- environment:
- name: openim
-
- strategy:
- matrix:
- go_version: ["1.21"]
- os: [ubuntu-latest]
-
- steps:
- - name: Setup
- uses: actions/checkout@v4
-
- - name: In ${{ matrix.os }} Execute the script validation code
- uses: actions/setup-go@v4
- with:
- go-version: ${{ matrix.go_version }}
- id: go
-
- - name: scripts validation
- run: |
- sudo make verify
- continue-on-error: true
-
- - name: verify format
- run: |
- sudo make format
- continue-on-error: true
-
- - name: verify license
- run: |
- sudo make verify-copyright
- continue-on-error: true
\ No newline at end of file
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
index c5e93d7b5..66b1ee714 100644
--- a/CODE_OF_CONDUCT.md
+++ b/CODE_OF_CONDUCT.md
@@ -60,7 +60,7 @@ representative at an online or offline event.
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
-3293172751nss@gmail.com.
+`security@openim.io`.
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 80cdf66c3..afa8b35d4 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -186,7 +186,7 @@ We divide the problem into security and general problems:
Security issues are always treated seriously. As our usual principle, we discourage anyone to spread security issues. If you find a security issue of Open-IM-Server, please do not discuss it in public and even do not open a public issue.
-Instead we encourage you to send us a private email to winxu81@gmail.com to report this.
+Instead we encourage you to send us a private email to info@openim.io to report this.
#### Reporting general issues
@@ -369,7 +369,7 @@ Our most recommended way to get in touch is through [Slack](https://join.slack.c
In addition to Slack, we also offer the following ways to get in touch:
+
: We also have Slack channels for you to communicate and discuss. To join, visit https://slack.com/ and join our [👀 Open-IM-Server slack](https://join.slack.com/t/openimsdk/shared_invite/zt-22720d66b-o_FvKxMTGXtcnnnHiMqe9Q) team channel.
-+
: Get in touch with us on [Gmail](winxu81@gmail.com). If you have any questions or issues that need resolving, or any suggestions and feedback for our open source projects, please feel free to contact us via email.
++
: Get in touch with us on [Gmail](info@openim.io). If you have any questions or issues that need resolving, or any suggestions and feedback for our open source projects, please feel free to contact us via email.
+
: Read our [blog](https://doc.rentsoft.cn/). Our blog is a great place to stay up-to-date with Open-IM-Server projects and trends. On the blog, we share our latest developments, tech trends, and other interesting information.
+
: Add [Wechat](https://github.com/OpenIMSDK/OpenIM-Docs/blob/main/docs/images/WechatIMG20.jpeg) and indicate that you are a user or developer of Open-IM-Server. We will process your request as soon as possible.
diff --git a/scripts/init-config.sh b/scripts/init-config.sh
index 6d8bef806..d38436129 100755
--- a/scripts/init-config.sh
+++ b/scripts/init-config.sh
@@ -24,11 +24,9 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${OPENIM_ROOT}/scripts/lib/init.sh"
-# 定义一个配置文件数组,其中包含需要生成的配置文件的名称路径
# (en: Define a profile array that contains the name path of the profile to be generated.)
readonly ENV_FILE=${ENV_FILE:-"${OPENIM_ROOT}/scripts/install/environment.sh"}
-# 定义关联数组,其中键是模板文件,值是对应的输出文件
# (en: Defines an associative array where the keys are the template files and the values are the corresponding output files.)
declare -A TEMPLATES=(
["${OPENIM_ROOT}/deployments/templates/env_template.yaml"]="${OPENIM_ROOT}/.env"
diff --git a/scripts/make-rules/common.mk b/scripts/make-rules/common.mk
index 99ceea7e0..81b44826b 100644
--- a/scripts/make-rules/common.mk
+++ b/scripts/make-rules/common.mk
@@ -102,27 +102,24 @@ endif
# The OS can be linux/windows/darwin when building binaries
PLATFORMS ?= linux_s390x linux_mips64 linux_mips64le darwin_amd64 windows_amd64 linux_amd64 linux_arm64 linux_ppc64le # wasip1_wasm
-# only support linux
-GOOS=linux
-
# set a specific PLATFORM, defaults to the host platform
ifeq ($(origin PLATFORM), undefined)
ifeq ($(origin GOARCH), undefined)
GOARCH := $(shell go env GOARCH)
endif
- ifeq ($(origin GOARCH), undefined)
- GOARCH := $(shell go env GOARCH)
- endif
+ # Determine the host OS
+ GOOS := $(shell go env GOOS)
PLATFORM := $(GOOS)_$(GOARCH)
- # Use linux as the default OS when building images
- IMAGE_PLAT := linux_$(GOARCH)
+ # Use the host OS and GOARCH as the default when building images
+ IMAGE_PLAT := $(PLATFORM)
else
- # such as: PLATFORM = linux_amd64
+ # Parse the PLATFORM variable
GOOS := $(word 1, $(subst _, ,$(PLATFORM)))
GOARCH := $(word 2, $(subst _, ,$(PLATFORM)))
IMAGE_PLAT := $(PLATFORM)
endif
+
# Protobuf file storage path
APIROOT=$(ROOT_DIR)/pkg/proto
diff --git a/scripts/template/footer.md.tmpl b/scripts/template/footer.md.tmpl
index 4f9ab29ab..6bf91162c 100644
--- a/scripts/template/footer.md.tmpl
+++ b/scripts/template/footer.md.tmpl
@@ -8,11 +8,11 @@ If you encounter any problems during its usage, please create an issue in the [G
**Here are some ways to get involved with the OpenIM community:**
-📢 **Slack Channel**: Join our Slack channels for discussions, communication, and support. Click [here](https://join.slack.com/t/openimsdk/shared_invite/zt-22720d66b-o_FvKxMTGXtcnnnHiMqe9Q) to join the Open-IM-Server Slack team channel.
+📢 **Slack Channel**: Join our Slack channels for discussions, communication, and support. Click [here](https://openimsdk.slack.com) to join the Open-IM-Server Slack team channel.
-📧 **Gmail Contact**: If you have any questions, suggestions, or feedback for our open-source projects, please feel free to [contact us via email](https://mail.google.com/mail/?view=cm&fs=1&tf=1&to=winxu81@gmail.com).
+📧 **Gmail Contact**: If you have any questions, suggestions, or feedback for our open-source projects, please feel free to [contact us via email](https://mail.google.com/mail/?view=cm&fs=1&tf=1&to=info@openim.io).
-📖 **Blog**: Stay up-to-date with OpenIM-Server projects and trends by reading our [blog](https://doc.rentsoft.cn/). We share the latest developments, tech trends, and other interesting information related to OpenIM.
+📖 **Blog**: Stay up-to-date with OpenIM-Server projects and trends by reading our [blog](https://openim.io/). We share the latest developments, tech trends, and other interesting information related to OpenIM.
📱 **WeChat**: Add us on WeChat (QR Code) and indicate that you are a user or developer of Open-IM-Server. We'll process your request as soon as possible.
diff --git a/test/api.sh b/test/api.sh
new file mode 100644
index 000000000..f5a9db353
--- /dev/null
+++ b/test/api.sh
@@ -0,0 +1,250 @@
+#!/usr/bin/env bash
+
+# Copyright 2020 Lingfei Kong . All rights reserved.
+# Use of this source code is governed by a MIT style
+# license that can be found in the LICENSE file.
+
+
+# The root of the build/dist directory
+IAM_ROOT=$(dirname "${BASH_SOURCE[0]}")/../..
+[[ -z ${COMMON_SOURCED} ]] && source ${IAM_ROOT}/scripts/install/common.sh
+
+INSECURE_APISERVER=${IAM_APISERVER_HOST}:${IAM_APISERVER_INSECURE_BIND_PORT}
+INSECURE_AUTHZSERVER=${IAM_AUTHZ_SERVER_HOST}:${IAM_AUTHZ_SERVER_INSECURE_BIND_PORT}
+
+Header="-HContent-Type: application/json"
+CCURL="curl -f -s -XPOST" # Create
+UCURL="curl -f -s -XPUT" # Update
+RCURL="curl -f -s -XGET" # Retrieve
+DCURL="curl -f -s -XDELETE" # Delete
+
+openim::test::login()
+{
+ ${CCURL} "${Header}" http://${INSECURE_APISERVER}/login \
+ -d'{"username":"admin","password":"Admin@2021"}' | grep -Po 'token[" :]+\K[^"]+'
+}
+
+openim::test::user()
+{
+ token="-HAuthorization: Bearer $(openim::test::login)"
+
+ # 1. 如果有 colin、mark、john 用户先清空
+ ${DCURL} "${token}" http://${INSECURE_APISERVER}/v1/users/colin; echo
+ ${DCURL} "${token}" http://${INSECURE_APISERVER}/v1/users/mark; echo
+ ${DCURL} "${token}" http://${INSECURE_APISERVER}/v1/users/john; echo
+
+ # 2. 创建 colin、mark、john 用户
+ ${CCURL} "${Header}" "${token}" http://${INSECURE_APISERVER}/v1/users \
+ -d'{"password":"User@2021","metadata":{"name":"colin"},"nickname":"colin","email":"colin@foxmail.com","phone":"1812884xxxx"}'; echo
+
+ # 3. 列出所有用户
+ ${RCURL} "${token}" "http://${INSECURE_APISERVER}/v1/users?offset=0&limit=10"; echo
+
+ # 4. 获取 colin 用户的详细信息
+ ${RCURL} "${token}" http://${INSECURE_APISERVER}/v1/users/colin; echo
+
+ # 5. 修改 colin 用户
+ ${UCURL} "${Header}" "${token}" http://${INSECURE_APISERVER}/v1/users/colin \
+ -d'{"nickname":"colin","email":"colin_modified@foxmail.com","phone":"1812884xxxx"}'; echo
+
+ # 6. 删除 colin 用户
+ ${DCURL} "${token}" http://${INSECURE_APISERVER}/v1/users/colin; echo
+
+ # 7. 批量删除用户
+ ${DCURL} "${token}" "http://${INSECURE_APISERVER}/v1/users?name=mark&name=john"; echo
+ openim::log::info "$(echo -e '\033[32mcongratulations, /v1/user test passed!\033[0m')"
+}
+
+openim::test::secret()
+{
+ token="-HAuthorization: Bearer $(openim::test::login)"
+
+ # 1. 如果有 secret0 密钥先清空
+ ${DCURL} "${token}" http://${INSECURE_APISERVER}/v1/secrets/secret0; echo
+
+ # 2. 创建 secret0 密钥
+ ${CCURL} "${Header}" "${token}" http://${INSECURE_APISERVER}/v1/secrets \
+ -d'{"metadata":{"name":"secret0"},"expires":0,"description":"admin secret"}'; echo
+
+ # 3. 列出所有密钥
+ ${RCURL} "${token}" http://${INSECURE_APISERVER}/v1/secrets; echo
+
+ # 4. 获取 secret0 密钥的详细信息
+ ${RCURL} "${token}" http://${INSECURE_APISERVER}/v1/secrets/secret0; echo
+
+ # 5. 修改 secret0 密钥
+ ${UCURL} "${Header}" "${token}" http://${INSECURE_APISERVER}/v1/secrets/secret0 \
+ -d'{"expires":0,"description":"admin secret(modified)"}'; echo
+
+ # 6. 删除 secret0 密钥
+ ${DCURL} "${token}" http://${INSECURE_APISERVER}/v1/secrets/secret0; echo
+ openim::log::info "$(echo -e '\033[32mcongratulations, /v1/secret test passed!\033[0m')"
+}
+
+openim::test::policy()
+{
+ token="-HAuthorization: Bearer $(openim::test::login)"
+
+ # 1. 如果有 policy0 策略先清空
+ ${DCURL} "${token}" http://${INSECURE_APISERVER}/v1/policies/policy0; echo
+
+ # 2. 创建 policy0 策略
+ ${CCURL} "${Header}" "${token}" http://${INSECURE_APISERVER}/v1/policies \
+ -d'{"metadata":{"name":"policy0"},"policy":{"description":"One policy to rule them all.","subjects":["users:","users:maria","groups:admins"],"actions":["delete",""],"effect":"allow","resources":["resources:articles:<.*>","resources:printer"],"conditions":{"remoteIPAddress":{"type":"CIDRCondition","options":{"cidr":"192.168.0.1/16"}}}}}'; echo
+
+ # 3. 列出所有策略
+ ${RCURL} "${token}" http://${INSECURE_APISERVER}/v1/policies; echo
+
+ # 4. 获取 policy0 策略的详细信息
+ ${RCURL} "${token}" http://${INSECURE_APISERVER}/v1/policies/policy0; echo
+
+ # 5. 修改 policy0 策略
+ ${UCURL} "${Header}" "${token}" http://${INSECURE_APISERVER}/v1/policies/policy0 \
+ -d'{"policy":{"description":"One policy to rule them all(modified).","subjects":["users:","users:maria","groups:admins"],"actions":["delete",""],"effect":"allow","resources":["resources:articles:<.*>","resources:printer"],"conditions":{"remoteIPAddress":{"type":"CIDRCondition","options":{"cidr":"192.168.0.1/16"}}}}}'; echo
+
+ # 6. 删除 policy0 策略
+ ${DCURL} "${token}" http://${INSECURE_APISERVER}/v1/policies/policy0; echo
+ openim::log::info "$(echo -e '\033[32mcongratulations, /v1/policy test passed!\033[0m')"
+}
+
+openim::test::apiserver()
+{
+ openim::test::user
+ openim::test::secret
+ openim::test::policy
+ openim::log::info "$(echo -e '\033[32mcongratulations, openim-apiserver test passed!\033[0m')"
+}
+
+openim::test::authz()
+{
+ token="-HAuthorization: Bearer $(openim::test::login)"
+
+ # 1. 如果有 authzpolicy 策略先清空
+ ${DCURL} "${token}" http://${INSECURE_APISERVER}/v1/policies/authzpolicy; echo
+
+ # 2. 创建 authzpolicy 策略
+ ${CCURL} "${Header}" "${token}" http://${INSECURE_APISERVER}/v1/policies \
+ -d'{"metadata":{"name":"authzpolicy"},"policy":{"description":"One policy to rule them all.","subjects":["users:","users:maria","groups:admins"],"actions":["delete",""],"effect":"allow","resources":["resources:articles:<.*>","resources:printer"],"conditions":{"remoteIPAddress":{"type":"CIDRCondition","options":{"cidr":"192.168.0.1/16"}}}}}'; echo
+
+ # 3. 如果有 authzsecret 密钥先清空
+ ${DCURL} "${token}" http://${INSECURE_APISERVER}/v1/secrets/authzsecret; echo
+
+ # 4. 创建 authzsecret 密钥
+ secret=$(${CCURL} "${Header}" "${token}" http://${INSECURE_APISERVER}/v1/secrets -d'{"metadata":{"name":"authzsecret"},"expires":0,"description":"admin secret"}')
+ secretID=$(echo ${secret} | grep -Po 'secretID[" :]+\K[^"]+')
+ secretKey=$(echo ${secret} | grep -Po 'secretKey[" :]+\K[^"]+')
+
+ # 5. 生成 token
+ token=$(iamctl jwt sign ${secretID} ${secretKey})
+
+ # 6. 调用 /v1/authz 完成资源授权。
+ # 注意这里要 sleep 3s 等待 openim-authz-server 将新建的密钥同步到其内存中
+ echo "wait 3s to allow openim-authz-server to sync information into its memory ..."
+ sleep 3
+ ret=`$CCURL "${Header}" -H"Authorization: Bearer ${token}" http://${INSECURE_AUTHZSERVER}/v1/authz \
+ -d'{"subject":"users:maria","action":"delete","resource":"resources:articles:ladon-introduction","context":{"remoteIPAddress":"192.168.0.5"}}' | grep -Po 'allowed[" :]+\K\w+'`
+
+ if [ "$ret" != "true" ];then
+ return 1
+ fi
+
+ openim::log::info "$(echo -e '\033[32mcongratulations, /v1/authz test passed!\033[0m')"
+}
+
+openim::test::authzserver()
+{
+ openim::test::authz
+ openim::log::info "$(echo -e '\033[32mcongratulations, openim-authz-server test passed!\033[0m')"
+}
+
+openim::test::pump()
+{
+ ${RCURL} http://${IAM_PUMP_HOST}:7070/healthz | egrep -q 'status.*ok' || {
+ openim::log::error "cannot access openim-pump healthz api, openim-pump maybe down"
+ return 1
+ }
+
+ openim::test::real_pump_test
+
+ openim::log::info "$(echo -e '\033[32mcongratulations, openim-pump test passed!\033[0m')"
+}
+
+# 使用真实的数据测试 openim-pump 是否正常工作
+openim::test::real_pump_test()
+{
+ # 1. 创建访问 openim-authz-server 需要用到的密钥对
+ iamctl secret create pumptest &>/dev/null
+
+ # 2. 使用步骤 1 创建的密钥对生成 JWT Token
+ authzAccessToken=`iamctl jwt sign njcho8gJQArsq7zr5v1YpG5NcvL0aeuZ38Ti if70HgRgp021iq5ex2l7pfy5XvgtZM3q` # iamctl jwt sign $secretID $secretKey
+
+ # 3. 创建授权策略
+ iamctl policy create pumptest '{"metadata":{"name":"policy0"},"policy":{"description":"One policy to rule them all.","subjects":["users:","users:maria","groups:admins"],"actions":["delete",""],"effect":"allow","resources":["resources:articles:<.*>","resources:printer"],"conditions":{"remoteIPAddress":{"type":"CIDRCondition","options":{"cidr":"192.168.0.1/16"}}}}}' &>/dev/null
+
+ # 注意这里要 sleep 3s 等待 openim-authz-server 将新建的密钥和授权策略同步到其内存中
+ echo "wait 3s to allow openim-authz-server to sync information into its memory ..."
+ sleep 3
+
+ # 4. 访问 /v1/authz 接口进行资源授权
+ $CCURL "${Header}" -H"Authorization: Bearer ${token}" http://${INSECURE_AUTHZSERVER}/v1/authz \
+ -d'{"subject":"users:maria","action":"delete","resource":"resources:articles:ladon-introduction","context":{"remoteIPAddress":"192.168.0.5"}}' &>/dev/null
+
+ # 这里要 sleep 5s,等待 openim-pump 将 Redis 中的日志,分析并转存到 MongoDB 中
+ echo "wait 10s to allow openim-pump analyze and dump authorization log into MongoDB ..."
+ sleep 10
+
+ # 5. 查看 MongoDB 中是否有经过解析后的授权日志。
+ echo "db.iam_analytics.find()" | mongosh --quiet "${IAM_PUMP_MONGO_URL}" | grep -q "allow access" || {
+ openim::log::error "cannot find analyzed authorization log in MongoDB"
+ return 1
+ }
+}
+
+openim::test::watcher()
+{
+ ${RCURL} http://${IAM_WATCHER_HOST}:5050/healthz | egrep -q 'status.*ok' || {
+ openim::log::error "cannot access openim-watcher healthz api, openim-watcher maybe down"
+ return 1
+ }
+ openim::log::info "$(echo -e '\033[32mcongratulations, openim-watcher test passed!\033[0m')"
+}
+
+openim::test::iamctl()
+{
+ iamctl user list | egrep -q admin || {
+ openim::log::error "iamctl cannot list users from openim-apiserver"
+ return 1
+ }
+ openim::log::info "$(echo -e '\033[32mcongratulations, iamctl test passed!\033[0m')"
+}
+
+openim::test::man()
+{
+ man openim-apiserver | grep -q 'OPENIM API Server' || {
+ openim::log::error "openim man page not installed or may not installed properly"
+ return 1
+ }
+ openim::log::info "$(echo -e '\033[32mcongratulations, man test passed!\033[0m')"
+}
+
+openim::test::smoke()
+{
+ openim::test::apiserver
+ openim::test::authzserver
+ openim::test::pump
+ openim::test::watcher
+ openim::test::iamctl
+ openim::log::info "$(echo -e '\033[32mcongratulations, smoke test passed!\033[0m')"
+}
+
+openim::test::test()
+{
+ openim::test::smoke
+ openim::test::man
+
+ openim::log::info "$(echo -e '\033[32mcongratulations, all test passed!\033[0m')"
+}
+
+if [[ "$*" =~ openim::test:: ]];then
+ eval $*
+fi