mirror of
https://github.com/AllSpiceIO/run-wireviz.git
synced 2025-04-01 00:16:33 +00:00
Initialize
This commit is contained in:
commit
422c1248c3
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.venv
|
10
Dockerfile
Normal file
10
Dockerfile
Normal file
@ -0,0 +1,10 @@
|
||||
FROM python:3.11-slim
|
||||
|
||||
RUN apt-get update && apt-get install -y graphviz
|
||||
|
||||
COPY requirements.txt /requirements.txt
|
||||
COPY entrypoint.py /entrypoint.py
|
||||
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
ENTRYPOINT ["/entrypoint.py"]
|
21
LICENSE.txt
Normal file
21
LICENSE.txt
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 AllSpice
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
83
README.md
Normal file
83
README.md
Normal file
@ -0,0 +1,83 @@
|
||||
# Run WireViz
|
||||
|
||||
Generate wiring diagrams using [WireViz](https://github.com/wireviz/WireViz/)
|
||||
in your CI workflows.
|
||||
|
||||
## Usage
|
||||
|
||||
Add the following step to your workflow:
|
||||
|
||||
```yaml
|
||||
- name: Run WireViz
|
||||
uses: AllSpiceIO/run-wireviz@v0.4
|
||||
with:
|
||||
# The input file(s) to process
|
||||
files: "path/to/your/input/file.yml"
|
||||
```
|
||||
|
||||
### Notes
|
||||
|
||||
Your input file must be present in the workspace. If it's not already there,
|
||||
you can use the [`actions/checkout`](https://github.com/actions/checkout)
|
||||
action to clone your repository.
|
||||
|
||||
This action's versions will match the version of WireViz it is running. For
|
||||
example, the tag 0.4.1 will match WireViz 0.4.1. Tags with only a major or
|
||||
minor version will match all versions with that major or minor version of this
|
||||
action.
|
||||
|
||||
### Customizing WireViz Output
|
||||
|
||||
You can customize the WireViz output using various input parameters:
|
||||
|
||||
```yaml
|
||||
- name: Run WireViz with Custom Options
|
||||
uses: AllSpiceIO/run-wireviz@v0.4
|
||||
with:
|
||||
files: "path/to/your/input/file.yml"
|
||||
format: "hps"
|
||||
prepend: "path/to/prepend.yml"
|
||||
output_dir: "output"
|
||||
output_name: "my_wireviz_output"
|
||||
```
|
||||
|
||||
These options correspond roughly to the same as the WireViz CLI. You can see the options exposed by WireViz by running:
|
||||
|
||||
```sh
|
||||
wireviz --help
|
||||
```
|
||||
|
||||
with the same version of WireViz as this action. To run a specific version of
|
||||
WireViz in an isolated environment, consider
|
||||
[uvx.](https://docs.astral.sh/uv/guides/tools/)
|
||||
|
||||
As of the current version, the following options are available:
|
||||
|
||||
- `files`: (Required) Input file(s) to process.
|
||||
- `format`: Output formats (g: GV, h: HTML, p: PNG, s: SVG, t: TSV). Default: 'hpst'
|
||||
- `prepend`: YAML file to prepend to the input file.
|
||||
- `output_dir`: Directory to use for output files.
|
||||
- `output_name`: File name (without extension) to use for output files.
|
||||
|
||||
#### Output Formats
|
||||
|
||||
The `format` input accepts a string containing one or more of the following characters to specify which file types to output:
|
||||
|
||||
- `g`: GraphViz (GV)
|
||||
- `h`: HTML
|
||||
- `p`: PNG
|
||||
- `s`: SVG
|
||||
- `t`: TSV (Tab-Separated Values, used for BOM.)
|
||||
|
||||
For example, to generate HTML, PNG, and SVG outputs, use `format: 'hps'`.
|
||||
|
||||
#### Working with Multiple Input Files
|
||||
|
||||
You can process multiple input files by providing a space-separated list:
|
||||
|
||||
```yaml
|
||||
- name: Run WireViz on Multiple Files
|
||||
uses: AllSpiceIO/run-wireviz@v0.4
|
||||
with:
|
||||
files: "file1.yml file2.yml file3.yml"
|
||||
```
|
35
action.yml
Normal file
35
action.yml
Normal file
@ -0,0 +1,35 @@
|
||||
name: "Run WireViz"
|
||||
description: "Run WireViz on input files with configurable options"
|
||||
|
||||
inputs:
|
||||
files:
|
||||
description: "Input file(s) to process"
|
||||
required: true
|
||||
format:
|
||||
description: "Output formats (g: GV, h: HTML, p: PNG, s: SVG, t: TSV)"
|
||||
required: false
|
||||
default: "hpst"
|
||||
prepend:
|
||||
description: "YAML file to prepend to the input file"
|
||||
required: false
|
||||
output_dir:
|
||||
description: "Directory to use for output files"
|
||||
required: false
|
||||
output_name:
|
||||
description: "File name (without extension) to use for output files"
|
||||
required: false
|
||||
|
||||
runs:
|
||||
using: "docker"
|
||||
image: "Dockerfile"
|
||||
args:
|
||||
- "-f"
|
||||
- ${{ github.workspace }}/${{ inputs.files }}
|
||||
- "-m"
|
||||
- ${{ inputs.format }}
|
||||
- "-p"
|
||||
- ${{ inputs.prepend }}
|
||||
- "-o"
|
||||
- ${{ inputs.output_dir }}
|
||||
- "-n"
|
||||
- ${{ inputs.output_name }}
|
51
entrypoint.py
Executable file
51
entrypoint.py
Executable file
@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Run WireViz with configurable options"
|
||||
)
|
||||
parser.add_argument("-f", "--files", required=True, help="Input file(s) to process")
|
||||
parser.add_argument(
|
||||
"-m", "--format", help="Output formats (g: GV, h: HTML, p: PNG, s: SVG, t: TSV)"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-p", "--prepend", help="YAML file to prepend to the input file"
|
||||
)
|
||||
parser.add_argument("-o", "--output-dir", help="Directory to use for output files")
|
||||
parser.add_argument(
|
||||
"-n",
|
||||
"--output-name",
|
||||
help="File name (without extension) to use for output files",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
command = ["wireviz"]
|
||||
|
||||
if args.format:
|
||||
command.extend(["-f", args.format])
|
||||
if args.prepend:
|
||||
command.extend(["-p", args.prepend])
|
||||
if args.output_dir:
|
||||
command.extend(["-o", args.output_dir])
|
||||
if args.output_name:
|
||||
command.extend(["-O", args.output_name])
|
||||
|
||||
command.extend(args.files.split())
|
||||
|
||||
print(f"Running command: {' '.join(command)}")
|
||||
|
||||
try:
|
||||
os.execvp("wireviz", command)
|
||||
except OSError as e:
|
||||
print(f"Error executing WireViz: {e}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@ -0,0 +1 @@
|
||||
wireviz == 0.4.1
|
Loading…
Reference in New Issue
Block a user