mirror of
https://staging.allspice.dev/AllSpice-Demos/Actions-demo.git
synced 2025-04-23 17:03:42 +00:00
Add documentation workflow
This commit is contained in:
parent
3f5cada2d4
commit
b252c4e6a0
.allspice
70
.allspice/utils/py-allspice-documentation.py
Normal file
70
.allspice/utils/py-allspice-documentation.py
Normal file
@ -0,0 +1,70 @@
|
||||
# save_design_review.py
|
||||
# Uses py-allspice + AllSpice API to save all design review comments to a markdown file
|
||||
from allspice import AllSpice, DesignReview
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
|
||||
print("Starting Test")
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="Allspice_API_BIST", description="Test connection and execution of API actions"
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--allspice_hub_url",
|
||||
help="The URL of your AllSpice Hub instance. Defaults to https://hub.allspice.io.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--allspice_token",
|
||||
help="Your AllSpice application token. Generate a token: https://hub.allspice.io/user/settings/applications",
|
||||
)
|
||||
|
||||
print("Parsing args")
|
||||
args = parser.parse_args()
|
||||
|
||||
auth_token = args.allspice_token
|
||||
if auth_token is None:
|
||||
print("Please supply a token with --allspice_token <your_token> Generate a token: https://hub.allspice.io/user/settings/applications")
|
||||
sys.exit(1)
|
||||
print(f"Auth token {auth_token}")
|
||||
|
||||
if args.allspice_hub_url is None:
|
||||
allspice = AllSpice(token_text="https://hub.allspice.io")
|
||||
else:
|
||||
try:
|
||||
allspice = AllSpice(
|
||||
token_text=auth_token, allspice_hub_url=args.allspice_hub_url
|
||||
)
|
||||
except Exception as e:
|
||||
print("Error")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
## Testing connection and authentication
|
||||
print("Finish making connection")
|
||||
# Test connection and key
|
||||
print("AllSpice Version: " + allspice.get_version())
|
||||
|
||||
# Test private API call
|
||||
print("API-Token belongs to user: " + allspice.get_user().username)
|
||||
|
||||
design_review = DesignReview.request(allspice, args.repo_owner, args.repo_name, args.dr)
|
||||
|
||||
file_name = "py-allspice-documentation.md"
|
||||
|
||||
def get_attributes(obj):
|
||||
return [attr for attr in dir(obj) if not attr.startswith('_')]
|
||||
|
||||
# Write string to file
|
||||
def write_to_file(file_name, string):
|
||||
with open(file_name, 'a') as f:
|
||||
f.write(string)
|
||||
f.write("\n")
|
||||
f.close()
|
||||
|
||||
|
||||
repository = allspice.get_repo("AllSpice-Demos", "API-Demo")
|
||||
write_to_file(get_attributes())
|
||||
|
||||
print("End-of-file")
|
48
.allspice/workflows/xx-Py-allspice-documenation.yml
Normal file
48
.allspice/workflows/xx-Py-allspice-documenation.yml
Normal file
@ -0,0 +1,48 @@
|
||||
|
||||
# Py-allspice documentation workflow
|
||||
# py-allspice https://github.com/AllSpiceIO/py-allspice
|
||||
# AllSpice Actions documentation: https://learn.allspice.io/docs/actions-cicd
|
||||
|
||||
name: Py-allspice documentation
|
||||
on:
|
||||
push:
|
||||
issues:
|
||||
types: [opened, closed, reopened]
|
||||
|
||||
jobs:
|
||||
Py-allspice documentation:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Get repository owner
|
||||
id: get_owner
|
||||
run: echo "::set-output name=owner::$(echo ${{ github.repository }} | cut -d'/' -f1)"
|
||||
|
||||
- name: Get repository name
|
||||
id: get_repo
|
||||
run: echo "::set-output name=repo::$(echo ${{ github.repository }} | cut -d'/' -f2)"
|
||||
|
||||
|
||||
# Check out repository code
|
||||
- name: "[📚->🖥️] Check out repository code"
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# Installs python requirements from the requirements.txt file
|
||||
- name: "[🤼->🖥️] Install python requirements"
|
||||
run: pip install -r .allspice/utils/requirements.txt
|
||||
|
||||
# Run the py-allspice self-test script, this will ping the server and verify the API is working
|
||||
# Parameters: ${github.server_url} and ${github.token} are automatic Workflow variables and are used to authenticate the AllSpice API
|
||||
- name: "[🔑->🕸️] Show py-allspice documentation"
|
||||
run: python .allspice/utils/py-allspice-documentation.py --allspice_hub_url ${{ github.server_url }} --allspice_token ${{ github.token }}
|
||||
|
||||
# Print the documentation file to the terminal
|
||||
- name: Show py-allspice documentation 🔎
|
||||
run: cat py-allspice-documentation.md
|
||||
|
||||
# Archive the netlist file as an artifact file
|
||||
- name: Archive code coverage results
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: py-allspice-documentation.md
|
||||
path: py-allspice-documentation.md
|
||||
|
Loading…
Reference in New Issue
Block a user