Update ci.yml #31
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: CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Docker | |
uses: docker/setup-buildx-action@v1 | |
- name: Install Docker Compose | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y docker-compose | |
- name: Build and run Docker containers | |
run: | | |
docker-compose up -d --build | |
- name: Wait for services to be ready | |
run: | | |
sleep 30 # 等待容器啟動 | |
- name: Run backend tests | |
run: | | |
docker exec backend npm test | |
- name: Run control-backend tests | |
run: | | |
docker exec control-backend npm test | |
- name: Shutdown containers | |
run: | | |
docker-compose down |