From 986b4696cdb8545d032d202802bf543493fe8669 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Sat, 16 Sep 2023 00:05:39 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20chore(ci.yml):=20add=20CI/CD=20p?= =?UTF-8?q?ipeline=20configuration=20file=20to=20automate=20build=20and=20?= =?UTF-8?q?test=20process=20=F0=9F=94=A7=20chore(pyproject.toml):=20add=20?= =?UTF-8?q?'async=5Ftest'=20marker=20for=20pytest=20to=20identify=20asynch?= =?UTF-8?q?ronous=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 63 ++++++++++++++++++++++++++++++++++++++++ pyproject.toml | 1 + 2 files changed, 64 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..ace4438ca --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 75e838b16..70f5723f4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -126,6 +126,7 @@ testpaths = ["tests", "integration"] console_output_style = "progress" filterwarnings = ["ignore::DeprecationWarning"] log_cli = true +markers = ["async_test"] [tool.ruff]