diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6b9a348..7e64a39 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,7 +5,7 @@ stages: - deploy variables: - DOCKER_IMAGE_VERSION: 1 + PROJECT_VERSION: 0.4 build docker: stage: docker @@ -15,7 +15,7 @@ build docker: script: - mkdir -p /kaniko/.docker - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json - - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$DOCKER_IMAGE_VERSION + - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$PROJECT_VERSION --build-arg PROJECT_VERSION=$PROJECT_VERSION only: changes: - Dockerfile @@ -25,8 +25,9 @@ build docker: unit tests: stage: test tags: [gitlab-org-docker] - image: $CI_REGISTRY_IMAGE:$DOCKER_IMAGE_VERSION + image: python:3-slim script: + - pip install --no-cache-dir -r requirements.txt - coverage run --source pipeline_mermaid -m unittest discover tests "*test*" - coverage xml # for merge request - coverage html # for pages @@ -41,7 +42,7 @@ unit tests: build package: tags: [ gitlab-org-docker ] - image: $CI_REGISTRY_IMAGE:$DOCKER_IMAGE_VERSION + image: python:3-slim stage: build script: - python setup.py sdist bdist_wheel @@ -67,13 +68,12 @@ pages: notify merge request: stage: deploy tags: [ gitlab-org-docker ] - image: $CI_REGISTRY_IMAGE:$DOCKER_IMAGE_VERSION + image: $CI_REGISTRY_IMAGE:$PROJECT_VERSION dependencies: [] script: - - pip install -e . - - python -m pipeline_mermaid.gitlab_helper show_current_pipeline graph - - python -m pipeline_mermaid.gitlab_helper show_pipeline 190875422 - - python -m pipeline_mermaid.gitlab_helper show_pipeline 192204962 journey + - pipeline-mermaid show_current_pipeline graph + - pipeline_mermaid show_pipeline 190875422 + - pipeline_mermaid show_pipeline 192204962 journey upload to pypi: @@ -83,7 +83,7 @@ upload to pypi: dependencies: - build package tags: [ gitlab-org-docker ] - image: $CI_REGISTRY_IMAGE:$DOCKER_IMAGE_VERSION + image: $CI_REGISTRY_IMAGE:$PROJECT_VERSION when: manual script: - twine upload dist/* --non-interactive -u __token__ -p $PYPI_TOKEN --verbose diff --git a/Dockerfile b/Dockerfile index 2909c51..371c002 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,5 @@ FROM python:3-slim WORKDIR /usr/src/app -COPY requirements.txt ./ -RUN pip install --no-cache-dir -r requirements.txt \ - && rm -rf * \ No newline at end of file +COPY ./ ./ +RUN pip install --no-cache-dir . \ No newline at end of file diff --git a/HISTORY.md b/HISTORY.md index d8bcebc..ca4a037 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,6 @@ +# 0.4 +- global command "pipeline-mermaid" + # 0.3 - support repeated jobs diff --git a/README.md b/README.md index 049110d..169eab0 100644 --- a/README.md +++ b/README.md @@ -8,29 +8,32 @@ Useful tool to show Gitlab pipeline as mermaid -## install - -```commandline -pip install pipeline-mermaid -``` - #### required environments - `GITLAB_API_TOKEN` - gitlab api token ## Using +Show current pipeline in merge request notes. [Example merge request](https://gitlab.com/Nov1kov/pipeline_to_mermaid/-/merge_requests/4) + ### in .gitlab-ci.yml ```yml notify merge request: + image: registry.gitlab.com/nov1kov/pipeline_to_mermaid:0.4 stage: deploy only: - merge_requests script: - - python -m pipeline_mermaid.gitlab_helper show_current_pipeline + - pipeline-mermaid show_current_pipeline +``` + +### as python package + +```commandline +pip install pipeline-mermaid +pipeline-mermaid show_current_pipeline ``` -Show current pipeline in merge request notes. [Example merge request](https://gitlab.com/Nov1kov/pipeline_to_mermaid/-/merge_requests/4) ## Gitlab pipeline as mermaid @@ -98,6 +101,7 @@ section deploy ### mermaid - interactions https://mermaid-js.github.io/mermaid/diagrams-and-syntax-and-examples/gantt.html#interaction - state +- docker implement ### documentaion - https://pdoc3.github.io/pdoc/ diff --git a/pipeline-mermaid b/pipeline-mermaid new file mode 100644 index 0000000..bfa621b --- /dev/null +++ b/pipeline-mermaid @@ -0,0 +1,9 @@ +#!/usr/bin/env python + +import sys + +from pipeline_mermaid.gitlab_helper import GitlabHelper + +if __name__ == "__main__": + gl = GitlabHelper() + result = eval("GitlabHelper." + sys.argv[1])(gl, *sys.argv[2:]) \ No newline at end of file diff --git a/setup.py b/setup.py index 3a17fa1..bcb235a 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,5 @@ +import os + from setuptools import setup, find_packages with open('README.md') as readme_file: @@ -8,7 +10,7 @@ setup_args = dict( name='pipeline_mermaid', - version='0.3', + version=os.environ['PROJECT_VERSION'], description='Useful tool to show Gitlab pipeline as mermaid', long_description_content_type="text/markdown", long_description=README + '\n\n' + HISTORY, @@ -18,7 +20,8 @@ author_email='spellh1@gmail.com', keywords=['pipeline', 'mermaid', 'Gitlab'], url='https://github.com/Nov1kov/pipeline_to_mermaid', - download_url='https://pypi.org/project/pipeline-mermaid/' + download_url='https://pypi.org/project/pipeline-mermaid/', + scripts=['pipeline-mermaid'] ) install_requires = [