mirror of
https://staging.allspice.dev/AllSpice-Demos/Actions-demo.git
synced 2025-04-23 17:03:42 +00:00
Remove blocking files
This commit is contained in:
parent
5bfabc60a3
commit
4170afd11b
@ -1,84 +0,0 @@
|
||||
# save_design_review.py
|
||||
# Uses py-allspice + AllSpice API to save all design review comments to a markdown file
|
||||
from allspice import AllSpice, DesignReview, Repository
|
||||
import argparse
|
||||
import sys
|
||||
import os
|
||||
import json
|
||||
from enum import Enum
|
||||
|
||||
|
||||
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)
|
||||
|
||||
file_name = "py-allspice-documentation.json"
|
||||
|
||||
def get_attributes(obj):
|
||||
return [attr for attr in dir(obj) if not attr.startswith('_') and not callable(getattr(obj, attr))]
|
||||
|
||||
class CustomEncoder(json.JSONEncoder):
|
||||
def default(self, obj):
|
||||
if isinstance(obj, Enum):
|
||||
return obj.name # Convert Enum to its name
|
||||
if isinstance(obj, type) and issubclass(obj, Enum):
|
||||
return list(obj) # Convert EnumMeta to a list of its members
|
||||
return super().default(obj)
|
||||
|
||||
def write_to_file(file_name, string):
|
||||
with open(file_name, 'w') as f: # Use 'w' mode to overwrite the file
|
||||
f.write(string + os.linesep)
|
||||
|
||||
# Get the repository object
|
||||
repository = Repository.request(allspice, "AllSpice-Demos", "Actions-demo")
|
||||
|
||||
attributes = get_attributes(repository)
|
||||
repository_dict = {attribute: getattr(repository, attribute) for attribute in attributes}
|
||||
|
||||
# Convert the repository dictionary to a JSON string using the custom encoder
|
||||
repository_json = json.dumps(repository_dict, indent=4, cls=CustomEncoder)
|
||||
|
||||
# Write the JSON string to a file
|
||||
write_to_file(file_name, repository_json)
|
||||
|
||||
print("End-of-file")
|
@ -1,117 +0,0 @@
|
||||
# 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",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--repo_owner",
|
||||
help="The owner of the repository",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--repo_name",
|
||||
help="The name of the repository",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--dr",
|
||||
help="The Design Review ID",
|
||||
)
|
||||
|
||||
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)
|
||||
|
||||
if args.repo_owner is None:
|
||||
print("Please supply a repo owner with --repo_owner <repo_owner>")
|
||||
sys.exit(1)
|
||||
|
||||
if args.repo_name is None:
|
||||
print("Please supply a repo name with --repo_name <repo_name>")
|
||||
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 = "design_review_comments.md"
|
||||
|
||||
# Filter out special methods and attributes
|
||||
design_review_attributes = [attr for attr in dir(design_review) if not attr.startswith('_')]
|
||||
|
||||
# Print the public design_review attributes
|
||||
print(f"design_review_attributes: {design_review_attributes}")
|
||||
|
||||
|
||||
# Write Design review details to file
|
||||
# with open(file_name, 'w') as f:
|
||||
# f.write(f"## Design Review: {design_review.title}\n")
|
||||
# f.write(f"State: {design_review.state}\n")
|
||||
# f.write(f"Assignees: {design_review.assignees}\n")
|
||||
# f.write(f"Description: {design_review.description}\n")
|
||||
# f.write(f"Created at: {design_review.created_at}\n")
|
||||
# f.write(f"Updated at: {design_review.updated_at}\n")
|
||||
# f.write(f"### Body:\n{design_review.body}")
|
||||
# f.write("end-of-description\n")
|
||||
|
||||
comments = design_review.get_comments()
|
||||
|
||||
# Filter out special methods and attributes
|
||||
comments_attributes = [attr for attr in dir(comments) if not attr.startswith('__')]
|
||||
|
||||
# Print the public comments attributes
|
||||
print(f"comments_attributes: {comments_attributes}")
|
||||
|
||||
for comment in comments:
|
||||
# write to file
|
||||
with open(file_name, 'a') as f:
|
||||
f.write(f"{comment.body}")
|
||||
# f.write(f"Comment: {comment.text}\n")
|
||||
f.write("\n")
|
||||
|
||||
# Close file
|
||||
f.close()
|
||||
|
||||
|
||||
|
||||
|
||||
print("End test")
|
@ -1,48 +0,0 @@
|
||||
|
||||
# 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: "[🔑->🕸️] Run py-allspice-documentation.py"
|
||||
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 repository attributes 🔎
|
||||
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
|
||||
|
@ -1,52 +0,0 @@
|
||||
|
||||
# Save design review workflow
|
||||
# Saves design review to workflow artifact file
|
||||
# AllSpice Actions documentation: https://learn.allspice.io/docs/actions-cicd
|
||||
name: Save design review
|
||||
on:
|
||||
push:
|
||||
issues:
|
||||
types: [opened, closed, reopened]
|
||||
|
||||
jobs:
|
||||
Save-design-review:
|
||||
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
|
||||
|
||||
- name: "[🔎->📂] List files in repo 🔎"
|
||||
run: |
|
||||
ls -la ${{ github.workspace }}
|
||||
|
||||
# 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: "[🔑->🕸️] Test AllSpice API with py-allspice 🔎"
|
||||
run: python .allspice/utils/save_design_review.py --allspice_hub_url ${{ github.server_url }} --allspice_token ${{ github.token }} --repo_owner ${{ steps.get_owner.outputs.owner }} --repo_name ${{ steps.get_repo.outputs.repo }} --dr 22
|
||||
|
||||
|
||||
# Print the netlist file to the terminal
|
||||
- name: Show Design Review comments 🔎
|
||||
run: cat design_review_comments.md
|
||||
|
||||
# Archive the netlist file as an artifact file
|
||||
- name: Archive code coverage results
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: design_review_comments.md
|
||||
path: design_review_comments.md
|
||||
|
Loading…
Reference in New Issue
Block a user