Memory Agent CI/CD 🧠✨🚀 - Flawless LEGO Block Testing! 🛠️✅ #101
This file contains hidden or 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
| # filename: .github/workflows/test_memory_agent.yml | |
| # Path: .github/workflows/test_memory_agent.yml | |
| name: Memory Agent CI/CD 🧠✨🚀 - Flawless LEGO Block Testing! 🛠️✅ | |
| # Controls when the workflow will run | |
| on: | |
| # Triggers the workflow on push or pull request events to the main branch 🟢➡️ | |
| push: | |
| branches: [ main ] | |
| paths: | |
| - '**.py' # Trigger on any Python file change | |
| - 'requirements.txt' | |
| pull_request: | |
| branches: [ main ] | |
| paths: | |
| - '**.py' | |
| - 'requirements.txt' | |
| # Allows you to run this workflow manually from the Actions tab ✋▶️ | |
| workflow_dispatch: | |
| # Schedule the workflow to run daily at a specific time (e.g., 00:00 UTC) ⏰🗓️ | |
| schedule: | |
| - cron: '0 0 * * *' # Every single day at midnight UTC! 🌃 | |
| # A workflow run is made up of one or more jobs that can run sequentially or in parallel 🚀➡️⚙️ | |
| jobs: | |
| # This job runs linters and tests for the MemoryAgent across multiple Python versions 🐍🧪✨ | |
| build-and-test: | |
| # Use a matrix strategy for ultimate compatibility checks! 🧩 | |
| strategy: | |
| matrix: | |
| python-version: ["3.8", "3.9", "3.10"] # Testing on various Python flavors! 🍎🍊🍋 | |
| # The type of runner that the job will run on - a fresh environment every time! ☁️🖥️ | |
| runs-on: ubuntu-latest | |
| # Steps represent a sequence of tasks that will be executed as part of the job 👇 | |
| steps: | |
| # Checks-out your repository under $GITHUB_WORKSPACE, so your workflow can access it. | |
| # This is essential to get your code onto the runner. 📁➡️🏃♂️ | |
| - name: Checkout repository Code Base! 📥 | |
| uses: actions/checkout@v4 | |
| # Sets up Python environment on the runner for the current matrix version. | |
| # A clean Python setup, ready for action! 🌟 | |
| - name: Set up Python ${{ matrix.python-version }} Environment 🏗️ | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| # Caches Python dependencies to speed up subsequent runs. | |
| # Smart caching for faster builds! 🚀💨 | |
| - name: Cache Python dependencies for Speed ⚡ | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-python-${{ matrix.python-version }}-${{ hashFiles('**/requirements.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-python-${{ matrix.python-version }}- | |
| # Installs pytest and other dependencies. | |
| # This ensures testing tools are always available for the workflow. | |
| - name: Install Dependencies including Formatters & Linters 🛠️📦 | |
| run: | | |
| python -m pip install --upgrade pip | |
| # Install formatters (black, isort), linters (flake8), and testing tools. | |
| # Added pytest-asyncio to handle asynchronous tests. | |
| pip install black isort flake8 pytest pytest-cov pytest-html pytest-asyncio | |
| # Install other project dependencies if requirements.txt exists. | |
| if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
| # This new step checks formatting. If the code is not formatted, this step will fail the build. | |
| - name: Check Code Formatting with Black and isort ✨🎨 | |
| run: | | |
| black --check . | |
| isort --check-only . | |
| # Runs Flake8 for code style and quality checks. | |
| - name: Run Flake8 Code Linter (Non-Blocking) 🧐 | |
| run: | | |
| # Use --exit-zero to report linting errors without stopping the workflow. | |
| flake8 . --count --exit-zero --max-complexity=10 --max-line-length=120 --statistics | |
| # Runs pytest using automatic test discovery. | |
| # Pytest will automatically find any file named 'test_*.py' or '*_test.py' | |
| - name: Execute Pytest Tests with Coverage & HTML Report 🏆📄 | |
| run: | | |
| python -m pytest -v --cov=. --cov-report=xml --html=report.html --self-contained-html | |
| # Uploads the coverage report artifact. | |
| - name: Upload Coverage Report Artifact 📤📊 | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report-py${{ matrix.python-version }} | |
| path: coverage.xml | |
| if-no-files-found: ignore | |
| # Uploads the HTML test report artifact. | |
| - name: Upload HTML Test Report Artifact 📤📜 | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: html-test-report-py${{ matrix.python-version }} | |
| path: report.html | |
| if-no-files-found: ignore |