Analyse poetry dependencies and comment on gitlab
Project description
Poetry dependencies scanner & gitlab commenter
This project consists of two scripts.
One analyses the poetry.lock
and pyproject.toml
files
it receives and produces an output listing the outdated
packages.
The other takes an input and posts it as a comment on a Gitlab merge request.
Here's how we use them:
# .gitlab-ci.yml
scan-deps:
stage: test
image: deps-scanner
allow_failure: true
script:
- scan-deps poetry.lock pyproject.toml | comment-gitlab
only:
- merge_requests
The deps-scanner
image is built from the Dockerfile in this repository.
Here's an example of what the output looks like in a merge request for this repository:
Dependencies analysis
The following snippet is an example output the first script may produce:
direct devpi command-log: current=0.0.28 -> latest=0.0.29
direct pypi django: current=3.1.9 -> latest=3.2.1
direct pypi semver: current=3.0.0.dev2 -> latest=2.13.0
trans. pypi idna: current=2.10 -> latest=3.1
The first column indicates whether the package is a direct or transitive dependency:
direct
means the package is a direct dependency.trans.
means the package is a transitive dependency: the dependency of a direct dependency or of a transitive dependency.
This is computed by using the pyproject.toml
if given. If this file is
not provided on the command line, the column will be omitted.
A dependency is considered direct if it is present in the pyproject.toml
.
The second column indicates whether the package comes from PyPi or a devpi instance.
Gitlab comment
The comment_gitlab.py
script requires some environment variables
to properly work:
BOT_USERNAME
: The username for the bot userBOT_TOKEN
: A Gitlab access token for the bot user (see https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html)CI_SERVER_URL
: The URL of the Gitlab instance where to postCI_PROJECT_ID
: The ID of the project containing the MR to post onCI_MERGE_REQUEST_IID
: The IID of the merge request to comment on
The last three variables are automatically populated by Gitlab CI when
running a job as part of a detached pipeline (for a merge request). Notice
the only: [merge_requests]
in the .gitlab-ci.yml
above.
Of course, you can also provide them manually to integrate with any other build system.
If a comment from the bot user already exists, it will be replaced, in order to reduce the noise. In other words, there will be at most one comment from the bot on a given merge request. It will contain the results of the latest check.
Build the docker image outside ITSF
The Dockerfile inside the repository references images from our internal
Docker registry proxy. You can easily build it on your own by removing
the nexus.itsf.io:5005/
prefix.
# on Ubuntu
sed -i 's/nexus.itsf.io:5005\///g' Dockerfile
# on macOS
sed -e 's/nexus.itsf.io:5005\///g' -i "" Dockerfile
# then
docker build -t deps-scanner .
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file poetry-deps-scanner-1.0.1.tar.gz
.
File metadata
- Download URL: poetry-deps-scanner-1.0.1.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.6 CPython/3.7.4 Darwin/20.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1662c4ddc27a4606f4133830994e27212ee146709efc39ef3c91e1ee3dacbc5 |
|
MD5 | 05b53bc49c9a737550a4aa654e441a0d |
|
BLAKE2b-256 | aa1978255025f0c1941fef7a3848565d8f379b14fe6b2c2a0e785d9275ba66a6 |
File details
Details for the file poetry_deps_scanner-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: poetry_deps_scanner-1.0.1-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.6 CPython/3.7.4 Darwin/20.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 932ee6ef53def05030e47abf8e1a877e4c02252e1f1e6d17214aeae1a6b1c1a9 |
|
MD5 | 005f1edb71d76ca8f9d1d6fc82ed1c0d |
|
BLAKE2b-256 | c1ba8f2690d3e9a4250134443bc7b92380e3668e11cbdea7e526f0d82734279e |