Skip to content

Commit a3582c9

Browse files
authored
[ISV-3309] Add dependency manager. (#454)
* [ISV-3309] Add dependency manager. * [ISV-3309] Add dependency manager. * [ISV-3309] Add dependency manager. * [ISV-3309] Add dependency manager. * [ISV-3309] Add dependency manager. * [ISV-3309] Add dependency manager. * [ISV-3309] Add dependency manager. * [ISV-3309] Add dependency manager. * [ISV-3309] Add dependency manager. * [ISV-3309] Add dependency manager. * [ISV-3309] Add dependency manager. * [ISV-3309] Add dependency manager. * [ISV-3309] Add dependency manager. * [ISV-3309] Add dependency manager. * [ISV-3309] Add dependency manager. * [ISV-3309] Add dependency manager. * [ISV-3309] Add dependency manager. * Correct the typo and add pdm installation in the dockerfile. * [ISV-3309] Add dependency manager. * Correct the typo and add pdm installation in the dockerfile. * Correct the typo and add pdm installation in the dockerfile. * Update the pdm installation in dockerfile. * Update the pdm installation in dockerfile. * Update the pdm installation in dockerfile. * Update the pdm installation in dockerfile. * Fix the tests. * Fix the tests. * Fix the tests. * Fix the tests. * Fix the tests. * Fix the tests. --------- Co-authored-by: haripate <>
1 parent 57cadea commit a3582c9

File tree

10 files changed

+1043
-35
lines changed

10 files changed

+1043
-35
lines changed

.github/workflows/validation.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,19 @@ jobs:
1313
name: Run unit tests and linters
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: actions/checkout@v3
17-
- uses: fedora-python/[email protected]
16+
- name: Checkout repository
17+
uses: actions/checkout@v3
18+
19+
- name: Set up PDM
20+
uses: pdm-project/setup-pdm@v3
1821
with:
19-
tox_env: black,test,yamllint
20-
dnf_install: krb5-devel krb5-workstation
22+
python-version: "3.10"
23+
24+
- name: Install dependencies
25+
run: |
26+
pdm sync -dG operator-pipelines-dev
27+
pdm sync -dG tox
28+
29+
- name: Run Tests
30+
run: |
31+
pdm run -v tox

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,4 @@ dmypy.json
146146
.*.sw?
147147
ansible/vault-password*
148148

149+
.pdm-python

docs/developer-guide.md

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -266,16 +266,26 @@ oc apply -R -f ansible/roles/operator-pipeline/templates/openshift
266266

267267
## Making Changes to the Pipeline Image
268268

269-
### Setup
270-
To install the python package in a development environment, run:
269+
### Dependency manager
270+
Operator pipelines project is configured to automatically manage Python dependencies using [PDM][1] tool.
271+
The pdm automates definition, installation, upgrades and the whole lifecycle of
272+
dependency in a project. All dependencies are stored in `pyproject.toml` file in a groups
273+
that corresponds to individual applications within the Operator pipelines project.
271274

275+
Adding, removing and updating of dependency needs to be always done using `pdm` cli.
272276
```bash
273-
pip install ".[dev]"
277+
pdm add -G operator-pipelines gunicorn==20.1.0
274278
```
279+
After a dependency is installed it is added to pdm.lock file. The lock file
280+
is always part of git repository.
275281

276-
### Tips
282+
If you want to install specific group set of dependencies use following command:
283+
```bash
284+
pdm install -G operator-pipelines
285+
```
286+
Dependencies are stored into virtual environment (.venv) which is automatically created after `pdm install`
287+
If .venv wasn't created, configure pdm to automatically create it during installation with `pdm config python.use_venv true`.
277288

278-
- If adding a new script in the pipeline image - don't forget to add the entrypoint to setup.py
279289

280290
### Run Unit Tests, Code Style Checkers, etc.
281291

@@ -285,17 +295,26 @@ To run unit tests and code style checkers:
285295
tox
286296
```
287297

298+
### Local development
299+
300+
Setup python virtual environment using pdm.
301+
```shell
302+
$ pdm venv create 3.10
303+
$ pdm install
304+
$ source .venv/bin/activate
305+
```
306+
288307
### Build & Push
289308

290309
1. Ensure you have [buildah](https://github.com/containers/buildah/blob/main/install.md) installed
291310

292-
1. Build the image
311+
2. Build the image
293312

294313
```bash
295314
buildah bud
296315
```
297316

298-
1. Push the image to a remote registry, eg. Quay.io.
317+
3. Push the image to a remote registry, eg. Quay.io.
299318

300319
```bash
301320
buildah push <image-digest-from-build-step> <remote-repository>
@@ -306,3 +325,5 @@ tox
306325
```bash
307326
buildah login quay.io
308327
```
328+
329+
[1]: https://pdm.fming.dev/latest/

operator-pipeline-images/Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,18 @@ WORKDIR /home/user
6161

6262
COPY ./operator-pipeline-images ./
6363

64+
# install PDM
65+
RUN pip3 install --upgrade pip setuptools wheel && pip3 install pdm
66+
# install dependencies in virtual environment
67+
COPY ./pdm.lock ./pyproject.toml ./README.md ./
68+
RUN pdm install --no-lock --no-editable \
69+
--group operator-pipelines \
70+
--group operator-pipelines-dev
71+
72+
ENV VIRTUAL_ENV=./.venv
73+
RUN python3 -m venv $VIRTUAL_ENV
74+
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
75+
6476
RUN pip3 install .
6577

6678
# set dir ownership

operator-pipeline-images/MANIFEST.in

Lines changed: 0 additions & 2 deletions
This file was deleted.

operator-pipeline-images/requirements-dev.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

operator-pipeline-images/requirements.txt

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)