CI for Python
Build, lint, and test a Python application using pip, Ruff, and pytest.
Use template →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
steps: - label: ":pip: Install dependencies" key: "pip" command: pip install -r requirements.txt plugins: - docker#v5.9.0: image: "python:3.13" - label: Lint with Ruff depends_on: ["pip"] command: | pip install ruff ruff check . plugins: - docker#v5.9.0: image: "python:3.13" - label: ":pytest: Run pytest" key: "pytest" depends_on: ["pip"] command: | pip install pytest pytest --junitxml=junit/test-results.xml \ artifact_paths: - junit/test-results.xml plugins: - docker#v5.9.0: image: "python:3.13" - label: ":junit: Annotate" depends_on: ["pytest"] plugins: - junit-annotate#v2.4.1: artifacts: junit/*.xml
- Languages
- Python
- Use cases
- Continuous integration, Web application
- Platforms
- Docker
CI for Python
This template gives you a continuous integration (CI) pipeline that builds, lints, and tests a Python application.
At a glance:
How it works
This template:
- Install Python dependencies with pip, caching the result.
- Performs static analysis on the codebase with Ruff.
- Runs pytest unit tests.
- Automatically annotates the build based on junit test output
The runtime environment uses the official Python Docker image with the latest version.
Next steps
After you select Use template, you’ll:
- Connect the Git repository with your Python application.
- Modify the commands if necessary.
- Configure the compute—run locally, on-premises, or in the cloud.
- Run the pipeline.
You can then play around with the pipeline settings. For example, run the pipeline locally while you iterate on the definition or set a schedule to trigger a nightly build.
If you need help, please check our documentation, raise an issue , or reach out to support.