{"id":13764409,"url":"https://github.com/Seven45/pdm-ci","last_synced_at":"2025-05-10T19:30:59.984Z","repository":{"id":162074673,"uuid":"583341074","full_name":"Seven45/pdm-ci","owner":"Seven45","description":"PDM-based image for ci usage","archived":false,"fork":false,"pushed_at":"2025-05-05T12:02:57.000Z","size":213,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-05T13:23:11.458Z","etag":null,"topics":["docker-image","dockerhub","gitlab-ci","multistage-build","package-manager","pdm","python","python3"],"latest_commit_sha":null,"homepage":"https://hub.docker.com/r/seven45/pdm-ci","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Seven45.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-12-29T13:42:30.000Z","updated_at":"2025-05-05T12:03:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"e73ecad0-02a7-4b24-87f6-465eb1089bcc","html_url":"https://github.com/Seven45/pdm-ci","commit_stats":null,"previous_names":[],"tags_count":57,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seven45%2Fpdm-ci","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seven45%2Fpdm-ci/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seven45%2Fpdm-ci/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seven45%2Fpdm-ci/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Seven45","download_url":"https://codeload.github.com/Seven45/pdm-ci/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253470683,"owners_count":21913713,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker-image","dockerhub","gitlab-ci","multistage-build","package-manager","pdm","python","python3"],"created_at":"2024-08-03T16:00:20.187Z","updated_at":"2025-05-10T19:30:59.758Z","avatar_url":"https://github.com/Seven45.png","language":"Dockerfile","funding_links":[],"categories":["Eco-system"],"sub_categories":[],"readme":"# pdm-ci\n\n[PDM](https://github.com/pdm-project/pdm) in docker [image](https://hub.docker.com/r/seven45/pdm-ci) (versioned like official python image)\n\nYour project's structure:\n- my_project/ (workdir)\n  - `src/`\n    - your files and folders here\n    - `__init__.py`\n    - `__main__.py`\n  - `tests/`\n  - `Dockerfile`\n  - `pdm.lock`\n  - `pyproject.toml`\n  - `README.md`\n\n## Python multistage build\n\n`Dockerfile`:\n\n```dockerfile\nARG PYTHON_VERSION=3.10\n\nFROM seven45/pdm-ci:$PYTHON_VERSION as pdm\nWORKDIR /project\nCOPY pyproject.toml pdm.lock /project/\nRUN python -m venv --copies .venv\nRUN pdm install --prod --no-self --no-lock --no-editable\n\nFROM python:$PYTHON_VERSION\nWORKDIR /project\nCOPY --from=pdm /project/.venv /project/.venv\nENV PATH=\"/project/.venv/bin:$PATH\"\nCOPY src /project/src\nCMD [\"python\", \"src/__main__.py\"]\n```\n\n## Continuous Integration\n\n`pyproject.toml`:\n\n```toml\n...\n\n[tool.pdm.dev-dependencies]\ntesting = [\"pytest-cov\u003e=5.0.0\"]\nlinting = [\n    \"ruff\u003e=0.3.4\",\n]\n\n[tool.pdm.scripts]\nlint = {composite = [\"ruff format src tests\", \"ruff check src tests --fix\"]}\nlint_check = {composite = [\"ruff format src tests --check\", \"ruff check src tests\"]}\ntest = \"pytest -vvv -s tests\"\ntest_cov = \"pytest --cov-branch --cov-report=xml --cov=src tests\"\n\n...\n```\n\n`gitlab-ci.yaml`:\n\n```yaml\nstages:\n  - lint\n  - test\n\nruff:\n  stage: lint\n  image: seven45/pdm-ci:3.10-alpine\n  only: [ \"merge_requests\" ]\n  script:\n    - pdm install --no-default -G linting\n    - pdm run lint_check\n  cache:\n    paths: [ \".venv\" ]\n    key:\n      prefix: venv_lint\n      files: [ \"pdm.lock\" ]\n \n pytest:\n  stage: test\n  image: seven45/pdm-ci:3.10-slim\n  only: [ \"merge_requests\" ]\n  script:\n    - pdm install -dG testing\n    - pdm run test_cov\n  coverage: '/(?i)total.*? (100(?:\\.0+)?\\%|[1-9]?\\d(?:\\.\\d+)?\\%)$/'\n  artifacts:\n    reports:\n      coverage_report:\n        coverage_format: cobertura\n        path: coverage.xml\n  cache:\n    paths: [ \".venv\" ]\n    key:\n      prefix: venv_test\n      files: [ \"pdm.lock\" ]\n```\n\n\n## Pre-commit hooks\n\n`pre-commit-config.yaml`:\n\n```yaml\nrepos:\n  - repo: local\n    hooks:\n      - id: ruff\n        name: ruff format and lint\n        language: system\n        types: [python]\n        entry: pdm run lint_check\n```\n\n\n## Extended usage\n\nDynamic versioning:\n\nPut your version into file `src/__version__.py` with content: \n```python\n__version__ = \"0.1.0\"\n\n```\n\nPut into your `pyproject.toml` file lines:\n\n```toml\n[project]\n...\ndynamic = [\"version\"]\n\n[tool.pdm]\nbuild = {includes = [\"src\"]}\nversion = { source = \"file\", path = \"src/__version__.py\" }\n...\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSeven45%2Fpdm-ci","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSeven45%2Fpdm-ci","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSeven45%2Fpdm-ci/lists"}