GitHub Actions — Automated Testing¶
Dr. X wants to ensure changes don't break the pipeline. They set up GitHub Actions to automatically test every commit.
.github/workflows/test.yml:¶
name: Test Pipeline
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install dependencies
run: |
pip install -r requirements.txt
- name: Run tests
run: |
pytest tests/
Now, every push and PR triggers automated tests. If tests fail, the PR shows a ❌ and won't be merged until fixed.
flowchart LR
A[Push to GitHub] --> B[GitHub Actions triggered]
B --> C{Tests pass?}
C -->|Yes ✓| D[Green checkmark]
C -->|No ✗| E[Red X - Fix before merge]
style D fill:#e6ffe6,stroke:#0a0
style E fill:#ffe6e6,stroke:#f00