-
Notifications
You must be signed in to change notification settings - Fork 1
49 lines (49 loc) · 1.66 KB
/
github-actions-test.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
name: Test
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
on: [push]
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
- uses: actions/setup-node@v4
with:
node-version: 20
- run: make ui
- run: make test idas
- name: "Test init command"
run: dist/idas --config examples/simple.yaml init
- name: "Test migrate command"
run: dist/idas --config examples/simple.yaml migrate
- name: "Test config display"
run: dist/idas --config examples/simple.yaml --config.display
- name: Start service
run: | # 启动一个监听端口的进程,例如一个简单的 HTTP 服务器
nohup dist/idas --config examples/simple.yaml &> server.log &
echo $! > server.pid
shell: bash
- name: Wait for service to start
run: sleep 5
- name: "Test login action"
run: |
errorCode=$(curl http://127.0.0.1:8081/api/v1/user/login -H 'Content-Type: application/json' -d '{"username":"admin","password":"idas","type":"normal"}'|jq ".errorCode" -r)
if [ "$errorCode" != "E0004" ]; then
echo "Login result code is not E0004"
exit 1
fi
shell: bash
- name: Stop service
if: always()
run: | # 停止服务
kill $(cat server.pid)
rm server.pid
shell: bash