Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[No QA] Update GitUtils to work with manual version bumps #44123

Merged
merged 14 commits into from
Jun 21, 2024
4 changes: 3 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const path = require('path');

const restrictedImportPaths = [
{
name: 'react-native',
Expand Down Expand Up @@ -96,7 +98,7 @@ module.exports = {
plugins: ['@typescript-eslint', 'jsdoc', 'you-dont-need-lodash-underscore', 'react-native-a11y', 'react', 'testing-library'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json',
project: path.resolve(__dirname, './tsconfig.json'),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change was really just a QOL improvement to fix this issue with JetBrains IDE's.

inline lint warnings were not working for any files with a separate eslint config (tests, GitHub Actions, etc...)

This fixes that by using an absolute path for the project's tsconfig.json..

},
env: {
jest: true,
Expand Down
16 changes: 8 additions & 8 deletions .github/actions/javascript/authorChecklist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11710,7 +11710,7 @@ FetchError.prototype.name = 'FetchError';

let convert;
try {
convert = (__nccwpck_require__(2877).convert);
convert = (__nccwpck_require__(3975).convert);
} catch (e) {}

const INTERNALS = Symbol('Body internals');
Expand Down Expand Up @@ -17557,27 +17557,27 @@ exports["default"] = arrayDifference;

/***/ }),

/***/ 2877:
/***/ 9491:
/***/ ((module) => {

module.exports = eval("require")("encoding");

"use strict";
module.exports = require("assert");

/***/ }),

/***/ 9491:
/***/ 6113:
/***/ ((module) => {

"use strict";
module.exports = require("assert");
module.exports = require("crypto");

/***/ }),

/***/ 6113:
/***/ 3975:
/***/ ((module) => {

"use strict";
module.exports = require("crypto");
module.exports = require("encoding");

/***/ }),

Expand Down
16 changes: 8 additions & 8 deletions .github/actions/javascript/awaitStagingDeploys/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7373,7 +7373,7 @@ FetchError.prototype.name = 'FetchError';

let convert;
try {
convert = (__nccwpck_require__(2877).convert);
convert = (__nccwpck_require__(3975).convert);
} catch (e) {}

const INTERNALS = Symbol('Body internals');
Expand Down Expand Up @@ -12822,27 +12822,27 @@ exports["default"] = arrayDifference;

/***/ }),

/***/ 2877:
/***/ 9491:
/***/ ((module) => {

module.exports = eval("require")("encoding");

"use strict";
module.exports = require("assert");

/***/ }),

/***/ 9491:
/***/ 6113:
/***/ ((module) => {

"use strict";
module.exports = require("assert");
module.exports = require("crypto");

/***/ }),

/***/ 6113:
/***/ 3975:
/***/ ((module) => {

"use strict";
module.exports = require("crypto");
module.exports = require("encoding");

/***/ }),

Expand Down
5 changes: 3 additions & 2 deletions .github/actions/javascript/bumpVersion/bumpVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type {PackageJson} from 'type-fest';
import {promisify} from 'util';
import {generateAndroidVersionCode, updateAndroidVersion, updateiOSVersion} from '@github/libs/nativeVersionUpdater';
import * as versionUpdater from '@github/libs/versionUpdater';
import type {SemverLevel} from '@github/libs/versionUpdater';

const exec = promisify(originalExec);

Expand Down Expand Up @@ -43,7 +44,7 @@ function updateNativeVersions(version: string) {
}

