Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(config): migrate requiredStatusChecks to ignoreTests (#11355)
* feat(config): migrate requiredStatusChecks to ignoreTests * fix(config): restore order of props * feat(config): add applyMigrations function * feat(platform): check ignoreTests param in worker * feat(config): rename getBranchStatus to resolveBranchStatus Co-authored-by: Michael Kriese <michael.kriese@visualon.de> Co-authored-by: Rhys Arkins <rhys@arkins.net>
- Loading branch information
1 parent
0a5cee1
commit 7801ae7
Showing
36 changed files
with
206 additions
and
331 deletions.
There are no files selected for viewing
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,18 @@ | ||
import { RenovateConfig } from '../types'; | ||
import type { Migration } from './migration'; | ||
import { RequiredStatusChecksMigration } from './required-status-checks-migration'; | ||
|
||
export function applyMigrations( | ||
originalConfig: RenovateConfig, | ||
migratedConfig: RenovateConfig | ||
): RenovateConfig { | ||
const migrations: Migration[] = [ | ||
new RequiredStatusChecksMigration(originalConfig, migratedConfig), | ||
]; | ||
|
||
for (const migration of migrations) { | ||
migration.migrate(); | ||
} | ||
|
||
return migratedConfig; | ||
} |
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,18 @@ | ||
import type { RenovateConfig } from '../types'; | ||
|
||
export abstract class Migration { | ||
protected readonly originalConfig: RenovateConfig; | ||
|
||
protected readonly migratedConfig: RenovateConfig; | ||
|
||
constructor(originalConfig: RenovateConfig, migratedConfig: RenovateConfig) { | ||
this.originalConfig = originalConfig; | ||
this.migratedConfig = migratedConfig; | ||
} | ||
|
||
abstract migrate(): void; | ||
|
||
protected delete(property: string): void { | ||
delete this.migratedConfig[property]; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
lib/config/migrations/required-status-checks-migration.spec.ts
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 @@ | ||
import { RequiredStatusChecksMigration } from './required-status-checks-migration'; | ||
|
||
describe('config/migrations/required-status-checks-migration', () => { | ||
it('should migrate requiredStatusChecks=null to ignoreTests=true', () => { | ||
const originalConfig: any = { | ||
requiredStatusChecks: null, | ||
}; | ||
const migratedConfig: any = { | ||
requiredStatusChecks: null, | ||
}; | ||
const migration = new RequiredStatusChecksMigration( | ||
originalConfig, | ||
migratedConfig | ||
); | ||
|
||
expect(migratedConfig.requiredStatusChecks).toBeNull(); | ||
migration.migrate(); | ||
expect(migratedConfig.requiredStatusChecks).toBeUndefined(); | ||
expect(migratedConfig.ignoreTests).toBeTrue(); | ||
}); | ||
}); |
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,11 @@ | ||
import { Migration } from './migration'; | ||
|
||
export class RequiredStatusChecksMigration extends Migration { | ||
public migrate(): void { | ||
this.delete('requiredStatusChecks'); | ||
|
||
if (this.originalConfig.requiredStatusChecks === null) { | ||
this.migratedConfig.ignoreTests = true; | ||
} | ||
} | ||
} |
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
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
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
Oops, something went wrong.