From 5023370e71508932c4d0664f8991b93875ff6588 Mon Sep 17 00:00:00 2001 From: Ryan Johnson Date: Thu, 31 Aug 2023 16:20:00 -0700 Subject: [PATCH] Create check-depgraph.yml (#509) # 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. --- .github/workflows/check-depgraph.yml | 65 +++++++ assets/depgraph.svg | 255 ++++++++++++++------------- 2 files changed, 193 insertions(+), 127 deletions(-) create mode 100644 .github/workflows/check-depgraph.yml diff --git a/.github/workflows/check-depgraph.yml b/.github/workflows/check-depgraph.yml new file mode 100644 index 000000000..6f2580e9c --- /dev/null +++ b/.github/workflows/check-depgraph.yml @@ -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/cargo-install@v2.1.0 + 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: + +
+ depgraph.svg (Don't forget the trailing newline) + + \`\`\`html + $(cat assets/depgraph.svg) + + \`\`\` +
+ + For reference, here is a diff against the old \`depgraph.svg\`: + +
+ + \`\`\`patch + $(cat assets/depgraph.patch) + \`\`\` +
" >> 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 diff --git a/assets/depgraph.svg b/assets/depgraph.svg index 012f98927..b140e1ac1 100644 --- a/assets/depgraph.svg +++ b/assets/depgraph.svg @@ -1,378 +1,379 @@ - - - + + - +%3 + 0 - -valence_advancement + +valence_advancement 1 - -valence_server + +valence_server 0->1 - - + + 2 - -valence_entity + +valence_entity 1->2 - - + + 11 - -valence_registry + +valence_registry 1->11 - - + + 10 - -valence_server_common + +valence_server_common 2->10 - - + + 11->10 - - + + 6 - -valence_protocol + +valence_protocol 10->6 - - + + 3 - -valence_math + +valence_math 4 - -valence_nbt + +valence_nbt 5 - -valence_ident + +valence_ident 7 - -valence_generated + +valence_generated 6->7 - - + + 9 - -valence_text + +valence_text 6->9 - - + + 7->3 - - + + 7->5 - - + + 9->4 - - + + 9->5 - - + + 8 - -valence_build_utils + +valence_build_utils 12 - -valence_anvil + +valence_anvil 12->1 - - + + 13 - -valence_boss_bar + +valence_boss_bar 13->1 - - + + 14 - -valence_inventory + +valence_inventory 14->1 - - + + 15 - -valence_lang + +valence_lang 16 - -valence_network + +valence_network 16->1 - - + + 16->15 - - + + 17 - -valence_player_list + +valence_player_list 17->1 - - + + 18 - -valence_scoreboard + +valence_scoreboard 18->1 - - + + 19 - -valence_spatial + +valence_spatial 20 - -valence_weather + +valence_weather 20->1 - - + + 21 - -valence_world_border + +valence_world_border 21->1 - - + + 22 - -dump_schedule + +dump_schedule 23 - -valence + +valence 22->23 - - + + 23->0 - - + + 23->12 - - + + 23->13 - - + + 23->14 - - + + 23->16 - - + + 23->17 - - + + 23->18 - - + + 23->20 - - + + 23->21 - - + + 24 - -packet_inspector + +packet_inspector 24->6 - - + + 25 - -playground + +playground 25->23 - - + + 26 - -stresser + +stresser 26->6 - - + +