-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from miketrebilcock/build
Initiate Commit
- Loading branch information
Showing
4 changed files
with
146 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Lint Code Base | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: read | ||
statuses: write | ||
|
||
jobs: | ||
lint: | ||
name: Example Diagrams | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: install nightly | ||
run: | | ||
rustup set profile minimal | ||
rustup toolchain install nightly | ||
shell: bash | ||
- name: build pymermaider | ||
run: | | ||
git clone https://github.com/diceroll123/pymermaider | ||
cd pymermaider | ||
cargo build --release | ||
shell: bash | ||
- name: run pymermaider | ||
run: | | ||
pymermaider/target/release/pymermaider | ||
shell: bash | ||
- name: upload artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: mermaid-diagrams | ||
path: | ||
pymermaider/target/release/output/*.md | ||
- name: Upload mermaid md file diagram into PR | ||
uses: actions/github-script@v7 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const fs = require('fs'); | ||
const body = fs.readFileSync('pymermaider/target/release/output/*.md', 'utf8'); | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: '```mermaid\n' + body + '\n```' | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# python-code-visualiser | ||
## Overview | ||
|
||
Python Code Visualiser is a github action that will create mermaid class diagrams of the a repo. The diagram can be posted to a PR as a comment to assist with Code Review, or just add as an artifact. | ||
|
||
The repo makes use of the fantastic [pymermaider](https://github.com/diceroll123/pymermaider) to create the diagrams. | ||
|
||
## Usage | ||
### Permission | ||
|
||
The following workflow permissions are necessary: | ||
|
||
```yml | ||
permissions: | ||
contents: read | ||
statuses: write | ||
``` | ||
### Inputs | ||
`python-code-visualiser` uses the following inputs: | ||
|
||
| Name | Description | Required | Default | | ||
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------- | -------------- | | ||
| `gh-token` | `GITHUB_TOKEN` (permissions `contents: write` and `pull-requests: write`) or a `repo` scoped [Personal Access Token (PAT)](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token). | no | `GITHUB_TOKEN` | | ||
|
||
## Outputs | ||
|
||
## Contributing | ||
|
||
Contributions are more than welcome, just make a PR and we'll go from there! | ||
|
||
## License | ||
|
||
This project is licensed under the MIT license. Please see the | ||
[LICENSE](LICENSE) file for more details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: python-code-visualiser | ||
author: mike@trebilcock.net | ||
description: 'Create Mermaid diagrams from Python code' | ||
branding: | ||
icon: 'file-text' | ||
color: 'green' | ||
inputs: | ||
gh-token: | ||
description: 'GITHUB_TOKEN or a `repo` scoped Personal Access Token (PAT)' | ||
default: ${{ github.token }} | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: install nightly | ||
run: | | ||
rustup set profile minimal | ||
rustup toolchain install nightly | ||
shell: bash | ||
- name: build pymermaider | ||
run: | | ||
git clone https://github.com/diceroll123/pymermaider | ||
cd pymermaider | ||
cargo build --release | ||
shell: bash | ||
- name: run pymermaider | ||
run: | | ||
pymermaider/target/release/pymermaider | ||
shell: bash | ||
- name: upload artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: mermaid-diagrams | ||
path: | ||
pymermaider/target/release/output/*.md | ||
- name: Upload mermaid md file diagram into PR | ||
uses: actions/github-script@v7 | ||
with: | ||
github-token: ${{ inputs.gh-token }} | ||
script: | | ||
const fs = require('fs'); | ||
const body = fs.readFileSync('pymermaider/target/release/output/*.md', 'utf8'); | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: '```mermaid\n' + body + '\n```' | ||
}) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Simple: | ||
def __init__(self): | ||
self.x = 1 | ||
self.y = 2 | ||
|
||
def add(self): | ||
return self.x + self.y |