-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
92 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
name: xzdp CI | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
fmt: | ||
name: Run go fmt | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.20 | ||
|
||
- name: Run go fmt | ||
run: | | ||
fmt_output=$(go fmt ./...) | ||
if [ -n "$fmt_output" ]; then | ||
echo "The following files need to be formatted:" | ||
echo "$fmt_output" | ||
exit 1 | ||
fi | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
needs: fmt | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.20 | ||
|
||
- name: Install dependencies | ||
run: go mod tidy | ||
|
||
- name: Build | ||
run: ./script/build.sh | ||
|
||
test: | ||
name: Run tests | ||
runs-on: ubuntu-latest | ||
needs: build | ||
services: | ||
redis: | ||
image: redis:latest | ||
ports: | ||
- 6379:6379 | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.20 | ||
|
||
- name: Install dependencies | ||
run: go mod tidy | ||
|
||
- name: Run tests | ||
env: | ||
REDIS_HOST: 127.0.0.1 | ||
REDIS_PORT: 6379 | ||
run: ./script/test.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
if [ ! -f conf/test/conf.yaml ]; then | ||
cp conf/test/conf.example.yaml conf/test/conf.yaml | ||
echo "conf/test/conf.yaml has been created from conf/test/conf.example.yaml" | ||
fi | ||
|
||
go build -v xzdp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
# 运行构建脚本 | ||
sh ./script/build.sh | ||
|
||
# 测试 ./xzdp 是否能正常运行,运行2秒后退出 | ||
timeout 2s ./xzdp & | ||
sleep 2 | ||
kill $! | ||
|
||
# 单元测试未编写,暂时只测试能否正确运行 | ||
# go test -v -cover ./... |