Building and Testing Python¶
This guide shows you how to build and test a Python application.
Example Workflow¶
name: python-build
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Test with pytest
run: |
pip install pytest
pytest
detailed explanation¶
- Set up Python:
actions/setup-pythoninstalls the specified version of Python. - Install dependencies: Upgrades
pipand installs dependencies fromrequirements.txt. - Test: Runs tests using
pytest(or any other test runner you prefer).
📬 DevopsPilot Weekly — Learn DevOps, Cloud & Gen AI the simple way.
👉 Subscribe here