-
-
Notifications
You must be signed in to change notification settings - Fork 1
105 lines (91 loc) · 4.44 KB
/
test_memory_agent.yml
File metadata and controls
105 lines (91 loc) · 4.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# 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