зеркало из
1
0
Форкнуть 0

Fix rush changelog; update changefile detection regex and add unit tests (#5315)

This commit is contained in:
James Burnside 2024-10-15 12:45:09 -07:00 коммит произвёл GitHub
Родитель 0aeeb44ea5
Коммит b0733e0310
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
8 изменённых файлов: 96 добавлений и 9 удалений

3
.github/workflows/ci.yml поставляемый
Просмотреть файл

@ -106,6 +106,9 @@ jobs:
# Typescript version check
- name: Typescript version compatibility check
run: rush build --only @internal/check-typescript-regression
# Scripts tests
- name: Test scripts/ folder
run: rush test --only @internal/scripts
# Ensure all downstream packlet versions are consitent with the base packlet version
- name: Ensure all package versions are consistent
run: rush ensure-consistent-versions

Просмотреть файл

@ -18634,12 +18634,23 @@ packages:
dev: false
file:projects/scripts.tgz:
resolution: {integrity: sha512-etEablx5ljVhADQIRE5hIW0rcgMt2K8eQ1iTjXlDmK7izoFSCbcR8pBD5KRmNGqg47isbtKuNdcjEps6HJrRHg==, tarball: file:projects/scripts.tgz}
resolution: {integrity: sha512-Gz39L0FpcaiWmu0vIdx+ag3rElBIi12ECc4QgxWTV4SzlBOCZzDJKWddFdkqhNnqxrUWz7LuHOtSOgRW3tblJg==, tarball: file:projects/scripts.tgz}
name: '@rush-temp/scripts'
version: 0.0.0
dependencies:
'@babel/preset-env': 7.23.9(@babel/core@7.25.2)
'@jest/transform': 29.7.0
'@types/yargs': 17.0.33
babel-jest: 29.7.0(@babel/core@7.25.2)
jest: 29.7.0(@types/node@20.14.12)(ts-node@10.9.2)
yargs: 17.7.2
transitivePeerDependencies:
- '@babel/core'
- '@types/node'
- babel-plugin-macros
- node-notifier
- supports-color
- ts-node
dev: false
file:projects/server.tgz:

Просмотреть файл

@ -18553,12 +18553,23 @@ packages:
dev: false
file:projects/scripts.tgz:
resolution: {integrity: sha512-etEablx5ljVhADQIRE5hIW0rcgMt2K8eQ1iTjXlDmK7izoFSCbcR8pBD5KRmNGqg47isbtKuNdcjEps6HJrRHg==, tarball: file:projects/scripts.tgz}
resolution: {integrity: sha512-Gz39L0FpcaiWmu0vIdx+ag3rElBIi12ECc4QgxWTV4SzlBOCZzDJKWddFdkqhNnqxrUWz7LuHOtSOgRW3tblJg==, tarball: file:projects/scripts.tgz}
name: '@rush-temp/scripts'
version: 0.0.0
dependencies:
'@babel/preset-env': 7.23.9(@babel/core@7.25.2)
'@jest/transform': 29.7.0
'@types/yargs': 17.0.33
babel-jest: 29.7.0(@babel/core@7.25.2)
jest: 29.7.0(@types/node@20.14.12)(ts-node@10.9.2)
yargs: 17.7.2
transitivePeerDependencies:
- '@babel/core'
- '@types/node'
- babel-plugin-macros
- node-notifier
- supports-color
- ts-node
dev: false
file:projects/server.tgz:

Просмотреть файл

@ -1,11 +1,19 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// Returns the filename in group1 of the regex match
const CHANGE_FILE_REGEX = /(?:change|change-beta)\/(@azure-communication-react[^\/]*\.json)(?:.*)?$/;
export function parseNewChangeFiles(stdout) {
// Split the output into lines
const lines = stdout.split('\n');
// Filter out the empty lines (`lines` list might have empty lines as part of the output)
const matches = lines.filter(line => line && line.toString().trim().length > 0);
// Split the output into lines and filter out the empty lines
const stdoutLines = stdout.split('\n').filter(line => line && line.toString().trim().length > 0);
// Parse the change file name from the output (remove the status and return only file information)
return matches.map(line => line.split('\t')[1]);
const matches = stdoutLines.map(line => {
const match = line.match(CHANGE_FILE_REGEX);
return match ? match[1] : undefined // Access group 1 (the filename);
}
).filter(Boolean); // Filter out nulls
return matches;
}

Просмотреть файл

@ -0,0 +1,38 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { parseNewChangeFiles } from './utils';
describe('parseNewChangeFiles', () => {
const testFilename = '@azure-communication-react-3ba4c269-8d22-48da-b905-091fdbaf2f98.json';
const testStrings = [
`A change-beta/${testFilename}`,
`A change/${testFilename}`,
`randomfolder/change-beta/${testFilename}random text that should be ignored`,
`\n\nchange/${testFilename}\s \n \t`
];
test('parseNewChangeFiles should return the filenames without folder prefixes or other space characters', () => {
for (const testString of testStrings) {
expect(parseNewChangeFiles(testString)).toStrictEqual([testFilename]);
}
});
test('parseNewChangeFiles should return the filenames when multiple files are seperated by newline characters', () => {
const test = testStrings.join('\n');
const expectedMatch = new Array(testStrings.length).fill(testFilename);
expect(parseNewChangeFiles(test)).toStrictEqual(expectedMatch);
});
test('parseNewChangeFiles should not return unrecognized lines in amonst legitmate changefiles', () => {
const testShouldnotMatch = 'change/randomfile.json';
const tests = [
testStrings[0],
testShouldnotMatch,
testStrings[1]
].join('\n');
expect(parseNewChangeFiles(tests)).toStrictEqual([testFilename, testFilename]);
});
});

Просмотреть файл

@ -0,0 +1,7 @@
module.exports = {
transform: {
'^.+\\.jsx?$': ['babel-jest', { configFile: './scripts-tests-setup/babel-config-jest.js' }],
'^.+\\.mjs$': ['babel-jest', { configFile: './scripts-tests-setup/babel-config-jest.js' }],
},
};

Просмотреть файл

@ -9,14 +9,18 @@
"build": "",
"build:stable": "",
"clean": "",
"test": "",
"test": "jest",
"test:ci-coverage": "",
"test:stable": "",
"prettier": "",
"prettier:check": ""
},
"devDependencies": {
"@babel/preset-env": "7.23.9",
"@jest/transform": "29.7.0",
"@types/yargs": "^17.0.29",
"babel-jest": "^29.5.0",
"jest": "29.7.0",
"yargs": "^17.7.2"
}
}

Просмотреть файл

@ -0,0 +1,5 @@
module.exports = {
presets: [
'@babel/preset-env' // to support `import` syntax in test files
]
};