Skip to content

Commit a6a711e

Browse files
authored
feat(build): added a workflow to find ununsed dependencies (#46)
* feat(build): added a workflow to find ununsed dependencies * fix(build): removed invalid arg and also installed the deps * fix(deps): removed the ext-mbstring unused dependency * fix(dev): added convenience scripts for running the dependency analysis
1 parent 3b719c0 commit a6a711e

File tree

5 files changed

+442
-51
lines changed

5 files changed

+442
-51
lines changed

.github/workflows/pipeline.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ jobs:
7272
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.ref }}
7373
secrets: inherit
7474

75+
check-deps:
76+
name: Run Dependency Checks
77+
uses: ./.github/workflows/unused.yml
78+
with:
79+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.ref }}
80+
secrets: inherit
81+
7582
all-passed:
7683
name: Check Build Status
7784
runs-on: ubuntu-latest
@@ -84,6 +91,7 @@ jobs:
8491
- run-tests
8592
- code-inspection
8693
- build-docker
94+
- check-deps
8795
steps:
8896
- name: Harden runner
8997
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0

.github/workflows/unused.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Dependencies
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
ref:
7+
required: true
8+
type: string
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
lint-dependencies:
15+
permissions:
16+
contents: read
17+
pull-requests: read
18+
runs-on: ubuntu-latest
19+
name: Lint Dependencies
20+
21+
steps:
22+
- name: Harden runner
23+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
24+
with:
25+
egress-policy: audit
26+
27+
- name: Checkout code
28+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
29+
with:
30+
ref: ${{ inputs.ref }}
31+
32+
- name: Install Dependencies
33+
run: composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader
34+
35+
- name: Inspect Dependencies
36+
uses: mridang/action-dependency-insight@v1

composer.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"php": "^8.",
2424
"ext-curl": "*",
2525
"ext-json": "*",
26-
"ext-mbstring": "*",
2726
"guzzlehttp/guzzle": "^7.3",
2827
"guzzlehttp/psr7": "^1.7 || ^2.0",
2928
"firebase/php-jwt": "^6.10.0",
@@ -40,7 +39,8 @@
4039
"vlucas/phpdotenv": "^5.6",
4140
"rector/rector": "^2.0",
4241
"phpstan/phpstan": "^2.1",
43-
"phpdocumentor/phpdocumentor": "^3.7"
42+
"phpdocumentor/phpdocumentor": "^3.7",
43+
"icanhazstring/composer-unused": "^0.9.3"
4444
},
4545
"autoload": {
4646
"psr-4": {
@@ -65,12 +65,13 @@
6565
"rector": "rector process",
6666
"phpstan": "phpstan analyse --memory-limit=-1",
6767
"format": "php-cs-fixer fix",
68-
"docgen": "phpdoc --config=phpdoc.xml"
68+
"docgen": "phpdoc --config=phpdoc.xml",
69+
"depcheck": "composer-unused"
6970
},
7071
"config": {
7172
"allow-plugins": {
7273
"php-http/discovery": true
7374
},
7475
"process-timeout": 600
7576
}
76-
}
77+
}

0 commit comments

Comments
 (0)