Skip to content

Commit

Permalink
docs(website): integrate new feature into docs site Refs, and CI Buil…
Browse files Browse the repository at this point in the history
…d in RTD
  • Loading branch information
boromir674 committed Dec 19, 2023
1 parent 8318453 commit 5dc98ac
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 2 deletions.
1 change: 1 addition & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ build:
- chmod +x ./scripts/gen-workflow-ref.py
- ./scripts/gen-workflow-ref.py ./.github/workflows/docker.yml > ./docs/ref_docker.md
- ./scripts/gen-workflow-ref.py ./.github/workflows/pypi_env.yml > ./docs/ref_pypi_env.md
- ./scripts/gen-workflow-ref.py ./.github/workflows/lint.yml > ./docs/ref_lint.md


# Build documentation in the "docs/" directory with mkdocs
Expand Down
52 changes: 52 additions & 0 deletions docs/ref_lint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Workflow lint.yml

### Trigger Events

If any of the below events occur, the `lint.yml` workflow will be triggered.

- workflow_call

Since there is a `workflow_call` _trigger_event_, this workflow can be triggered (called) by another (caller) workflow.
> Thus, it is a `Reusable Workflow`.

## Reusable Workflow

Event Trigger: `workflow_call`

### Inputs

#### Required Inputs

None

#### Optional Inputs

- `dedicated_branches`
- type: _string_
- Description:
- Default: `master, main, dev`
- `pylint_threshold`
- type: _string_
- Description:
- Default: `8.0`
- `python_version`
- type: _string_
- Description:
- Default: `3.10`
- `run_policy`
- type: _string_
- Description:
- Default: `2`
- `source_code_targets`
- type: _string_
- Description:
- Default: `src`

### Secrets

None

### Outputs

None
9 changes: 8 additions & 1 deletion docs/tests_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ There is a dedicated [`cicd-test`](https://github.com/boromir674/cicd-test) Gith

The `Test Suite` consists of

- a set of [**GA Workflows**](https://github.com/boromir674/cicd-test/tree/main/.github/workflows) that call our [**Docker**](https://github.com/boromir674/automated-workflows/tree/main/.github/workflows/docker.yml) and [**PyPI**](https://github.com/boromir674/automated-workflows/tree/main/.github/workflows/pypi_env.yml) Workflows in various
- a set of [**GA Workflows**](https://github.com/boromir674/cicd-test/tree/main/.github/workflows) that call our [**Docker**](https://github.com/boromir674/automated-workflows/tree/main/.github/workflows/docker.yml), [**PyPI**](https://github.com/boromir674/automated-workflows/tree/main/.github/workflows/pypi_env.yml), and [**Lint**](https://github.com/boromir674/automated-workflows/tree/main/.github/workflows/lint_env.yml) Workflows in various
*Scenarios* and *Situations*
- a set of [**Automated Tests**](https://github.com/boromir674/cicd-test/tree/main/tests), implemented with `Pytest` (Python)
- a *Test Runner* with a CLI (`pytest -n auto`)
Expand All @@ -35,3 +35,10 @@ make the necessary assertions.
| expected green pass | expected red (because scenario involves upload python dist to existing index, without allow_existing set to True) |
| --- | --- |
| [![gg](https://github.com/boromir674/cicd-test/actions/workflows/.github/workflows/pypi_test.yaml/badge.svg)](https://github.com/boromir674/cicd-test/actions/workflows/pypi_test.yaml) | ![](https://github.com/boromir674/cicd-test/actions/workflows/.github/workflows/pypi_test_red.yaml/badge.svg) |


## Lint Workflow Automated Tests

| expected green pass | expected red |
| --- | --- |
| [![gg](https://github.com/boromir674/cicd-test/actions/workflows/.github/workflows/static_code_green.yaml/badge.svg)](https://github.com/boromir674/cicd-test/actions/workflows/static_code_green.yaml) | |
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ nav:
- References:
- "Docker": "ref_docker.md"
- "PyPI": "ref_pypi_env.md"
- "Lint": "ref_lint.md"
- Topics:
- "Test Suite": tests_index.md
- tags: tags.md
Expand Down
16 changes: 15 additions & 1 deletion scripts/gen-workflow-ref.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
class InputArgument(TypedDict):
required: bool # allowed values {True, False}
type: str # common values {'string', 'boolean', 'number'}
default: t.Optional[str] # default value for the input argument

## Resuable Workflow 'secrets' ##
class SecretArgument(TypedDict):
Expand Down Expand Up @@ -133,7 +134,11 @@ def generate_markdown(
## Workflow Inputs ##
markdown_content += f"{'#' * (max_mk_level + 1)} Inputs\n\n"
required_inputs: t.Set[str] = {x for x in inputs.keys() if inputs[x].get("required", False)}

# Required Inputs
markdown_content += f"{'#' * (max_mk_level + 2)} Required Inputs\n\n"
if not required_inputs:
markdown_content += f"None\n"
for input_name in sorted(required_inputs):
markdown_content += f"- `{input_name}`\n"
markdown_content += f" - type: _{inputs[input_name].get('type', 'string')}_\n"
Expand All @@ -142,14 +147,20 @@ def generate_markdown(
# Optional Inputs
optional_inputs: t.Set[str] = {x for x in inputs.keys() if x not in required_inputs}
markdown_content += f"{'#' * (max_mk_level + 2)} Optional Inputs\n\n"
if not optional_inputs:
markdown_content += f"None\n"
for input_name in sorted(optional_inputs):
markdown_content += f"- `{input_name}`\n"
markdown_content += f" - type: _{inputs[input_name].get('type', 'string')}_\n"
markdown_content += f" - Description: {inputs[input_name].get('description', '')}\n"
if inputs[input_name].get("default", None):
markdown_content += f" - Default: `{inputs[input_name]['default']}`\n"
markdown_content += "\n"

## Workflow Secrets ##
markdown_content += f"{'#' * (max_mk_level + 1)} Secrets\n\n"
if not secrets:
markdown_content += f"None\n"
for secret_name, secret_details in sorted(secrets.items(), key=lambda x: x[0]):
markdown_content += f"- `{secret_name}`\n"
markdown_content += f" - type: _{secret_details.get('type', 'string')}_\n"
Expand All @@ -159,12 +170,15 @@ def generate_markdown(

## Workflow Outputs ##
markdown_content += f"{'#' * (max_mk_level + 1)} Outputs\n\n"
if not outputs:
markdown_content += f"None\n"
for output_name, output_details in sorted(outputs.items(), key=lambda x: x[0]):
markdown_content += f"- `{output_name}`\n"
markdown_content += f" - type: _{output_details.get('type', 'string')}_\n"
markdown_content += f" - Value: {output_details.get('value', '')}\n"
markdown_content += f" - Description: {output_details.get('description', '')}\n"
markdown_content += "\n"
# omit last \n
# markdown_content += "\n"

# markdown_content += "### Environments\n\n"
# for environment_name, environment_value in repository_details["environments"].items():
Expand Down

0 comments on commit 5dc98ac

Please sign in to comment.