Skip to content

Commit

Permalink
Add action for creating class diagrams
Browse files Browse the repository at this point in the history
  • Loading branch information
denrase committed Sep 18, 2023
1 parent b074a17 commit 90630c1
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 3 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/diagrams.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: diagrams
on:
# push:
# branches:
# - main
pull_request:

jobs:
diagrams:
runs-on: ubuntu-latest
name: "Create class diagrams of all packages"
steps:
- uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d # pin@v1
with:
sdk: stable

- uses: actions/checkout@v3

- name: dependencies
run: |
dart pub global activate lakos
sudo apt update
sudo apt install graphviz
- name: dart
working-directory: ./dart
run: lakos . -i "{test/**,example/**,example_web/**}" | dot -Tsvg -o class-diagram.svg

- name: flutter
working-directory: ./flutter
run: lakos . -i "{test/**,example/**}" | dot -Tsvg -o class-diagram.svg

- name: dio
working-directory: ./dio
run: lakos . -i "{test/**,example/**}" | dot -Tsvg -o class-diagram.svg

- name: file
working-directory: ./file
run: lakos . -i "{test/**,example/**}" | dot -Tsvg -o class-diagram.svg

- name: sqflite
working-directory: ./sqflite
run: lakos . -i "{test/**,example/**}" | dot -Tsvg -o class-diagram.svg

- name: logging
working-directory: ./logging
run: lakos . -i "{test/**,example/**}" | dot -Tsvg -o class-diagram.svg

# Source: https://stackoverflow.com/a/58035262
# - name: Extract branch name
# shell: bash
# run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
# id: extract_branch

# actions/checkout fetches only a single commit in a detached HEAD state. Therefore
# we need to pass the current branch, otherwise we can't commit the changes.
# GITHUB_HEAD_REF is the name of the head branch. GitHub Actions only sets this for PRs.
# - name: Commit & push
# run: ./scripts/commit-code.sh ${{ steps.extract_branch.outputs.branch }} "Update class diagrams"
2 changes: 1 addition & 1 deletion .github/workflows/format-and-fix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ jobs:
# we need to pass the current branch, otherwise we can't commit the changes.
# GITHUB_HEAD_REF is the name of the head branch. GitHub Actions only sets this for PRs.
- name: Commit & push
run: ./scripts/commit-formatted-code.sh ${{ steps.extract_branch.outputs.branch }}
run: ./scripts/commit-code.sh ${{ steps.extract_branch.outputs.branch }} "Format & fix code"
5 changes: 3 additions & 2 deletions scripts/commit-formatted-code.sh → scripts/commit-code.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
set -euo pipefail

GITHUB_BRANCH="${1}"
COMMIT_MESSAGE="${2}"

if [[ $(git status) == *"nothing to commit"* ]]; then
echo "Nothing to commit. All code formatted correctly."
Expand All @@ -11,6 +12,6 @@ else
git config --global user.email '[email protected]'
git fetch
git checkout ${GITHUB_BRANCH}
git commit -am "Format & fix code"
git push --set-upstream origin ${GITHUB_BRANCH}
git commit -am ${GITHUB_BRANCH}
git push --set-upstream origin ${COMMIT_MESSAGE}
fi

0 comments on commit 90630c1

Please sign in to comment.