Simple generator of gitlab ci file documentation
Project description
Overview
The CI/CD solution by gitlba is great, however it has some limitations. The way how a pipeline is defined is definitelly one of thme. There's nothing woring about YAML itself, but gitlab pipeline is so complex to be written in a markup language.
For instance, let's assume there is the design where we want to trigger a pipeline from web UI or by API call. The pipeline consumes variables as input. There is no way how to define variable's type, options or if it's required or if it shouldn't be overriden. This sort of information is always part of a documentation. This package provides functionality to create simple documentation of workflow section, which can contain all of these infromation.
In my opinion, the workflow section should be part of every clean/nice pipeline definition ("code"). Let's define the naming convention, which covers some scenarios, and all other information write to comment. I know, comments sound awful, but it is the most safe way to achieve what we need.
How does it work
The output of this script is simple description (documentation) of workflow section. It parses workflow section and inserts it to readme file. Currently, output documentation is only as html table.
Readme file
By default, the script inserts generated table in the beggining of the file. However, it is possible to mark position in the file where the table will be inserted. The mark token is <!--PIPELINE_DOCS-->
If token is present, the table is insreted below it.
Variable definition
As mentioned before, we write all parameters of a variable to a comment. Format of a comment is very simple.
- first part describes if variable is required on input. By default a variable is considered as optional. To "set" is as required, put required to the comment - # required
- second part descibes variable's type or valid options.
- type - starts with colon. Typename can be whatever made up. :type
- choices - dev|test
These parts are separated by space. Type and choices must not by combined.
Example
ENV: dev # required dev|test|prod
ACCOUNT_ALIAS: null # required :str
IMAGE_TAG: 0.1.0 # :version
Usage
The tool can be used from command line or imported as module in a code. It requires only two parameters on input:
- path to yaml file containing thw workflow section
- path to documentation file where generated table is inserted to
Command line
The packegs is called gitlabcidocs and consumes following arguments:
- --ci-file [optional]
Path to the file containing workflow section.
Default value is .gitlab-ci.yml - --doc-file [optional]
Path to the output file.
Default value is README.md
python -m gitlabcidocs --ci-file my_workflow.yml --doc-file myREADME.md
Import in code
The module gitlab-ci-docs contains create_docs function. The functions consumes the same arguments as cli tool, but there are no default values set.
import gitlabcidocs
def run_create_docs():
docs = gitlabcidocs.create_docs(
ci_file_path='my_workflow.yml',
docs_file_path='README.md'
)
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 gitlab_ci_docs-0.1.0b2.tar.gz
.
File metadata
- Download URL: gitlab_ci_docs-0.1.0b2.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d45a1547bf215414f0cc7672a47c2d6e5f0228f0023fda5c3cdcb71455f0f024 |
|
MD5 | c3bf451e551ae04ed6efc51b8bbdb791 |
|
BLAKE2b-256 | 46a515408e94b1e3501771434fbd92cdaf20e0aaed43318a78df4d92845ee55c |
File details
Details for the file gitlab_ci_docs-0.1.0b2-py3-none-any.whl
.
File metadata
- Download URL: gitlab_ci_docs-0.1.0b2-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59f94d13813764749c4fa7fdb78eaf0c22e0f0cad054bc2dccdbd67412f274c8 |
|
MD5 | 2321ae7e09498682c4f02304490b27b0 |
|
BLAKE2b-256 | 0224b124d361dea8ecc478a718d696df955cf4815fc69b5e4e813657a5f11681 |