MicroOps-cn is testing out GitHub Actions 🚀 #20
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
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 |