Skip to content

Commit

Permalink
Create check-depgraph.yml (#509)
Browse files Browse the repository at this point in the history
# Objective

- When the project structure changes, the dependency graph in
`assets/depgraph.svg` needs to be updated. However, there's nothing in
place to enforce this.

# Solution

- Add a GitHub workflow to check this. It automatically leaves a comment
on the pull request containing the new file.
  • Loading branch information
rj00a authored Aug 31, 2023
1 parent 1cc5545 commit 5023370
Show file tree
Hide file tree
Showing 2 changed files with 193 additions and 127 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/check-depgraph.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Check Depgraph

on:
pull_request:
branches: [ "main" ]

env:
CARGO_TERM_COLOR: always

permissions:
# Needed in order to leave comments on pull requests.
pull-requests: 'write'

jobs:
check-depgraph:
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v3

- name: Install cargo-depgraph
uses: baptiste0928/[email protected]
with:
crate: cargo-depgraph

- name: Install graphviz
run: sudo apt update && sudo apt install -y graphviz

- name: Generate new depgraph
run: cargo depgraph --workspace-only | tred | dot -Tsvg -o assets/depgraph.svg

- name: Check depgraph diff
run: git diff --exit-code assets/depgraph.svg > assets/depgraph.patch

- name: Create comment file
if: ${{ failure() }}
run: |
echo "It looks like this pull request changed the workspace structure. \
Please replace \`assets/depgraph.svg\` with the following text:
<details>
<summary>depgraph.svg (Don't forget the trailing newline)</summary>
\`\`\`html
$(cat assets/depgraph.svg)
\`\`\`
</details>
For reference, here is a diff against the old \`depgraph.svg\`:
<details>
\`\`\`patch
$(cat assets/depgraph.patch)
\`\`\`
</details>" >> pr-comment.txt
- name: Create pull request comment
uses: marocchino/sticky-pull-request-comment@v2
if: ${{ failure() }}
with:
recreate: true
header: depgraph
path: pr-comment.txt
Loading

0 comments on commit 5023370

Please sign in to comment.