Skip to content

Commit

Permalink
update contents.
Browse files Browse the repository at this point in the history
  • Loading branch information
mo3et committed Aug 11, 2024
1 parent 6d2551c commit 73cf359
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 3 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.

name: "CodeQL"

on:
push:
branches: [ main ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
schedule:
- cron: '18 19 * * 6'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
language: [ 'go' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
61 changes: 61 additions & 0 deletions .github/workflows/comment-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Check for Chinese Characters

on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
check_chinese_comments:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Search for Chinese comments
run: |
set -e
# 搜索中文字符的模式
pattern='[\u4e00-\u9fff]'
# 创建一个结果文件
output_file=chinese_comments.txt
: > $output_file
# 使用 grep 查找所有包含中文字符的注释
grep -Pnr "$pattern" . \
--exclude-dir={docs,tests,scripts,assets,node_modules,build} \
--exclude="*.md" --exclude="*.txt" --exclude="*.html" --exclude="*.css" --exclude="*.min.js" \
|| true | tee -a $output_file
# 如果发现了中文注释,输出注释内容及其位置
if [ -s $output_file ]; then
echo "Chinese comments found in the following locations:"
cat $output_file
exit 1
else
echo "No Chinese comments found."
fi
# jobs:
# check-chinese:
# name: Check for Chinese Characters in Code
# runs-on: ubuntu-latest

# steps:
# - name: Checkout code
# uses: actions/checkout@v4

# - name: Scan for Chinese characters
# run: |
# # 检查所有文件中是否包含中文字符并输出所有匹配结果
# RESULT=$(grep -rn --include=\*.{go,py,js} --exclude-dir={.git,node_modules,html,md} '[\u4e00-\u9fff]' . || true)
# if [ -n "$RESULT" ]; then
# echo "$RESULT" | tee /dev/stderr
# echo "Error: Chinese characters found in the code."
# exit 1
# else
# echo "No Chinese characters found."
# fi
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ jobs:

- name: Build and test Server Services
run: |
sudo mage build
sudo mage start
sudo mage check
mage build
mage start
mage check
- name: Checkout Chat repository
uses: actions/checkout@v4
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Golang Lint Check

on:
push:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
resolve-modules:
name: resolve module
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4

- id: set-matrix
run: ./hack/resolve-modules.sh

lint:
name: lint module
runs-on: ubuntu-latest
needs: resolve-modules
strategy:
matrix: ${{ fromJson(needs.resolve-modules.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- name: Lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.54.2
working-directory: ${{ matrix.workdir }}
4 changes: 4 additions & 0 deletions config/conf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# 中文测试

config:
workflows: true
9 changes: 9 additions & 0 deletions hello.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package main

import "fmt"

func main() {
// 你好

fmt.Println("hello")
}

0 comments on commit 73cf359

Please sign in to comment.