Skip to content

Commit 54367bc

Browse files
authored
Native semver and dependabot (#785)
* Fix incorrect version comparison in example * Replace deprecated plugins with native filter functions The commit replaces the deprecated `extractDependabotVersionBump` and `compareSemver` plugins with their native filter function equivalents `checkDependabot` and `checkSemver`. Updates documentation and examples to reflect this change.
1 parent 597b21e commit 54367bc

File tree

15 files changed

+112
-208
lines changed

15 files changed

+112
-208
lines changed

docs/automations/integrations/dependabot/approve-dependabot/README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ Auto-merge Dependabot PRs
1010

1111
=== "By Release Type"
1212

13-
!!! warning "Required gitStream Plugins"
14-
This example requires you to install the [`extractDependabotVersionBump`](/filter-function-plugins/#extractdependabotversionbump) and [`compareSemver`](/filter-function-plugins/#comparesemver) plugins.
15-
16-
[Learn more about gitStream plugins](/plugins/).
17-
1813
!!! info "Configuration Description"
1914

2015
Conditions (all must be true):

docs/downloads/automation-library/integrations/dependabot/approve_dependabot_minor.cm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ automations:
3232
comment: |
3333
Dependabot `patch` version bumps are approved and merged automatically.
3434

35-
bump: {{ pr.description | extractDependabotVersionBump | compareSemver }}
35+
bump: {{ pr.description | checkDependabot | checkSemver }}

docs/execution-model.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,6 @@ This allows developers to get AI feedback during the coding process before marki
200200

201201
For example, you can have your normal automations that help developers with their PRs and a separate automation that automates Dependabot or Renovate version bumps. Both automations serve distinctly different purposes: the first helps your developers streamline their PRs, while the other reduces developers' toil by auto-approving version bumps. You will not want to unnecessarily trigger gitStream for Dependabot or Renovate, so you can configure the triggers to exclude the branch where Dependabot or Renovate PRs are created.
202202

203-
!!! warning "Required gitStream Plugins"
204-
This example requires you to install the [`extractDependabotVersionBump`](/filter-function-plugins/#extractdependabotversionbump) and [`compareSemver`](/filter-function-plugins/#comparesemver) plugins.
205203

206204
In your default automation file, you should exclude the branch where Dependabot or Renovate PRs are created:
207205

@@ -270,7 +268,7 @@ automations:
270268
comment: |
271269
Dependabot `patch` version bumps are approved and merged automatically.
272270
273-
bump: {{ pr.description | extractDependabotVersionBump | compareSemver }}
271+
bump: {{ pr.description | checkDependabot | checkSemver }}
274272
```
275273

276274
#### Assign code expert

docs/filter-function-plugins.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@ JavaScript plugins that enable custom filter functions for gitStream. To learn h
1212

1313
--8<-- "plugins/filters/compareMultiSemver/README.md"
1414

15-
--8<-- "plugins/filters/compareSemver/README.md"
15+
## compareSemver
16+
!!! note "compareSemver → checkSemver"
1617

17-
--8<-- "plugins/filters/extractDependabotVersionBump/README.md"
18+
This plugin is now supported by a native filter function [`checkSemver`](/filter-functions/#checksemver). The native implementation provides better performance and doesn't require plugin installation.
19+
20+
## extractDependabotVersionBump
21+
!!! note "extractDependabotVersionBump → checkDependabot"
22+
23+
This plugin is now supported by a native filter function [`checkDependabot`](/filter-functions/#checkdependabot). The native implementation provides better performance and doesn't require plugin installation.
1824

1925
--8<-- "plugins/filters/extractRenovateVersionBump/README.md"
2026

docs/filter-functions.md

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ The following functions are supported in addition to the built-in functions prov
4545
| [`allDocs`](#alldocs)<br />Checks the list includes only images | [`files`](./context-variables.md#files) | - | Bool |
4646
| [`allImages`](#allimages)<br />Checks the list includes only images | [`files`](./context-variables.md#files) | - | Bool |
4747
| [`allTests`](#alltests)<br />Checks the list includes only tests | [`files`](./context-variables.md#files) | - | Bool |
48+
| [`checkDependabot`](#checkdependabot)<br />Extract version bump information from Dependabot PRs description | String - PR description | - | [String] |
49+
| [`checkSemver`](#checksemver)<br />Compare two software version numbers and determine the type of version change | [String] - Array with [to, from] versions | `lexicographical`, `zeroExtend` | String |
4850
| [`codeExperts`](#codeexperts)<br />Get list of contributors based on expert reviewer model results | [`repo`](./context-variables.md#repo) | `gt`, `lt` | [String] |
4951
| [`decode`](#decode)<br />Decode Base64 encoded string into an object | String (Base64 encoded) | - | Object |
5052
| [`encode`](#encode)<br />Encode data into Base64 encoded string | Object | - | String (Base64 encoded) |
@@ -379,6 +381,93 @@ To identify as test the file must include the word `test` or `spec` in its name
379381
{{ files | allTests }}
380382
```
381383

384+
385+
#### `checkDependabot`
386+
387+
Extract version bump information from Dependabot PRs description. This filter parses Dependabot PR descriptions to identify version changes and returns an array containing the "to" and "from" versions.
388+
389+
<div class="filter-details" markdown=1>
390+
391+
| Argument | Usage | Type | Description |
392+
| -------- | ------ | ------ | ------------------------------------------------------------------- |
393+
| - | Input | String | The PR description from a Dependabot pull request |
394+
| - | Output | [String] | Array with [to, from] versions, or null if no version info found |
395+
396+
</div>
397+
398+
Examples:
399+
400+
Check if a Dependabot PR is a minor version bump and auto-approve:
401+
402+
```yaml+jinja
403+
automations:
404+
auto_approve_dependabot_minor:
405+
if:
406+
- {{ pr.description | checkDependabot | checkSemver == 'minor' }}
407+
- {{ branch.name | includes(term="dependabot") }}
408+
- {{ branch.author | includes(term="dependabot") }}
409+
run:
410+
- action: approve@v1
411+
- action: add-comment@v1
412+
args:
413+
comment: |
414+
Dependabot minor version bump approved automatically.
415+
```
416+
417+
Auto-merge patch updates:
418+
419+
```yaml+jinja
420+
automations:
421+
auto_merge_dependabot_patch:
422+
if:
423+
- {{ pr.description | checkDependabot | checkSemver == 'patch' }}
424+
- {{ branch.name | includes(term="dependabot") }}
425+
run:
426+
- action: approve@v1
427+
- action: merge@v1
428+
```
429+
430+
#### `checkSemver`
431+
432+
Compare two software version numbers and determine the type of version change. This filter takes an array of two version strings and returns the type of change between them.
433+
434+
<div class="filter-details" markdown=1>
435+
436+
| Argument | Usage | Type | Description |
437+
| -------- | ------ | ------ | ------------------------------------------------------------------- |
438+
| - | Input | [String] | Array with [to, from] versions in semver format |
439+
| `lexicographical` | Input (optional) | Boolean | Compare lexicographically instead of naturally (default: false) |
440+
| `zeroExtend` | Input (optional) | Boolean | Pad shorter version with zeros (default: true) |
441+
| - | Output | String | Returns 'major', 'minor', 'patch', 'downgrade', 'equal', or 'error' |
442+
443+
</div>
444+
445+
Examples:
446+
447+
Compare version arrays directly:
448+
449+
```yaml+jinja
450+
{{ ["1.2.3", "1.2.1"] | checkSemver }} # Returns "patch"
451+
```
452+
453+
Use with Dependabot to classify version bumps:
454+
455+
```yaml+jinja
456+
bump_type: {{ pr.description | checkDependabot | checkSemver }}
457+
458+
automations:
459+
handle_major_bump:
460+
if:
461+
- {{ bump_type == 'major' }}
462+
run:
463+
- action: add-label@v1
464+
args:
465+
label: "major-version-bump"
466+
- action: request-changes@v1
467+
args:
468+
comment: "Major version bumps require manual review"
469+
```
470+
382471
#### `codeExperts`
383472

384473
When requesting a review for a pull request, it's important to select a reviewer who has a deep understanding of the relevant code area, the domain problem, and the framework being used. This ensures that the reviewer can provide specific and informed feedback, rather than general comments that may not take into account the context in which the issue was solved.
@@ -416,7 +505,7 @@ automations:
416505
```
417506

418507
!!! tip "Limit git history for code experts"
419-
508+
420509
Use the [`config.git_history_since`](./cm-file.md#configgit_history_since) configuration to limit the git history analysis to commits after a specific date. This is useful for team transitions or when you want to focus on recent contributors only.
421510

422511
#### `decode`

plugins/filters/compareSemver/reference.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## compareSemver
44
Compares two software version numbers (e.g., "1.2.1" or "1.2b") and determines the type of version change.
5-
The first version to be compared, and the second are passed as argument 1 and 2 or as array of 2 items.
5+
The first version to be compared, and the second are passed as argument 1 and 2 or as array of 2 items.
66
When V1 > V2 the it means and upgrade.
77

88
**Returns**: <code>string</code> - It returns a string of either:
@@ -11,16 +11,16 @@ When V1 > V2 the it means and upgrade.
1111
'patch' if the patch version is incremented.
1212
'downgrade' if the second version is lower than the first.
1313
'equal' if both versions are equal.
14-
'error' if the comparison is abnormal or cannot be determined.
15-
**License**: MIT
14+
'error' if the comparison is abnormal or cannot be determined.
15+
**License**: MIT
1616

1717
| Param | Type | Default | Description |
1818
| --- | --- | --- | --- |
1919
| versions | <code>Array.&lt;string&gt;</code> | | V1 and V2 in Semver format |
2020
| [lexicographical] | <code>boolean</code> | <code>false</code> | compares each part of the version strings lexicographically instead of naturally; this allows suffixes such as "b" or "dev" but will cause "1.10" to be considered smaller than "1.2". |
2121
| [zeroExtend] | <code>boolean</code> | <code>true</code> | changes the result if one version string has less parts than the other. In this case the shorter string will be padded with "zero" parts instead of being considered smaller. |
2222

23-
**Example**
23+
**Example**
2424
```js
25-
{{ ["1.2.1", "1.2.3"] | compareSemver == "patch" }}
25+
{{ ["1.2.3", "1.2.1"] | compareSemver == "patch" }}
2626
```

plugins/filters/extractDependabotVersionBump/LICENSE

Lines changed: 0 additions & 21 deletions
This file was deleted.

plugins/filters/extractDependabotVersionBump/README.md

Lines changed: 0 additions & 22 deletions
This file was deleted.

plugins/filters/extractDependabotVersionBump/extract_dependabot_version_bump.cm

Lines changed: 0 additions & 36 deletions
This file was deleted.

plugins/filters/extractDependabotVersionBump/index.js

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)