GitHub Actions CI/CD¶
This project uses GitHub Actions for continuous integration and deployment automation.
Overview¶
Two workflows automate key project tasks:
- Test Workflow - Runs pytest on every push and pull request
- Documentation Workflow - Builds and deploys MkDocs to GitHub Pages
Test Workflow¶
File: .github/workflows/test.yml
Triggers¶
The test workflow runs automatically when:
- Push to main: Any commit pushed to the main branch
- Pull requests: Any PR targeting the main branch
- Manual trigger: Via the Actions tab in GitHub ("Run workflow" button)
What It Does¶
- Checkout code - Clones the repository
- Set up Python 3.10 - Installs Python runtime
- Install uv - Installs the uv package manager with caching
- Install dependencies - Creates venv and installs project with dev dependencies
- Run pytest - Executes all tests with verbose output
- Upload test results - Stores coverage reports as artifacts (30-day retention)
Example Output¶
Run pytest
============================= test session starts ==============================
platform linux -- Python 3.10.x, pytest-7.x.x
collected 45 items
tests/test_data_processing.py::test_load_raw_data PASSED [ 2%]
tests/test_data_processing.py::test_merge_store_info PASSED [ 4%]
tests/test_features.py::test_add_calendar_features PASSED [ 6%]
...
============================== 45 passed in 12.34s ==============================
Viewing Results¶
- Navigate to the Actions tab in your GitHub repository
- Click on the latest workflow run
- View test results in the job logs
- Download coverage artifacts if needed
Manual Trigger¶
To manually run tests:
- Go to Actions tab
- Select "Run Tests" workflow
- Click "Run workflow" dropdown
- Select branch and click "Run workflow" button
Documentation Workflow¶
File: .github/workflows/docs.yml
Triggers¶
The documentation workflow runs when:
- Push to main: Changes to
docs/,mkdocs.yml, or the workflow file itself - Manual trigger: Via the Actions tab
What It Does¶
Build Job:
- Checkout code
- Set up Python and install dependencies
- Build documentation with
mkdocs build --strict - Upload built site as Pages artifact
Deploy Job:
- Deploy artifact to GitHub Pages
- Publish to
https://<username>.github.io/<repo-name>/
Setup Requirements¶
First-time setup (one-time configuration):
- Go to Settings > Pages in your repository
- Under "Build and deployment":
- Source: GitHub Actions
- Save changes
The workflow will then automatically deploy on the next push.
Viewing Documentation¶
Once deployed, your documentation will be available at:
Example: https://bradleyboehmke.github.io/rossmann-forecasting/
Deployment Status¶
Check deployment status:
- Actions tab shows build progress
- Environments section shows "github-pages" deployments
- Green checkmark indicates successful deployment
Workflow Configuration¶
Dependencies¶
Both workflows use:
- actions/checkout@v4 - Latest checkout action
- actions/setup-python@v5 - Python installation
- astral-sh/setup-uv@v3 - uv package manager with caching
Caching¶
The uv action automatically caches dependencies to speed up subsequent runs:
- First run: ~2-3 minutes (installs everything)
- Cached runs: ~30-60 seconds (uses cached packages)
Python Version¶
Both workflows use Python 3.10 to match the development environment specified in pyproject.toml.
Best Practices¶
Testing¶
Before pushing to main:
# Run tests locally first
pytest -v
# Check that all tests pass
# Fix any failures before committing
Pull request workflow:
- Create feature branch:
git checkout -b feature/my-feature - Make changes and commit
- Push branch:
git push origin feature/my-feature - Open pull request on GitHub
- Tests run automatically - wait for green checkmark
- Review results before merging
Documentation¶
Before pushing docs changes:
# Build docs locally to check for errors
mkdocs build --strict
# Serve locally to preview
mkdocs serve
# Visit http://localhost:8000
Deployment process:
- Make changes to
docs/files - Test locally with
mkdocs serve - Commit and push to main
- Workflow automatically builds and deploys
- Check deployment status in Actions tab
- Visit GitHub Pages URL to verify
Troubleshooting¶
Test Workflow Failures¶
Common issues:
-
Import errors: Missing dependencies in
pyproject.toml -
Test failures: Broken tests or code changes
-
Coverage issues: Not all code paths tested
Documentation Workflow Failures¶
Common issues:
-
Build errors: Invalid mkdocs.yml or broken links
-
Missing files: References to non-existent pages
Fix: Check file paths in
mkdocs.ymlnavigation -
Permission errors: GitHub Pages not enabled
- Solution: Enable Pages in repository Settings
Viewing Workflow Logs¶
To debug issues:
- Go to Actions tab
- Click failed workflow run
- Click on failed job
- Expand failed step to see error details
- Copy error message and fix locally
Workflow Status Badges¶
Add status badges to your README:


Replace <username> with your GitHub username.
Advanced Configuration¶
Running Subset of Tests¶
Modify .github/workflows/test.yml to run specific tests:
- name: Run pytest
run: |
source .venv/bin/activate
pytest tests/test_features.py -v # Only feature tests
Custom MkDocs Theme¶
The documentation workflow uses the configuration in mkdocs.yml. To customize:
- Edit
mkdocs.ymllocally - Test with
mkdocs serve - Commit and push - workflow uses your config
Scheduled Runs¶
Add scheduled testing (e.g., nightly builds):
Cost and Usage¶
Good news: GitHub Actions is free for public repositories!
- Public repos: Unlimited minutes
- Private repos: 2,000 free minutes/month
Storage:
- Artifacts retained for 30 days (configurable)
- Test results and coverage reports count against storage