Skip to content

Commit 886bc55

Browse files
authored
docs: document package diffs (#14)
1 parent 2cc0115 commit 886bc55

File tree

3 files changed

+99
-6
lines changed

3 files changed

+99
-6
lines changed

.github/workflows/diff-dependencies.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ jobs:
1111
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
1212
with:
1313
ref: main
14-
- name: Use Node v${{ matrix.node-version }}
14+
- name: Use Node
1515
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
1616
with:
1717
node-version: 24.x
1818
- name: Install Dependencies
19-
run: npm ci
19+
run: npm ci --ignore-scripts
2020
- name: Build
2121
run: npm run build
2222
- name: Pack
@@ -30,12 +30,12 @@ jobs:
3030
steps:
3131
- name: Checkout
3232
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
33-
- name: Use Node v${{ matrix.node-version }}
33+
- name: Use Node
3434
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
3535
with:
3636
node-version: 24.x
3737
- name: Install Dependencies
38-
run: npm ci
38+
run: npm ci --ignore-scripts
3939
- name: Build
4040
run: npm run build
4141
- name: Pack

README.md

Lines changed: 91 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This action compares dependencies between your base branch and current branch, a
1010
-**Trusted publisher changes** - Detects loss of trusted publish status
1111
- 📈 **Dependency growth** - Warns when dependency count increases significantly
1212
- 📦 **Install size** - Warns when package size increases significantly
13+
- 🔄 **Duplicate versions** - Detects packages with multiple versions installed
1314

1415
## Usage
1516

@@ -38,11 +39,15 @@ jobs:
3839
3940
| Name | Description | Required | Default |
4041
|------|-------------|----------|---------|
41-
| `base-ref` | Base ref to compare against (defaults to main or PR target) | Yes | `main` |
42+
| `base-ref` | Base ref to compare against (defaults to main or PR target) | No | Auto-detected from PR or `main` |
4243
| `github-token` | The GitHub token for authentication | Yes | `${{ github.token }}` |
4344
| `pr-number` | The number of the pull request to comment on | Yes | `${{ github.event.pull_request.number }}` |
4445
| `dependency-threshold` | Threshold for warning about significant increase in number of dependencies | No | `10` |
4546
| `size-threshold` | Threshold (in bytes) for warning about significant increase in package size | No | `100000` |
47+
| `duplicate-threshold` | Threshold for warning about packages with multiple versions | No | `1` |
48+
| `base-packages` | Glob pattern for base branch pack files (e.g., `"./base-packs/*.tgz"`) | No | None |
49+
| `source-packages` | Glob pattern for source branch pack files (e.g., `"./source-packs/*.tgz"`) | No | None |
50+
| `pack-size-threshold` | Threshold (in bytes) for warning about significant increase in total pack size | No | `50000` |
4651

4752
## Example with custom inputs
4853

@@ -55,6 +60,90 @@ jobs:
5560
size-threshold: '50000'
5661
```
5762

63+
## Package Bundle Analysis
64+
65+
In addition to analyzing dependency changes, this action can optionally compare the actual bundle sizes of your packages by examining `npm pack` outputs. This provides insights into the **bundle size** (what gets published) rather than just the **install size** (what gets installed with dependencies).
66+
67+
### Package Inputs
68+
69+
The action accepts glob patterns to locate package tarballs for comparison:
70+
71+
- **`base-packages`** - Glob pattern for base branch pack files (e.g., `"./base-packs/*.tgz"`)
72+
- **`source-packages`** - Glob pattern for source branch pack files (e.g., `"./source-packs/*.tgz"`)
73+
- **`pack-size-threshold`** - Threshold in bytes for warning about significant pack size increases
74+
75+
> [!NOTE]
76+
> Package bundle analysis only runs when both `base-packages` and `source-packages` are provided. If these inputs are not set, this feature is skipped entirely.
77+
78+
### Example with package analysis
79+
80+
```yaml
81+
jobs:
82+
build-main:
83+
runs-on: ubuntu-latest
84+
steps:
85+
- name: Checkout
86+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
87+
with:
88+
ref: main # or your default branch
89+
- name: Use Node
90+
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
91+
with:
92+
node-version: 24.x
93+
- name: Install Dependencies
94+
run: npm ci --ignore-scripts
95+
- name: Build
96+
run: npm run build
97+
- name: Pack
98+
run: npm pack
99+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
100+
with:
101+
name: base-packages
102+
path: '*.tgz'
103+
build-pr:
104+
runs-on: ubuntu-latest
105+
steps:
106+
- name: Checkout
107+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
108+
- name: Use Node
109+
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
110+
with:
111+
node-version: 24.x
112+
- name: Install Dependencies
113+
run: npm ci --ignore-scripts
114+
- name: Build
115+
run: npm run build
116+
- name: Pack
117+
run: npm pack
118+
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
119+
with:
120+
name: source-packages
121+
path: '*.tgz'
122+
diff_dependencies:
123+
runs-on: ubuntu-latest
124+
needs: [build-main, build-pr]
125+
permissions:
126+
pull-requests: write
127+
steps:
128+
- name: Checkout repository
129+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
130+
with:
131+
fetch-depth: 0 # allows the diff action to access git history
132+
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
133+
with:
134+
name: base-packages
135+
path: ./base-packages
136+
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
137+
with:
138+
name: source-packages
139+
path: ./source-packages
140+
- name: Create Diff
141+
uses: e18e/action-dependency-diff@main
142+
with:
143+
base-packages: ./base-packages/*.tgz
144+
source-packages: ./source-packages/*.tgz
145+
```
146+
58147
## Supported package managers
59148

60149
- npm (package-lock.json)
@@ -68,7 +157,7 @@ The action requires the following permissions:
68157

69158
```yaml
70159
permissions:
71-
pull-requests: write # To comment on pull requests
160+
pull-requests: write # To comment on pull requests
72161
```
73162

74163
## License

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ inputs:
3636
description: 'Threshold (in bytes) for warning about significant increase in total pack size'
3737
required: false
3838
default: '50000'
39+
duplicate-threshold:
40+
description: 'Threshold for warning about packages with multiple versions'
41+
required: false
42+
default: '1'
3943

4044
runs:
4145
using: node24

0 commit comments

Comments
 (0)