Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 33 additions & 3 deletions .github/workflows/before_script.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
#!/usr/bin/env bash

find . -name "*.go" | xargs gofmt -w
git diff --name-only --exit-code || if [ $? != 0 ]; then echo "Notice: gofmt check failed,please gofmt before pr." && exit 1; fi
echo "gofmt check pass."
# Install gci
echo "Installing gci..."
go install github.com/daixiang0/gci@latest

# Check if the GCI is installed successfully
if ! command -v gci &> /dev/null
then
echo "gci could not be installed. Please check your Go setup."
exit 1
fi

# Use GCI to format the code
echo "Running gci to format code..."
gci write \
--custom-order \
--skip-generated \
--skip-vendor \
-s standard \
-s blank \
-s default \
-s dot \
-s "prefix(github.com/gogf/gf/v2)" \
-s "prefix(github.com/gogf/gf/cmd)" \
-s "prefix(github.com/gogf/gf/contrib)" \
-s "prefix(github.com/gogf/gf/example)" \
./

# Check the code for changes
git diff --name-only --exit-code || if [ $? != 0 ]; then echo "Notice: gci check failed, please gci before pr." && exit 1; fi
echo "gci check pass."

# Add the local domain name to `/etc/hosts`
echo "Adding local domain to /etc/hosts..."
sudo echo "127.0.0.1 local" | sudo tee -a /etc/hosts
3 changes: 0 additions & 3 deletions .github/workflows/ci-main.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#!/usr/bin/env bash

# Define the latest Go version requirement
LATEST_GO_VERSION="1.23"

coverage=$1

# find all path that contains go.mod.
Expand Down
21 changes: 14 additions & 7 deletions .github/workflows/ci-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,21 @@ concurrency:

env:
TZ: "Asia/Shanghai"

# for unit testing cases of some components that only execute on the latest go version.
LATEST_GO_VERSION: "1.23"

jobs:
code-test:
strategy:
matrix:
# 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥
# When adding new go version to the list, make sure:
# 1. Update the `LATEST_GO_VERSION` env variable.
# 2. Update the `Report Coverage` action.
# 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥
go-version: [ "1.20", "1.21", "1.22", "1.23" ]
goarch: [ "386", "amd64" ]

runs-on: ubuntu-20.04

# Service containers to run with `code-test`
Expand Down Expand Up @@ -185,11 +196,6 @@ jobs:
ports:
- 2181:2181

strategy:
matrix:
go-version: [ "1.20", "1.21", "1.22", "1.23" ]
goarch: [ "386", "amd64" ]

steps:
# TODO: szenius/set-timezone update to node16
# sudo ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
Expand Down Expand Up @@ -256,7 +262,8 @@ jobs:

- name: Report Coverage
uses: codecov/codecov-action@v4
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
# Only report coverage on the latest go version and amd64 arch
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && matrix.go-version == '1.23' && matrix.goarch == 'amd64' }}
with:
flags: go-${{ matrix.go-version }}-${{ matrix.goarch }}
token: ${{ secrets.CODECOV_TOKEN }}
11 changes: 8 additions & 3 deletions .github/workflows/ci-sub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,22 @@ concurrency:

env:
TZ: "Asia/Shanghai"

# for unit testing cases of some components that only execute on the latest go version.
LATEST_GO_VERSION: "1.23"

jobs:
code-test:
runs-on: ubuntu-latest

strategy:
matrix:
# 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥
# When adding new go version to the list, make sure:
# 1. Update the `LATEST_GO_VERSION` env variable.
# 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥
go-version: [ "1.20", "1.21", "1.22", "1.23" ]
goarch: [ "386", "amd64" ]

runs-on: ubuntu-latest

steps:
- name: Setup Timezone
uses: szenius/[email protected]
Expand Down
61 changes: 61 additions & 0 deletions .github/workflows/format-code-on-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Format Code on Push

on:
push

jobs:
format-code:
strategy:
matrix:
go-version: [ 'stable' ]
name: format-code-by-gci
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Golang ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Install gci
run: go install github.com/daixiang0/gci@latest
- name: Run gci
run: |
gci write --custom-order \
--skip-generated \
--skip-vendor \
-s standard \
-s blank \
-s default \
-s dot \
-s "prefix(github.com/gogf/gf/v2)" \
-s "prefix(github.com/gogf/gf/cmd)" \
-s "prefix(github.com/gogf/gf/contrib)" \
-s "prefix(github.com/gogf/gf/example)" \
./
- name: Check for changes
run: |
if [[ -n "$(git status --porcelain)" ]]; then
echo "HAS_CHANGES=true" >> $GITHUB_ENV
else
echo "HAS_CHANGES=false" >> $GITHUB_ENV
fi
- name: Configure Git
run: |
if [[ "$HAS_CHANGES" == 'true' ]]; then
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
else
echo "HAS_CHANGES= $HAS_CHANGES "
fi
- name: Commit and push changes
run: |
if [[ "$HAS_CHANGES" == 'true' ]]; then
git add .
git commit -m "Apply gci import order changes"
git push origin ${{ github.event.pull_request.head.ref }}
else
echo "No change to commit push"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44 changes: 6 additions & 38 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# If a copy of the MIT was not distributed with this file,
# You can obtain one at https://github.com/gogf/gf.

