🔧 chore(ci.yml): add CI/CD pipeline configuration file to automate build and test process

🔧 chore(pyproject.toml): add 'async_test' marker for pytest to identify asynchronous tests
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-09-16 00:05:39 -03:00
commit 986b4696cd
2 changed files with 64 additions and 0 deletions

63
.github/workflows/ci.yml vendored Normal file
View file

@ -0,0 +1,63 @@
name: CI/CD Pipeline
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build-and-test:
runs-on: ubuntu-latest
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
steps:
# Step 1: Checkout code from the repository
- name: Checkout code
uses: actions/checkout@v2
# Step 2: Setup cache for Docker layers
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
# Step 3: Setup Docker and Docker Compose
- name: Set up Docker
run: docker --version && docker-compose --version
# Step 4: Build Docker containers and start services (e.g., Redis, Celery)
- name: Build and start services
working-directory: ./deploy
run: docker-compose up --build -d
continue-on-error: true
- name: Build and run tests
run: |
docker-compose -f docker-compose.yml up --exit-code-from tests tests queue celeryworker db -d
container_id=$(docker ps -a -q --filter "name=tests")
docker cp ${container_id}:/path/in/container/to/test/results ./test-results
- name: Upload test report
if: always()
uses: actions/upload-artifact@v2
with:
name: test-report
path: ./test-results
# Step 6: Capture test results and store as an artifact
- name: Archive test results
if: always()
uses: actions/upload-artifact@v2
with:
name: test-results
path: path/to/your/test-results/ # Update this to where pytest stores test results
# Step 7: Cleanup - Stop and remove Docker containers
- name: Stop services
run: docker-compose down

View file

@ -126,6 +126,7 @@ testpaths = ["tests", "integration"]
console_output_style = "progress"
filterwarnings = ["ignore::DeprecationWarning"]
log_cli = true
markers = ["async_test"]
[tool.ruff]