-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #531 from linear-b/renovate-plugin
Renovate plugin
- Loading branch information
Showing
18 changed files
with
367 additions
and
32 deletions.
There are no files selected for viewing
74 changes: 53 additions & 21 deletions
74
docs/automations/integrations/renovate/approve-renovate/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,67 @@ | ||
--- | ||
title: Automation - Approve and Merge Renovate Changes | ||
description: Automatically approve and merge Renovate PRs. | ||
category: [security, renovate] | ||
category: [efficiency, renovate, security] | ||
quickstart: false | ||
--- | ||
# Approve and Merge Renovate Changes | ||
|
||
<!-- --8<-- [start:example]--> | ||
Approve PRs from Renovate | ||
Auto-merge Renovate PRs | ||
|
||
=== "By Release Type" | ||
|
||
!!! warning "Required gitStream Plugins" | ||
This example requires you to install the [`extractRenovateVersionBump`](/filter-function-plugins/#extractrenovateversionbump), [`compareMultiSemver`](/filter-function-plugins/#comparemultisemver) and [`compareSemver`](/filter-function-plugins/#comparesemver) plugins. | ||
|
||
[Learn more about gitStream plugins](/plugins/). | ||
|
||
!!! info "Configuration Description" | ||
|
||
Conditions (all must be true): | ||
|
||
* The PR author is Renovate. | ||
* The branch name includes 'renovate' | ||
* The dependency change is a patch or minor update. | ||
|
||
Automation Actions: | ||
|
||
* Approve the PR | ||
* Apply an `approved-renovate` label to the PR | ||
* Merge the PR if all status checks pass. | ||
|
||
!!! example "Configuration Example" | ||
```yaml+jinja | ||
--8<-- "docs/downloads/automation-library/integrations/renovate/approve_renovate_minor.cm" | ||
``` | ||
<div class="result" markdown> | ||
<span> | ||
[:octicons-download-24: Download this example as a CM file.](/downloads/automation-library/integrations/renovate/approve_renovate_minor.cm){ .md-button } | ||
</span> | ||
</div> | ||
|
||
=== "All Updates" | ||
!!! info "Configuration Description" | ||
|
||
![Approve and Merge Renovate Changes](/automations/integrations/renovate/approve-renovate/approve-renovate.png) | ||
Conditions (all must be true): | ||
|
||
!!! info "Configuration Description" | ||
* The PR author is Renovate. | ||
* The branch name includes 'renovate' | ||
|
||
**Conditions (all must be true):** | ||
Automation Actions: | ||
|
||
* The PR author is Mend Renovate. | ||
* Approve the PR | ||
* Apply an `approved-renovate` label to the PR | ||
* Merge the PR if all status checks pass. | ||
|
||
**Automation Actions:** | ||
|
||
* Approve the PR | ||
* Apply an `approved-renovate` label to the PR | ||
* Merge the PR if all status checks pass. | ||
!!! example "Configuration Example" | ||
```yaml+jinja | ||
--8<-- "docs/downloads/automation-library/integrations/renovate/approve_renovate.cm" | ||
``` | ||
<div class="result" markdown> | ||
<span> | ||
[:octicons-download-24: Download this example as a CM file.](/downloads/automation-library/integrations/renovate/approve_renovate.cm){ .md-button } | ||
</span> | ||
</div> | ||
|
||
<div class="automationExample" markdown="1"> | ||
!!! example "Approve Renovate" | ||
```yaml+jinja | ||
--8<-- "docs/downloads/automation-library/integrations/renovate/approve-renovate/approve_renovate.cm" | ||
``` | ||
<div class="result" markdown> | ||
<span> | ||
[:octicons-download-24: Download this example as a CM file.](/downloads/automation-library/integrations/renovate/approve-renovate/approve_renovate.cm){ .md-button } | ||
</span> | ||
</div> | ||
<!-- --8<-- [end:example]--> |
File renamed without changes.
30 changes: 30 additions & 0 deletions
30
docs/downloads/automation-library/integrations/renovate/approve_renovate_minor.cm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
manifest: | ||
version: 1.0 | ||
|
||
automations: | ||
merge_renovate_minor: | ||
if: | ||
- {{ bump == 'minor' }} | ||
- {{ branch.name | includes(term="renovate") }} | ||
- {{ branch.author | includes(term="renovate") }} | ||
run: | ||
- action: approve@v1 | ||
- action: add-comment@v1 | ||
args: | ||
comment: | | ||
Renovate `minor` version bumps are approved automatically. | ||
|
||
merge_renovate_minor_patch: | ||
if: | ||
- {{ bump == 'patch' }} | ||
- {{ branch.name | includes(term="renovate") }} | ||
- {{ branch.author | includes(term="renovate") }} | ||
run: | ||
- action: approve@v1 | ||
- action: merge@v1 | ||
- action: add-comment@v1 | ||
args: | ||
comment: | | ||
Renovate `patch` version bumps are approved and merged automatically. | ||
|
||
bump: {{ pr.description | extractRenovateVersionBump | compareMultiSemver }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 LinearB | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--8<-- "plugins/filters/compareMultiSemver/reference.md" | ||
|
||
??? note "Plugin Code: compareMultiSemver" | ||
```javascript | ||
--8<-- "plugins/filters/compareMultiSemver/index.js" | ||
``` | ||
<div class="result" markdown> | ||
<span> | ||
</span> | ||
</div> | ||
|
||
??? example "gitStream CM Example: compareMultiSemver" | ||
```yaml+jinja | ||
--8<-- "plugins/filters/compareMultiSemver/compare_multi_semver.cm" | ||
``` | ||
<div class="result" markdown> | ||
<span> | ||
</span> | ||
</div> | ||
|
||
[Download Source Code](https://github.com/linear-b/gitstream/tree/main/plugins/filters/compareMultiSemver) |
26 changes: 26 additions & 0 deletions
26
plugins/filters/compareMultiSemver/compare_multi_semver.cm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
manifest: | ||
version: 1.0 | ||
|
||
automations: | ||
bump_minor: | ||
if: | ||
- {{ bump == 'minor' }} | ||
run: | ||
- action: approve@v1 | ||
- action: add-comment@v1 | ||
args: | ||
comment: | | ||
bot `minor` version bumps are approved automatically. | ||
|
||
bump_patch: | ||
if: | ||
- {{ bump == 'patch' }} | ||
run: | ||
- action: approve@v1 | ||
- action: merge@v1 | ||
- action: add-comment@v1 | ||
args: | ||
comment: | | ||
bot `patch` version bumps are approved and merged automatically. | ||
|
||
bump: {{ [["1.2.3", "1.2.1"], ["1.3.1", "1.2.3"]] | compareMultiSemver }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* @module compareMultiSemver | ||
* @description Processes a list of pairs of semantic version numbers and determines the most significant change among them. | ||
* Each pair consists of two versions to be compared. | ||
* @param {string[][]} listOfPairs - An array of version pairs, where each pair is an array of two semantic version strings. | ||
* @returns {string} It returns a string of either: | ||
* 'major' if any pair has a major version increment. | ||
* 'minor' if no pair has a major version increment but has a minor version increment. | ||
* 'patch' if no pair has major or minor version increments but has a patch version increment. | ||
* 'downgrade' if no pairs have a higher version. | ||
* 'equal' if all pairs are equal. | ||
* 'error' if the comparison is abnormal or cannot be determined. | ||
* @example {{ [["1.2.3", "1.2.1"], ["1.3.1", "1.2.3"]] | compareMultiSemver == "minor" }} | ||
* @license MIT | ||
*/ | ||
|
||
|
||
const compareSemver = require('../compareSemver/index.js'); | ||
|
||
module.exports = (listOfPairs) => { | ||
|
||
const priority = { | ||
'major': 3, | ||
'minor': 2, | ||
'patch': 1, | ||
'downgrade': 0, | ||
'equal': -1, | ||
'error': -2 | ||
}; | ||
|
||
let mostSignificantChange = 'equal'; | ||
|
||
listOfPairs.forEach(pair => { | ||
const result = compareSemver(pair); | ||
if (priority[result] > priority[mostSignificantChange]) { | ||
mostSignificantChange = result; | ||
} | ||
}); | ||
|
||
return mostSignificantChange; | ||
} | ||
|
||
|
||
const compareMultiSemver = require('./index.js'); | ||
console.assert(compareMultiSemver([["1.2.3", "1.2.1"], ["1.3.1", "1.2.3"]]) === 'minor', `compareSemver([["1.2.3", "1.2.1"], ["1.3.1", "1.2.3"]]) == 'minor'`); | ||
console.assert(compareMultiSemver([["1.2.3", "0.2.1"], ["1.3.1", "1.2.3"]]) === 'major', `compareMultiSemver([["1.2.3", "0.2.1"], ["1.3.1", "1.2.3"]]) === 'major'`); | ||
console.assert(compareMultiSemver([["2.2.3", "0.2.1"], ["1.3.1", "1.2.3"]]) === 'major', `compareMultiSemver([["2.2.3", "0.2.1"], ["1.3.1", "1.2.3"]]) === 'major'`); | ||
console.assert(compareMultiSemver([["1.2.3", "1.2.1"], ["1.2.4", "1.2.3"]]) === 'patch', `compareMultiSemver([["1.2.3", "1.2.1"], ["1.2.4", "1.2.3"]]) === 'patch'`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<a name="module_compareSemver"></a> | ||
|
||
## compareMultiSemver | ||
Processes a list of pairs of semantic version numbers and determines the most significant change among them. | ||
|
||
**Returns**: <code>string</code> - It returns a string of either: | ||
'major' if any pair has a major version increment. | ||
'minor' if no pair has a major version increment but has a minor version increment. | ||
'patch' if no pair has major or minor version increments but has a patch version increment. | ||
'downgrade' if no pairs have a higher version. | ||
'equal' if all pairs are equal. | ||
'error' if the comparison is abnormal or cannot be determined. | ||
|
||
**License**: MIT | ||
|
||
| Param | Type | Default | Description | | ||
| --- | --- | --- | --- | | ||
| listOfPairs | <code>Array.<Array></code> | | An array of version pairs, where each pair is an array of two semantic version strings.| | ||
|
||
**Example** | ||
```js | ||
{{ [["1.2.3", "0.2.1"], ["1.3.1", "1.2.3"]] | compareMultiSemver == "major" }} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 LinearB | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Oops, something went wrong.