Skip to content

Commit

Permalink
feat: split and export renovate presets (#1516)
Browse files Browse the repository at this point in the history
## Proposed change

Split and export renovate presets

## Related issues

- 🚀 Feature resolves #1483

<!-- Please make sure to follow the contributing guidelines on
https://github.com/amadeus-digital/Otter/blob/main/CONTRIBUTING.md -->
  • Loading branch information
kpanot authored Mar 22, 2024
2 parents d9fa7d9 + d298010 commit 18c4f43
Show file tree
Hide file tree
Showing 15 changed files with 552 additions and 172 deletions.
82 changes: 82 additions & 0 deletions .renovaterc.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"github>AmadeusITGroup/otter//tools/renovate/base",
"github>AmadeusITGroup/otter//tools/renovate/design-factory",
"github>AmadeusITGroup/otter//tools/renovate/otter-project",
"github>AmadeusITGroup/otter//tools/renovate/sdk"
],
"ignorePaths": [
"**/node_modules/**",
"**/templates/**"
],
"enabledManagers": [
"npm",
"github-actions",
"gradle"
],
"labels": [
"upgrade"
],
"baseBranches": [
"main",
"/^release\\/.*-next$/"
],
"packageRules": [
{
"matchPackageNames": [
"typescript",
"eslint",
"@yarnpkg/sdks"
],
"postUpgradeTasks": {
"commands": [
"yarn install",
"yarn sdks"
],
"executionMode": "branch",
"fileFilters": [
".yarn/sdks/**"
]
}
},
{
// Update of bootstrap disabled as it is not supported by design-factory (Can be removed when upgrading design-factory to v17)
"matchCurrentVersion": "<=5.2.0",
"matchPackageNames": [
"bootstrap"
],
"enabled": false
},
{
//Major update of chalk disabled as it drops support on CommonJS
"matchUpdateTypes": [
"major"
],
"matchCurrentVersion": "<5",
"matchPackageNames": [
"chalk"
],
"enabled": false
},
{
//Major update of globby disabled as it drops support on CommonJS
"matchUpdateTypes": [
"major"
],
"matchCurrentVersion": "<14",
"matchPackageNames": [
"globby"
],
"enabled": false
},
{
// This rule disable the upgrade of the gaurav-nelson/github-action-markdown-link-check
// TODO: re-activate the upgrade when the following issue is fixed: gaurav-nelson/github-action-markdown-link-check#200
"matchPackagePatterns": [
".*markdown-link-check"
],
"enabled": false
}
]
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"**/.DS_Store": true,
"**/Thumbs.db": true
},
"files.associations": {
"*.json5": "jsonc"
},
"npm.packageManager": "yarn",
"typescript.tsdk": ".yarn/sdks/typescript/lib",
"typescript.preferences.importModuleSpecifier": "relative",
Expand Down
31 changes: 31 additions & 0 deletions docs/renovate/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Renovate Presets