name: GolangCI-Lint
name: GolangCI Lint
on:
push:
branches:
Expand All @@ -26,11 +26,11 @@ on:
- feat/**

jobs:
golangci:
golang-ci:
strategy:
matrix:
go-version: [ 'stable' ]
name: golangci-lint
name: golang-ci-lint
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -39,44 +39,12 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: golangci-lint
- name: golang-ci-lint
uses: golangci/golangci-lint-action@v6
with:
# Required: specify the golangci-lint version without the patch version to always use the latest patch.
version: v1.62.2
only-new-issues: true
skip-cache: true
github-token: ${{ secrets.GITHUB_TOKEN }}
args: --timeout 3m0s
- name: Install gci
run: go install github.com/daixiang0/gci@latest
- name: Run gci
run: |
gci write --custom-order \
--skip-generated \
--skip-vendor \
-s standard \
-s blank \
-s default \
-s dot \
-s "prefix(github.com/gogf/gf/v2)" \
-s "prefix(github.com/gogf/gf/cmd)" \
-s "prefix(github.com/gogf/gf/contrib)" \
-s "prefix(github.com/gogf/gf/example)" \
./
- name: Check for changes
# Check if the event is a push or a pull request from a forked repository
if: github.event_name == 'push'|| (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true)
run: |
if [[ -n "$(git status --porcelain)" ]]; then
echo "HAS_CHANGES=true" >> $GITHUB_ENV
else
echo "HAS_CHANGES=false" >> $GITHUB_ENV
fi
- name: Commit and push changes
if: env.HAS_CHANGES == 'true'
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "Apply gci import order changes"
git push origin HEAD:$(git rev-parse --abbrev-ref HEAD)
args: --timeout 3m0s --config=.golangci.yml -v
6 changes: 3 additions & 3 deletions .github/workflows/issue-check-inactive.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# 规则描述:每天凌晨3点(GMT+8)执行一次,将最近7天没有活跃且非BUG的ISSUE设置标签:inactive
# Rule description: Execute the ISSUE once a day at 3 a.m. (GMT+8) and set the non-bug issue that has not been active in the last 7 days to inactive
name: Issue Check Inactive

on:
schedule:
- cron: "0 19 * * *"

env: # 设置环境变量
TZ: Asia/Shanghai #时区(设置时区可使页面中的`最近更新时间`使用时区时间)
env: # Set environment variables
TZ: Asia/Shanghai #Time zone (setting the time zone allows the 'Last Updated' on the page to use the time zone)

permissions:
contents: read
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/issue-close-inactive.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# 规则描述:每天凌晨 4 点 (GMT+8) 执行一次,将最近 30 天没有活跃且非 BUG 的 ISSUE 关闭
# RULE DESCRIPTION: EXECUTED ONCE A DAY AT 4 A.M. (GMT+8) TO CLOSE NON-BUG ISSUES THAT HAVE NOT BEEN ACTIVE IN THE LAST 30 DAYS
name: Issue Close Inactive

on:
schedule:
- cron: "0 20 * * *"

env: # 设置环境变量
TZ: Asia/Shanghai #时区(设置时区可使页面中的`最近更新时间`使用时区时间)
env: # Set environment variables
TZ: Asia/Shanghai #Time zone (setting the time zone allows the 'Last Updated' on the page to use the time zone)

jobs:
close-issues:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/issue-labeled.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
## 规则描述:当 issue 被标记为 help wanted 时,增加评论
## Rule description: Add comments when an issue is marked as help wanted

name: Issue Labeled

on:
issues:
types: [labeled]

env: # 设置环境变量
TZ: Asia/Shanghai # 时区(设置时区可使页面中的`最近更新时间`使用时区时间)
env: # Set environment variables
TZ: Asia/Shanghai # Time zone (setting the time zone allows the 'Last Updated' on the page to use the time zone)

jobs:
reply-labeled:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/issue-remove-inactive.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 规则描述:在 issue 没有活跃且尚未被关闭期间,若 issue 作者更新或评论该 ISSUE,则移除其 inactive 标签
# Rule description: If an issue author updates or comments on an issue while it is not active and has not been closed, the inactive tag will be removed
name: Issue Remove Inactive

on:
Expand All @@ -7,8 +7,8 @@ on:
issue_comment:
types: [created, edited]

env: # 设置环境变量
TZ: Asia/Shanghai #时区(设置时区可使页面中的`最近更新时间`使用时区时间)
env: # Set environment variables
TZ: Asia/Shanghai #Time zone (setting the time zone allows the 'Last Updated' on the page to use the time zone)

permissions:
contents: read
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/issue-remove-need-more-details.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 规则描述:将需要提供更多细节且暂未关闭的 issue,在 issue 作者评论后,移除 need more details 标签
# Rule Description: For issues that need more details and are not yet closed, remove the "need more details" tag after the issue author comments
name: Issue Remove Need More Details

on:
Expand All @@ -7,8 +7,8 @@ on:
issue_comment:
types: [created, edited]

env: # 设置环境变量
TZ: Asia/Shanghai #时区(设置时区可使页面中的`最近更新时间`使用时区时间)
env: # Set environment variables
TZ: Asia/Shanghai #Time zone (setting the time zone allows the 'Last Updated' on the page to use the time zone)

permissions:
contents: read
Expand Down
Loading
Loading