CI for Python
Build, lint, and test a Python application using pip, Ruff, and pytest.
Use template →1steps:
2 - label: ":pip: Install dependencies"
3 key: "pip"
4 command: pip install -r requirements.txt
5 plugins:
6 - docker#v5.9.0:
7 image: "python:3.13"
8
9 - label: Lint with Ruff
10 depends_on: ["pip"]
11 command: |
12 pip install ruff
13 ruff check .
14 plugins:
15 - docker#v5.9.0:
16 image: "python:3.13"
17
18 - label: ":pytest: Run pytest"
19 key: "pytest"
20 depends_on: ["pip"]
21 command: |
22 pip install pytest
23 pytest --junitxml=junit/test-results.xml \
24 artifact_paths:
25 - junit/test-results.xml
26 plugins:
27 - docker#v5.9.0:
28 image: "python:3.13"
29
30 - label: ":junit: Annotate"
31 depends_on: ["pytest"]
32 plugins:
33 - junit-annotate#v2.4.1:
34 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.