The Otter library provides a set of custom [Renovate Presets](https://docs.renovatebot.com/config-presets/) to facilitate the configuration of automated dependency updates.

## Usage

To be able to benefit from the Renovate Presets exposed by the Otter Framework, you can add the configurations in the `extends` field in your `.renovaterc.json` file as described in the following example:

```json5
{
"extends": [
"config:base"
"github>AmadeusITGroup/otter//tools/renovate/base",
"github>AmadeusITGroup/otter//tools/renovate/otter-project"
],
"packageRules": [
// ...
]
}
```

> [!NOTE]
> The Otter Renovate presets are always prefixed with `github>AmadeusITGroup/otter//tools/renovate/` to target the specific configuration files hosted in the Otter repository.
## Available presets

- **base**: Base configuration recommended to an Otter base project.
- **otter-project**: Configuration to be used in a project to facilitate and regroup the upgrades of Otter dependencies.
- **sdk**: Configuration to ensure the upgrade of the dependencies of a generated SDK
- **sdk-spec-upgrade**: Setup an auto-regeneration of the SDK based on a given Swagger/OAS specification dependency (as first [parameter](https://docs.renovatebot.com/config-presets/#preset-parameters)).
- **design-factory**: Renovate configuration to ensure the dependency upgrade of the Design Factory dependencies are following the Design Factory constraints.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import { chain, Rule } from '@angular-devkit/schematics';
import { addCpyDependencies, deprecateScriptsFolder, updateScriptPackageJson } from './v10.0/script-removal';
import { addPresetsRenovate } from './v10.1/add-presets-renovate';

/**
* update of Otter library V10.0
Expand All @@ -16,3 +17,14 @@ export function updateV10_0(): Rule {

return chain(updateRules);
}

/**
* Update of Ama-sdk library V10.1
*/
export function updateV10_1(): Rule {
const updateRules: Rule[] = [
addPresetsRenovate()
];

return chain(updateRules);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import type { Rule } from '@angular-devkit/schematics';

const renovatePresets = [
'github>AmadeusITGroup/otter//tools/renovate/base',
'github>AmadeusITGroup/otter//tools/renovate/sdk'
];

export const addPresetsRenovate = (): Rule => {
return (tree, context) => {
if (tree.exists('.renovaterc.json')) {
const renovateConfig = tree.readJson('.renovaterc.json') as any;
renovateConfig.extends ||= [];
renovatePresets
.filter((preset) => !renovateConfig.extends.includes(preset))
.forEach((preset) => renovateConfig.extends.push(preset));
tree.overwrite('renovate.json', JSON.stringify(renovateConfig, null, 2));
} else {
context.logger.debug('renovate.json not found, skipping preset addition');
}
// eslint-disable-next-line max-len
context.logger.info('To activate the auto-generation based on a dependency package, replace "my-specification-package", in your Renovate configuration, by your specification dependency package name.');
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base",
"group:allNonMajor",
"group:recommended",
"group:monorepos",
"group:test",
"group:linters"
"github>AmadeusITGroup/otter//tools/renovate/base",
"github>AmadeusITGroup/otter//tools/renovate/sdk",
"github>AmadeusITGroup/otter//tools/renovate/sdk-spec-upgrade(my-specification-package)"
],
"prConcurrentLimit": 0,
"prHourlyLimit": 0,
"baseBranches": [
"master"
"master",
"main"
],
"endpoint": "https://dev.azure.com/AmadeusDigitalAirline",
"platform": "azure",
"enabledManagers": [
"npm"
],
Expand All @@ -32,54 +29,6 @@
"automerge": true,
"platformAutomerge": true,
"packageRules": [
{
"matchPackagePrefixes": [
"@my-api-scope",
"@ama-sdk/generator"
],
"postUpgradeTasks": {
"commands": [
"<%=packageManager%> install",
"<%=packageManager%> run generate"
],
"executionMode": "branch"
}
},
{
"matchPackagePrefixes": [
"@my-api-scope"
],
"rangeStrategy": "bump",
"groupName": "Swagger Specification upgrade",
"groupSlug": "spec-upgrade"
},
{
"matchPackagePrefixes": [
"@my-api-scope"
],
"matchBaseBranches": [
"/^release\/.*/"
],
"rangeStrategy": "in-range-only"
},
{
"matchPackageNames": [
"@ama-sdk/core",
"@ama-sdk/schematics"
],
"rangeStrategy": "bump",
"groupName": "SDK Core and Generator dependencies",
"groupSlug": "sdk-core-dependencies"
},
{
"excludePackagePrefixes": [
"@my-api-scope"
],
"matchBaseBranches": [
"/^release\/.*/"
],
"enabled": false
},
{
"matchDepTypes": [
"peerDependencies"
Expand Down
6 changes: 5 additions & 1 deletion packages/@o3r/workspace/migration.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"$schema": "https://raw.githubusercontent.com/angular/angular-cli/master/packages/angular_devkit/schematics/collection-schema.json",
"schematics": {

"migration-v10_0": {
"version": "10.1.0-alpha.0",
"description": "Updates of @o3r/workspace to v10.1.*",
"factory": "./schematics/ng-update/index#updateV10_1"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base",
"group:allNonMajor",
"group:monorepos",
"group:recommended",
"group:test"
"github>AmadeusITGroup/otter//tools/renovate/base",
"github>AmadeusITGroup/otter//tools/renovate/otter-project"
],
"prConcurrentLimit": 0,
"prHourlyLimit": 0,
"baseBranches": [
"master"
"main"
],
"platform": "azure",
"enabledManagers": [
Expand All @@ -28,34 +26,9 @@
"packageRules": [
{
"matchPackageNames": [
"@o3r/core"
"@o3r/*"
],
"postUpgradeTasks": {
"commands": [
"npm install",
"npm run ng update {{{depName}}} --from={{{currentVersion}}} --to={{{newVersion}}} --migrate-only --allow-dirty --force"
],
"fileFilters": [
"**"
],
"executionMode": "branch"
}
},
{
"matchPackagePrefixes": [
"@otter",
"@o3r",
"@ama-sdk",
"@ama-terasu"
],
"groupName": "Otter dependencies",
"groupSlug": "otter-dependencies"
},
{
"matchPackagePatterns": [
"*"
],
"rangeStrategy": "replace"
"automergeType": "patch"
}
]
}
22 changes: 21 additions & 1 deletion packages/@o3r/workspace/schematics/ng-update/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
export type {};
/* eslint-disable @typescript-eslint/naming-convention */
/* eslint-disable camelcase */

import { chain, type Rule } from '@angular-devkit/schematics';
import { createSchematicWithMetricsIfInstalled } from '@o3r/schematics';
import { addPresetsRenovate } from './v10.1/add-presets-renovate';

/**
* Update of Otter Workspace V10.1
*/
function updateV10_1Fn(): Rule {
const updateRules: Rule[] = [
addPresetsRenovate()
];
return chain(updateRules);
}

/**
* Update of Otter Workspace V10.1
*/
export const updateV10_1 = createSchematicWithMetricsIfInstalled(updateV10_1Fn);
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { Rule } from '@angular-devkit/schematics';

const renovatePresets = [
'github>AmadeusITGroup/otter//tools/renovate/base',
'github>AmadeusITGroup/otter//tools/renovate/otter-project'
];

export const addPresetsRenovate = (): Rule => {
return (tree, context) => {
if (tree.exists('.renovaterc.json')) {
const renovateConfig = tree.readJson('.renovaterc.json') as any;
renovateConfig.extends ||= [];
renovatePresets
.filter((preset) => !renovateConfig.extends.includes(preset))
.forEach((preset) => renovateConfig.extends.push(preset));
tree.overwrite('renovate.json', JSON.stringify(renovateConfig, null, 2));
} else {
context.logger.info('renovate.json not found, skipping preset addition');
}
};
};
Loading

0 comments on commit 18c4f43

Please sign in to comment.