Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

next
sh 71 lines 2.27 KB
Raw
1 #!/usr/bin/env bash
2 #
3 # Report orphaned CI plumbing — the GitHub Actions analogue of the "dead file"
4 # problem knip/vulture catch for TS/Python:
5 #
6 # * composite actions under .github/actions/* that no workflow `uses:`
7 # * reusable workflows (on: workflow_call) that nothing calls AND that have
8 # no self-trigger (push/pull_request/schedule/...), i.e. truly unreachable
9 #
10 # Report-only: prints findings and always exits 0 so it never blocks CI on a
11 # heuristic. Vet anything it prints by hand before deleting.
12
13 set -uo pipefail
14
15 repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
16 workflows_dir="$repo_root/.github/workflows"
17 actions_dir="$repo_root/.github/actions"
18
19 findings=0
20
21 note() {
22 findings=$((findings + 1))
23 echo " - $1"
24 }
25
26 echo "### Orphaned CI check"
27 echo ""
28 echo "Composite actions with no callers:"
29
30 if [[ -d "$actions_dir" ]]; then
31 for action_yml in "$actions_dir"/*/action.yml "$actions_dir"/*/action.yaml; do
32 [[ -f "$action_yml" ]] || continue
33 name="$(basename "$(dirname "$action_yml")")"
34 # A caller references it as `uses: ./.github/actions/<name>`.
35 if ! grep -rqs "uses:.*\.github/actions/$name\b" "$workflows_dir" "$actions_dir"; then
36 note "action \`$name\` (.github/actions/$name) is referenced by no workflow"
37 fi
38 done
39 fi
40 [[ $findings -eq 0 ]] && echo " _(none)_"
41
42 before_wf=$findings
43 echo ""
44 echo "Reusable workflows that are unreachable:"
45
46 for wf in "$workflows_dir"/*.yml "$workflows_dir"/*.yaml; do
47 [[ -f "$wf" ]] || continue
48 # Only reusable workflows are candidates.
49 grep -qs "workflow_call:" "$wf" || continue
50 base="$(basename "$wf")"
51 # Called by another workflow?
52 if grep -rqs "uses:.*\.github/workflows/$base\b" "$workflows_dir"; then
53 continue
54 fi
55 # Self-triggering (has a real event trigger besides workflow_call)?
56 if grep -Eqs "^[[:space:]]+(push|pull_request|schedule|workflow_dispatch|release|issues|issue_comment|repository_dispatch|merge_group):" "$wf"; then
57 continue
58 fi
59 note "workflow \`$base\` exposes workflow_call but has no caller and no self-trigger"
60 done
61 [[ $findings -eq $before_wf ]] && echo " _(none)_"
62
63 echo ""
64 if [[ $findings -eq 0 ]]; then
65 echo "No orphaned CI plumbing found."
66 else
67 echo "Found $findings orphaned CI item(s) above — review before removing."
68 fi
69
70 # Report-only.
71 exit 0