let semanticVersionLevel = core.getInput('SEMVER_LEVEL', {required: true});
if (!semanticVersionLevel || !Object.keys(versionUpdater.SEMANTIC_VERSION_LEVELS).includes(semanticVersionLevel)) {
if (!semanticVersionLevel || !versionUpdater.isValidSemverLevel(semanticVersionLevel)) {
semanticVersionLevel = versionUpdater.SEMANTIC_VERSION_LEVELS.BUILD;
console.log(`Invalid input for 'SEMVER_LEVEL': ${semanticVersionLevel}`, `Defaulting to: ${semanticVersionLevel}`);
}
Expand All @@ -53,7 +54,7 @@ if (!previousVersion) {
core.setFailed('Error: Could not read package.json');
}

const newVersion = versionUpdater.incrementVersion(previousVersion ?? '', semanticVersionLevel);
const newVersion = versionUpdater.incrementVersion(previousVersion ?? '', semanticVersionLevel as SemverLevel);
console.log(`Previous version: ${previousVersion}`, `New version: ${newVersion}`);

updateNativeVersions(newVersion);
Expand Down
8 changes: 6 additions & 2 deletions .github/actions/javascript/bumpVersion/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3473,7 +3473,7 @@ function updateNativeVersions(version) {
}
}
let semanticVersionLevel = core.getInput('SEMVER_LEVEL', { required: true });
if (!semanticVersionLevel || !Object.keys(versionUpdater.SEMANTIC_VERSION_LEVELS).includes(semanticVersionLevel)) {
if (!semanticVersionLevel || !versionUpdater.isValidSemverLevel(semanticVersionLevel)) {
semanticVersionLevel = versionUpdater.SEMANTIC_VERSION_LEVELS.BUILD;
console.log(`Invalid input for 'SEMVER_LEVEL': ${semanticVersionLevel}`, `Defaulting to: ${semanticVersionLevel}`);
}
Expand Down Expand Up @@ -3589,7 +3589,7 @@ exports.updateiOSVersion = updateiOSVersion;
"use strict";

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.getPreviousVersion = exports.incrementPatch = exports.incrementMinor = exports.SEMANTIC_VERSION_LEVELS = exports.MAX_INCREMENTS = exports.incrementVersion = exports.getVersionStringFromNumber = exports.getVersionNumberFromString = void 0;
exports.getPreviousVersion = exports.incrementPatch = exports.incrementMinor = exports.SEMANTIC_VERSION_LEVELS = exports.MAX_INCREMENTS = exports.incrementVersion = exports.getVersionStringFromNumber = exports.getVersionNumberFromString = exports.isValidSemverLevel = void 0;
const SEMANTIC_VERSION_LEVELS = {
MAJOR: 'MAJOR',
MINOR: 'MINOR',
Expand All @@ -3599,6 +3599,10 @@ const SEMANTIC_VERSION_LEVELS = {
exports.SEMANTIC_VERSION_LEVELS = SEMANTIC_VERSION_LEVELS;
const MAX_INCREMENTS = 99;
exports.MAX_INCREMENTS = MAX_INCREMENTS;
function isValidSemverLevel(str) {
return Object.keys(SEMANTIC_VERSION_LEVELS).includes(str);
}
exports.isValidSemverLevel = isValidSemverLevel;
/**
* Transforms a versions string into a number
*/
Expand Down
16 changes: 8 additions & 8 deletions .github/actions/javascript/checkDeployBlockers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6679,7 +6679,7 @@ FetchError.prototype.name = 'FetchError';

let convert;
try {
convert = (__nccwpck_require__(2877).convert);
convert = (__nccwpck_require__(3975).convert);
} catch (e) {}

const INTERNALS = Symbol('Body internals');
Expand Down Expand Up @@ -12050,27 +12050,27 @@ exports["default"] = arrayDifference;

/***/ }),

/***/ 2877:
/***/ 9491:
/***/ ((module) => {

module.exports = eval("require")("encoding");

"use strict";
module.exports = require("assert");

/***/ }),

/***/ 9491:
/***/ 6113:
/***/ ((module) => {

"use strict";
module.exports = require("assert");
module.exports = require("crypto");

/***/ }),

/***/ 6113:
/***/ 3975:
/***/ ((module) => {

"use strict";
module.exports = require("crypto");
module.exports = require("encoding");

/***/ }),

Expand Down
90 changes: 77 additions & 13 deletions .github/actions/javascript/createOrUpdateStagingDeploy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9434,7 +9434,7 @@ FetchError.prototype.name = 'FetchError';

let convert;
try {
convert = (__nccwpck_require__(2877).convert);
convert = (__nccwpck_require__(3975).convert);
} catch (e) {}

const INTERNALS = Symbol('Body internals');
Expand Down Expand Up @@ -14401,7 +14401,66 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
const child_process_1 = __nccwpck_require__(2081);
const CONST_1 = __importDefault(__nccwpck_require__(9873));
const sanitizeStringForJSONParse_1 = __importDefault(__nccwpck_require__(3902));
const VERSION_UPDATER = __importStar(__nccwpck_require__(8982));
const VersionUpdater = __importStar(__nccwpck_require__(8982));
/**
* Check if a tag exists locally or in the remote.
*/
function tagExists(tag) {
try {
// Check if the tag exists locally
(0, child_process_1.execSync)(`git show-ref --tags ${tag}`, { stdio: 'ignore' });
return true; // Tag exists locally
}
catch (error) {
// Tag does not exist locally, check in remote
let shouldRetry = true;
let needsRepack = false;
let doesTagExist = false;
while (shouldRetry) {
try {
if (needsRepack) {
// We have seen some scenarios where this fixes the git fetch.
// Why? Who knows... https://github.com/Expensify/App/pull/31459
(0, child_process_1.execSync)('git repack -d', { stdio: 'inherit' });
}
(0, child_process_1.execSync)(`git ls-remote --exit-code --tags origin ${tag}`, { stdio: 'ignore' });
doesTagExist = true;
shouldRetry = false;
}
catch (e) {
if (!needsRepack) {
console.log('Attempting to repack and retry...');
needsRepack = true;
}
else {
console.error("Repack didn't help, giving up...");
shouldRetry = false;
}
}
}
return doesTagExist;
}
}
/**
* This essentially just calls getPreviousVersion in a loop, until it finds a version for which a tag exists.
* It's useful if we manually perform a version bump, because in that case a tag may not exist for the previous version.
*
* @param tag the current tag
* @param level the Semver level to step backward by
*/
function getPreviousExistingTag(tag, level) {
let previousVersion = VersionUpdater.getPreviousVersion(tag, level);
let tagExistsForPreviousVersion = false;
while (!tagExistsForPreviousVersion) {
if (tagExists(previousVersion)) {
tagExistsForPreviousVersion = true;
break;
}
console.log(`Tag for previous version ${previousVersion} does not exist. Checking for an older version...`);
previousVersion = VersionUpdater.getPreviousVersion(previousVersion, level);
}
return previousVersion;
}
/**
* @param [shallowExcludeTag] When fetching the given tag, exclude all history reachable by the shallowExcludeTag (used to make fetch much faster)
*/
Expand Down Expand Up @@ -14444,8 +14503,8 @@ function fetchTag(tag, shallowExcludeTag = '') {
* Get merge logs between two tags (inclusive) as a JavaScript object.
*/
function getCommitHistoryAsJSON(fromTag, toTag) {
// Fetch tags, exclude commits reachable from the previous patch version (i.e: previous checklist), so that we don't have to fetch the full history
const previousPatchVersion = VERSION_UPDATER.getPreviousVersion(fromTag, VERSION_UPDATER.SEMANTIC_VERSION_LEVELS.PATCH);
// Fetch tags, excluding commits reachable from the previous patch version (i.e: previous checklist), so that we don't have to fetch the full history
const previousPatchVersion = getPreviousExistingTag(fromTag, VersionUpdater.SEMANTIC_VERSION_LEVELS.PATCH);
fetchTag(fromTag, previousPatchVersion);
fetchTag(toTag, previousPatchVersion);
console.log('Getting pull requests merged between the following tags:', fromTag, toTag);
Expand Down Expand Up @@ -14517,6 +14576,7 @@ async function getPullRequestsMergedBetween(fromTag, toTag) {
return pullRequestNumbers;
}
exports["default"] = {
getPreviousExistingTag,
getValidMergedPRs,
getPullRequestsMergedBetween,
};
Expand Down Expand Up @@ -15026,7 +15086,7 @@ exports["default"] = sanitizeStringForJSONParse;
"use strict";

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.getPreviousVersion = exports.incrementPatch = exports.incrementMinor = exports.SEMANTIC_VERSION_LEVELS = exports.MAX_INCREMENTS = exports.incrementVersion = exports.getVersionStringFromNumber = exports.getVersionNumberFromString = void 0;
exports.getPreviousVersion = exports.incrementPatch = exports.incrementMinor = exports.SEMANTIC_VERSION_LEVELS = exports.MAX_INCREMENTS = exports.incrementVersion = exports.getVersionStringFromNumber = exports.getVersionNumberFromString = exports.isValidSemverLevel = void 0;
const SEMANTIC_VERSION_LEVELS = {
MAJOR: 'MAJOR',
MINOR: 'MINOR',
Expand All @@ -15036,6 +15096,10 @@ const SEMANTIC_VERSION_LEVELS = {
exports.SEMANTIC_VERSION_LEVELS = SEMANTIC_VERSION_LEVELS;
const MAX_INCREMENTS = 99;
exports.MAX_INCREMENTS = MAX_INCREMENTS;
function isValidSemverLevel(str) {
return Object.keys(SEMANTIC_VERSION_LEVELS).includes(str);
}
exports.isValidSemverLevel = isValidSemverLevel;
/**
* Transforms a versions string into a number
*/
Expand Down Expand Up @@ -15152,14 +15216,6 @@ function arrayDifference(array1, array2) {
exports["default"] = arrayDifference;


/***/ }),

/***/ 2877:
/***/ ((module) => {

module.exports = eval("require")("encoding");


/***/ }),

/***/ 9491:
Expand All @@ -15186,6 +15242,14 @@ module.exports = require("crypto");

/***/ }),

/***/ 3975:
/***/ ((module) => {

"use strict";
module.exports = require("encoding");

/***/ }),

/***/ 2361:
/***/ ((module) => {

Expand Down
16 changes: 8 additions & 8 deletions .github/actions/javascript/getArtifactInfo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6679,7 +6679,7 @@ FetchError.prototype.name = 'FetchError';

let convert;
try {
convert = (__nccwpck_require__(2877).convert);
convert = (__nccwpck_require__(3975).convert);
} catch (e) {}

const INTERNALS = Symbol('Body internals');
Expand Down Expand Up @@ -12011,27 +12011,27 @@ exports["default"] = arrayDifference;

/***/ }),

/***/ 2877:
/***/ 9491:
/***/ ((module) => {

module.exports = eval("require")("encoding");

"use strict";
module.exports = require("assert");

/***/ }),

/***/ 9491:
/***/ 6113:
/***/ ((module) => {

"use strict";
module.exports = require("assert");
module.exports = require("crypto");

/***/ }),

/***/ 6113:
/***/ 3975:
/***/ ((module) => {

"use strict";
module.exports = require("crypto");
module.exports = require("encoding");

/***/ }),

Expand Down
Loading
Loading