Loading .gitlab-ci.yml +1 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ documentation: entrypoint: [""] stage: build script: - python3 builder/builder.py - mkdocs build -d ./public artifacts: when: always Loading builder/builder.py 0 → 100644 +109 −0 Original line number Diff line number Diff line #!/usr/bin/env python3 # This script is used to build the documentation that hub.go2scale.com will be using for every job added to the hub # Directory skeleton for a job: # ── jobs # └── <job_name> # ├── <job_name>.yml # ├── LICENSE # ├── README.md # └── versions # ├── 0.0.1.md # ├── 0.0.2.md # └──... from pathlib import Path from os import listdir from yaml import full_load from jinja2 import Environment, FileSystemLoader # Job variables jobs_dir = "jobs" mkdocs_dir = "docs" job_changelog_dir = "versions" job_description_file = "README.md" job_license_file = "LICENSE" mk_changelog_wrapper = "\n## Changelog\n\n* **[latest]**(<LATEST_RELEASE>)\n" mk_license_wrapper = "??? License\n" mkdocs_job_content = "" # Index variables builder_dir = "builder" template_dir = "templates" template_name = "index.md.j2" index_file = "index.md" index = {"static_tests": [], "build": [], "dynamic_tests": [], "review": [], "deployment": []} def get_conf(job_path, job_name): # Load yaml file with open(job_path + "/" + job_name + ".yml") as file: return full_load(file) def add_description(job_path, job_name): # Concatenate description to final file global mkdocs_job_content with open(job_path + "/" + job_description_file) as file: mkdocs_job_content += file.read() def add_changelog(job_path, job_name): # Concatenate changelog to final file global mkdocs_job_content mkdocs_job_content += mk_changelog_wrapper # For now, we are just getting the latest release, but we will be adding a full link to the release later latest_release = listdir(job_path + "/" + job_changelog_dir)[-1][0:-3] mkdocs_job_content = mkdocs_job_content.replace("<LATEST_RELEASE>", latest_release) for release in listdir(job_path + "/" + job_changelog_dir)[::-1]: with open(job_path + "/" + job_changelog_dir + "/" + release) as file: mkdocs_job_content += file.read() # TODO replace> <include tag by the link to the release # Adding a new line for consistency mkdocs_job_content += "\n" def add_license(job_path, job_name): # Concatenate license to final file global mkdocs_job_content mkdocs_job_content += mk_license_wrapper with open(job_path + "/" + job_license_file) as file: for line in file.readlines(): mkdocs_job_content += " " + line def create_job_doc(job): job_path = jobs_dir + "/" + job # Getting conf for indexing conf = get_conf(job_path, job) index[conf["default_stage"]].append(conf) mkdocs_file_path = mkdocs_dir + "/" + jobs_dir + "/" + conf["default_stage"] + "/" + job + ".md" add_description(job_path, job) add_changelog(job_path, job) add_license(job_path, job) # Write final file with open(mkdocs_file_path, 'w+') as file: file.write(mkdocs_job_content) if __name__ == "__main__": # Iterate over every directories in jobs directory to create their job.md for the documentation ### TO EDIT # for job in listdir(jobs_dir): job = "python_test" ### create_job_doc(job) # Using jinja2 with a template to create the index env = Environment(loader=FileSystemLoader(builder_dir + "/" + 'templates')) template = env.get_template(template_name) index_content = template.render(index=index) with open(mkdocs_dir + "/" + index_file, "w+") as file: file.write(index_content) builder/templates/index.md.j2 0 → 100644 +43 −0 Original line number Diff line number Diff line # 🗂 Index Jobs index. They are sorted using the [HUB default stages](/getting-started#stages). ## 🔎 Static tests | Name | Description | | ---- | ----------- | {% for job in index["static_tests"] -%} | {% if job.icon is defined -%} {{ job.icon }} {% endif %}[{{- job.name }}](https://hub.go2scale.io/jobs/static_tests/{{ job.name }}/) | {{ job.description }} | {% endfor %} ## 📦 Build | Name | Description | | ---- | ----------- | {% for job in index["build"] -%} | {% if job.icon is defined -%} {{ job.icon }} {% endif %}[{{- job.name }}](https://hub.go2scale.io/jobs/build/{{ job.name }}/) | {{ job.description }} | {% endfor %} ## 🛡 Dynamic tests | Name | Description | | ---- | ----------- | {% for job in index["dynamic_tests"] -%} | {% if job.icon is defined -%} {{ job.icon }} {% endif %}[{{- job.name }}](https://hub.go2scale.io/jobs/dynamic_tests/{{ job.name }}/) | {{ job.description }} | {% endfor %} ## 🙋 Review | Name | Description | | ---- | ----------- | {% for job in index["review"] -%} | {% if job.icon is defined -%} {{ job.icon }} {% endif %}[{{- job.name }}](https://hub.go2scale.io/jobs/review/{{ job.name }}/) | {{ job.description }} | {% endfor %} ## 🚀 Deployment | Name | Description | | ---- | ----------- | {% for job in index["deployment"] -%} | {% if job.icon is defined -%} {{ job.icon }} {% endif %}[{{- job.name }}](https://hub.go2scale.io/jobs/deployment/{{ job.name }}/) | {{ job.description }} | {% endfor %} docs/jobs/index.md.old 0 → 100644 +37 −0 Original line number Diff line number Diff line # 🗂 Index Jobs index. They are sorted using the [HUB default stages](/getting-started#stages). ## 🔎 Static tests | Name | Description | | ---- | ----------- | | 🐨 [Coala](/jobs/static_tests/coala) | Check code quality using Coala | ## 📦 Build | Name | Description | | ---- | ----------- | | 📒 [ApiDoc](/jobs/build/apidoc) | Creates a HTML documentation from API annotations in source code | | 🐳 [Docker](/jobs/build/docker) | Build and publish Docker image using Kaniko | | 📃 [Mkdocs](/jobs/build/mkdocs) | Build documentation from markdown to HTML using Mkdocs| ## 🛡 Dynamic tests | Name | Description | | ---- | ----------- | | 🧱 [Trivy image analysis](/jobs/dynamic_tests/trivy_image) | Run a security analysis on docker image using Trivy | ## 🙋 Review | Name | Description | | ---- | ----------- | | ☸️ [Helm](/jobs/deployment/helm) | Deploy a review environment on Kubernetes using a Helm chart | ## 🚀 Deployment | Name | Description | | ---- | ----------- | | ☸️ [Helm](/jobs/deployment/helm) | Deploy on Kubernetes using a Helm chart | | 🦊 [Pages](/jobs/deployment/pages) | Build and publish Docker image using Kaniko | docs/jobs/static_tests/python_test.md→jobs/python_test/Description.md +0 −5 Original line number Diff line number Diff line Loading @@ -51,8 +51,3 @@ python_tests: variables: TEST_FRAMEWORK: "nosetests" ``` ## Versions * **Latest** (current -> `2020-09-09_1`) : `https://jobs.go2scale.io/latest/python_test.yml` * **Tag `2020-09-09_1`** (initial version) : `https://jobs.go2scale.io/2020-09-09_1/python_tests.yml` Loading
.gitlab-ci.yml +1 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ documentation: entrypoint: [""] stage: build script: - python3 builder/builder.py - mkdocs build -d ./public artifacts: when: always Loading
builder/builder.py 0 → 100644 +109 −0 Original line number Diff line number Diff line #!/usr/bin/env python3 # This script is used to build the documentation that hub.go2scale.com will be using for every job added to the hub # Directory skeleton for a job: # ── jobs # └── <job_name> # ├── <job_name>.yml # ├── LICENSE # ├── README.md # └── versions # ├── 0.0.1.md # ├── 0.0.2.md # └──... from pathlib import Path from os import listdir from yaml import full_load from jinja2 import Environment, FileSystemLoader # Job variables jobs_dir = "jobs" mkdocs_dir = "docs" job_changelog_dir = "versions" job_description_file = "README.md" job_license_file = "LICENSE" mk_changelog_wrapper = "\n## Changelog\n\n* **[latest]**(<LATEST_RELEASE>)\n" mk_license_wrapper = "??? License\n" mkdocs_job_content = "" # Index variables builder_dir = "builder" template_dir = "templates" template_name = "index.md.j2" index_file = "index.md" index = {"static_tests": [], "build": [], "dynamic_tests": [], "review": [], "deployment": []} def get_conf(job_path, job_name): # Load yaml file with open(job_path + "/" + job_name + ".yml") as file: return full_load(file) def add_description(job_path, job_name): # Concatenate description to final file global mkdocs_job_content with open(job_path + "/" + job_description_file) as file: mkdocs_job_content += file.read() def add_changelog(job_path, job_name): # Concatenate changelog to final file global mkdocs_job_content mkdocs_job_content += mk_changelog_wrapper # For now, we are just getting the latest release, but we will be adding a full link to the release later latest_release = listdir(job_path + "/" + job_changelog_dir)[-1][0:-3] mkdocs_job_content = mkdocs_job_content.replace("<LATEST_RELEASE>", latest_release) for release in listdir(job_path + "/" + job_changelog_dir)[::-1]: with open(job_path + "/" + job_changelog_dir + "/" + release) as file: mkdocs_job_content += file.read() # TODO replace> <include tag by the link to the release # Adding a new line for consistency mkdocs_job_content += "\n" def add_license(job_path, job_name): # Concatenate license to final file global mkdocs_job_content mkdocs_job_content += mk_license_wrapper with open(job_path + "/" + job_license_file) as file: for line in file.readlines(): mkdocs_job_content += " " + line def create_job_doc(job): job_path = jobs_dir + "/" + job # Getting conf for indexing conf = get_conf(job_path, job) index[conf["default_stage"]].append(conf) mkdocs_file_path = mkdocs_dir + "/" + jobs_dir + "/" + conf["default_stage"] + "/" + job + ".md" add_description(job_path, job) add_changelog(job_path, job) add_license(job_path, job) # Write final file with open(mkdocs_file_path, 'w+') as file: file.write(mkdocs_job_content) if __name__ == "__main__": # Iterate over every directories in jobs directory to create their job.md for the documentation ### TO EDIT # for job in listdir(jobs_dir): job = "python_test" ### create_job_doc(job) # Using jinja2 with a template to create the index env = Environment(loader=FileSystemLoader(builder_dir + "/" + 'templates')) template = env.get_template(template_name) index_content = template.render(index=index) with open(mkdocs_dir + "/" + index_file, "w+") as file: file.write(index_content)
builder/templates/index.md.j2 0 → 100644 +43 −0 Original line number Diff line number Diff line # 🗂 Index Jobs index. They are sorted using the [HUB default stages](/getting-started#stages). ## 🔎 Static tests | Name | Description | | ---- | ----------- | {% for job in index["static_tests"] -%} | {% if job.icon is defined -%} {{ job.icon }} {% endif %}[{{- job.name }}](https://hub.go2scale.io/jobs/static_tests/{{ job.name }}/) | {{ job.description }} | {% endfor %} ## 📦 Build | Name | Description | | ---- | ----------- | {% for job in index["build"] -%} | {% if job.icon is defined -%} {{ job.icon }} {% endif %}[{{- job.name }}](https://hub.go2scale.io/jobs/build/{{ job.name }}/) | {{ job.description }} | {% endfor %} ## 🛡 Dynamic tests | Name | Description | | ---- | ----------- | {% for job in index["dynamic_tests"] -%} | {% if job.icon is defined -%} {{ job.icon }} {% endif %}[{{- job.name }}](https://hub.go2scale.io/jobs/dynamic_tests/{{ job.name }}/) | {{ job.description }} | {% endfor %} ## 🙋 Review | Name | Description | | ---- | ----------- | {% for job in index["review"] -%} | {% if job.icon is defined -%} {{ job.icon }} {% endif %}[{{- job.name }}](https://hub.go2scale.io/jobs/review/{{ job.name }}/) | {{ job.description }} | {% endfor %} ## 🚀 Deployment | Name | Description | | ---- | ----------- | {% for job in index["deployment"] -%} | {% if job.icon is defined -%} {{ job.icon }} {% endif %}[{{- job.name }}](https://hub.go2scale.io/jobs/deployment/{{ job.name }}/) | {{ job.description }} | {% endfor %}
docs/jobs/index.md.old 0 → 100644 +37 −0 Original line number Diff line number Diff line # 🗂 Index Jobs index. They are sorted using the [HUB default stages](/getting-started#stages). ## 🔎 Static tests | Name | Description | | ---- | ----------- | | 🐨 [Coala](/jobs/static_tests/coala) | Check code quality using Coala | ## 📦 Build | Name | Description | | ---- | ----------- | | 📒 [ApiDoc](/jobs/build/apidoc) | Creates a HTML documentation from API annotations in source code | | 🐳 [Docker](/jobs/build/docker) | Build and publish Docker image using Kaniko | | 📃 [Mkdocs](/jobs/build/mkdocs) | Build documentation from markdown to HTML using Mkdocs| ## 🛡 Dynamic tests | Name | Description | | ---- | ----------- | | 🧱 [Trivy image analysis](/jobs/dynamic_tests/trivy_image) | Run a security analysis on docker image using Trivy | ## 🙋 Review | Name | Description | | ---- | ----------- | | ☸️ [Helm](/jobs/deployment/helm) | Deploy a review environment on Kubernetes using a Helm chart | ## 🚀 Deployment | Name | Description | | ---- | ----------- | | ☸️ [Helm](/jobs/deployment/helm) | Deploy on Kubernetes using a Helm chart | | 🦊 [Pages](/jobs/deployment/pages) | Build and publish Docker image using Kaniko |
docs/jobs/static_tests/python_test.md→jobs/python_test/Description.md +0 −5 Original line number Diff line number Diff line Loading @@ -51,8 +51,3 @@ python_tests: variables: TEST_FRAMEWORK: "nosetests" ``` ## Versions * **Latest** (current -> `2020-09-09_1`) : `https://jobs.go2scale.io/latest/python_test.yml` * **Tag `2020-09-09_1`** (initial version) : `https://jobs.go2scale.io/2020-09-09_1/python_tests.yml`