Skip to content

Commit

Permalink
Merge origin/main into master-sync
Browse files Browse the repository at this point in the history
  • Loading branch information
danjm committed Dec 18, 2024
2 parents c5dd2e3 + f8a1d4f commit ab8ecae
Show file tree
Hide file tree
Showing 830 changed files with 60,651 additions and 41,674 deletions.
41 changes: 24 additions & 17 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ executors:
NODE_OPTIONS: --max_old_space_size=3072
node-linux-medium:
machine:
image: ubuntu-2404:current
image: ubuntu-2404:2024.05.1
resource_class: medium #// linux medium: 2 CPUs, 7.5 GB RAM, 10 credits/min
environment:
NODE_OPTIONS: --max_old_space_size=6144
Expand Down Expand Up @@ -45,11 +45,11 @@ rc_branch_only: &rc_branch_only
only:
- /^Version-v(\d+)[.](\d+)[.](\d+)/

develop_master_rc_only: &develop_master_rc_only
main_master_rc_only: &main_master_rc_only
filters:
branches:
only:
- develop
- main
- master
- /^Version-v(\d+)[.](\d+)[.](\d+)/

Expand Down Expand Up @@ -107,7 +107,9 @@ workflows:
- matches:
pattern: /^l10n_crowdin_action$/
value: << pipeline.git.branch >>
- equal: [rerun-from-failed, << pipeline.schedule.name >>]
- matches:
pattern: /^rerun-from-failed.*/
value: << pipeline.schedule.name >>
jobs:
- create_release_pull_request:
<<: *rc_branch_only
Expand All @@ -123,6 +125,8 @@ workflows:
branches:
ignore:
- master
requires:
- prep-deps
- test-deps-audit:
requires:
- prep-deps
Expand Down Expand Up @@ -172,7 +176,7 @@ workflows:
requires:
- prep-deps
- prep-build-test-flask-mv2:
<<: *develop_master_rc_only
<<: *main_master_rc_only
requires:
- prep-deps
- prep-build-test-mmi:
Expand Down Expand Up @@ -200,7 +204,7 @@ workflows:
requires:
- prep-deps
- test-e2e-chrome-webpack:
<<: *develop_master_rc_only
<<: *main_master_rc_only
requires:
- prep-build-test-webpack
- get-changed-files-with-git-diff
Expand All @@ -209,7 +213,7 @@ workflows:
- prep-build-test
- get-changed-files-with-git-diff
- test-e2e-firefox:
<<: *develop_master_rc_only
<<: *main_master_rc_only
requires:
- prep-build-test-mv2
- get-changed-files-with-git-diff
Expand All @@ -220,6 +224,7 @@ workflows:
- test-api-specs:
requires:
- prep-build-test
- get-changed-files-with-git-diff
- test-e2e-chrome-multiple-providers:
requires:
- prep-build-test
Expand All @@ -229,7 +234,7 @@ workflows:
- prep-build-test-flask
- get-changed-files-with-git-diff
- test-e2e-firefox-flask:
<<: *develop_master_rc_only
<<: *main_master_rc_only
requires:
- prep-build-test-flask-mv2
- test-e2e-chrome-mmi:
Expand All @@ -250,7 +255,7 @@ workflows:
filters:
branches:
only:
- develop
- main
- /^Version-v(\d+)[.](\d+)[.](\d+)/
requires:
- prep-build
Expand Down Expand Up @@ -349,25 +354,27 @@ workflows:
- job-publish-storybook:
filters:
branches:
only: develop
only: main
requires:
- prep-build-storybook
- job-publish-ts-migration-dashboard:
filters:
branches:
only: develop
only: main
requires:
- prep-build-ts-migration-dashboard

rerun-from-failed:
when:
equal: [rerun-from-failed, << pipeline.schedule.name >>]
matches:
pattern: /^rerun-from-failed.*/
value: << pipeline.schedule.name >>
jobs:
- prep-deps
- rerun-workflows-from-failed:
filters:
branches:
only: develop
only: main
requires:
- prep-deps

Expand Down Expand Up @@ -477,7 +484,7 @@ jobs:

# This job is used for the e2e quality gate.
# It must be run before any job which uses the run-all.js script.
# The job is skipped in develop, master or RC branches.
# The job is skipped in main, master or RC branches.
get-changed-files-with-git-diff:
executor: node-browsers-small
steps:
Expand All @@ -487,7 +494,7 @@ jobs:
at: .
- run:
name: Get changed files with git diff
command: npx tsx .circleci/scripts/git-diff-develop.ts
command: yarn git-diff-default-branch
- persist_to_workspace:
root: .
paths:
Expand Down Expand Up @@ -1335,7 +1342,7 @@ jobs:
template: basic_fail_1
channel: C01LUJL3T98
- slack/notify:
branch_pattern: develop
branch_pattern: main
event: fail
mentions: <@antonio.regadas>, @ramon.acitores134
template: basic_fail_1
Expand Down Expand Up @@ -1745,7 +1752,7 @@ jobs:
command: echo 'whew - everything passed!'

check-mmi-trigger:
executor: node-browsers-medium
executor: node-browsers-small
steps:
- checkout
- run:
Expand Down
4 changes: 2 additions & 2 deletions .circleci/scripts/bundle-stats-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ then
exit 1
fi

if [[ "${CIRCLE_BRANCH}" != "develop" ]]
if [[ "${CIRCLE_BRANCH}" != "main" ]]
then
printf 'This is not develop branch'
printf 'This is not main branch'
exit 0
fi

Expand Down
2 changes: 1 addition & 1 deletion .circleci/scripts/check_mmi_trigger.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if [ -z "$CIRCLE_PULL_REQUEST" ] || [ -z "$GITHUB_TOKEN" ]; then
exit 0
fi

if [[ $CIRCLE_BRANCH = 'develop' || $CIRCLE_BRANCH = 'master' || $CIRCLE_BRANCH =~ ^Version-v[0-9.]* ]]; then
if [[ $CIRCLE_BRANCH = 'main' || $CIRCLE_BRANCH = 'master' || $CIRCLE_BRANCH =~ ^Version-v[0-9.]* ]]; then
echo "Long-running branch detected, running MMI tests."
echo "run_mmi_tests=true" > mmi_trigger.env
exit 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const PR_NUMBER =
process.env.CIRCLE_PR_NUMBER ||
process.env.CIRCLE_PULL_REQUEST?.split('/').pop();

const MAIN_BRANCH = 'develop';
const GITHUB_DEFAULT_BRANCH = 'main';
const SOURCE_BRANCH = `refs/pull/${PR_NUMBER}/head`;

const CHANGED_FILES_DIR = 'changed-files';
Expand Down Expand Up @@ -48,7 +48,7 @@ async function getPrInfo(): Promise<PRInfo | null> {
*/
async function fetchWithDepth(depth: number): Promise<boolean> {
try {
await exec(`git fetch --depth ${depth} origin "${MAIN_BRANCH}"`);
await exec(`git fetch --depth ${depth} origin "${GITHUB_DEFAULT_BRANCH}"`);
await exec(
`git fetch --depth ${depth} origin "${SOURCE_BRANCH}:${SOURCE_BRANCH}"`,
);
Expand Down Expand Up @@ -84,7 +84,7 @@ async function fetchUntilMergeBaseFound() {
}
}
}
await exec(`git fetch --unshallow origin "${MAIN_BRANCH}"`);
await exec(`git fetch --unshallow origin "${GITHUB_DEFAULT_BRANCH}"`);
}

/**
Expand Down Expand Up @@ -123,9 +123,7 @@ async function storeGitDiffOutputAndPrBody() {
// even if we want to skip this step.
fs.mkdirSync(CHANGED_FILES_DIR, { recursive: true });

console.log(
`Determining whether to run git diff...`,
);
console.log(`Determining whether to run git diff...`);
if (!PR_NUMBER) {
console.log('Not a PR, skipping git diff');
return;
Expand All @@ -137,11 +135,13 @@ async function storeGitDiffOutputAndPrBody() {
if (!baseRef) {
console.log('Not a PR, skipping git diff');
return;
} else if (baseRef !== MAIN_BRANCH) {
} else if (baseRef !== GITHUB_DEFAULT_BRANCH) {
console.log(`This is for a PR targeting '${baseRef}', skipping git diff`);
writePrBodyToFile(prInfo.body);
return;
} else if (prInfo.labels.some(label => label.name === 'skip-e2e-quality-gate')) {
} else if (
prInfo.labels.some((label) => label.name === 'skip-e2e-quality-gate')
) {
console.log('PR has the skip-e2e-quality-gate label, skipping git diff');
return;
}
Expand All @@ -164,4 +164,7 @@ async function storeGitDiffOutputAndPrBody() {
}
}

storeGitDiffOutputAndPrBody();
// If main module (i.e. this is the TS file that was run directly)
if (require.main === module) {
storeGitDiffOutputAndPrBody();
}
13 changes: 7 additions & 6 deletions .circleci/scripts/rerun-ci-workflow-from-failed.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const CIRCLE_TOKEN = process.env.API_V2_TOKEN;
const GITHUB_DEFAULT_BRANCH = 'main';

interface Actor {
login: string;
Expand Down Expand Up @@ -59,7 +60,7 @@ interface WorkflowStatusResponse {
* Note: the API returns the first 20 workflows by default.
* If we wanted to get older workflows, we would need to use the 'page-token' we would get in the first response
* and perform a subsequent request with the 'page-token' parameter.
* This seems unnecessary as of today, as the amount of daily PRs merged to develop is not that high.
* This seems unnecessary as of today, as the amount of daily PRs merged to main is not that high.
*
* @returns {Promise<WorkflowItem[]>} A promise that resolves to an array of workflow items.
* @throws Will throw an error if the CircleCI token is not defined or if the HTTP request fails.
Expand Down Expand Up @@ -177,7 +178,7 @@ async function rerunWorkflowById(workflowId: string) {
}

/**
* Re-runs failed CircleCI workflows from develop branch.
* Re-runs failed CircleCI workflows from default branch.
* The workflow will only be re-runed if:
* 1. It has the status of 'failed'
* 2. It has only been run once
Expand All @@ -186,9 +187,9 @@ async function rerunWorkflowById(workflowId: string) {
*
* @throws Will throw an error if fetching the workflows or re-running a workflow fails.
*/
async function rerunFailedWorkflowsFromDevelop() {
console.log('Getting Circle Ci workflows from develop branch...');
const workflows = await getCircleCiWorkflowsByBranch('develop');
async function rerunFailedWorkflowsFromDefaultBranch() {
console.log('Getting Circle Ci workflows from main branch...');
const workflows = await getCircleCiWorkflowsByBranch(GITHUB_DEFAULT_BRANCH);

console.log('Assessing if any of the workflows needs to be rerun...');
for (const item of workflows) {
Expand All @@ -204,7 +205,7 @@ async function rerunFailedWorkflowsFromDevelop() {
console.log('Task completed successfully!');
}

rerunFailedWorkflowsFromDevelop()
rerunFailedWorkflowsFromDefaultBranch()
.catch((error) => {
console.error(error);
process.exitCode = 1;
Expand Down
23 changes: 19 additions & 4 deletions .circleci/scripts/test-run-e2e-timeout-minutes.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
import { fetchManifestFlagsFromPRAndGit } from '../../development/lib/get-manifest-flag';
import { filterE2eChangedFiles } from '../../test/e2e/changedFilesUtil';

const changedOrNewTests = filterE2eChangedFiles();
fetchManifestFlagsFromPRAndGit().then((manifestFlags) => {
let timeout;

// 20 minutes, plus 3 minutes for every changed file, up to a maximum of 30 minutes
const extraTime = Math.min(20 + changedOrNewTests.length * 3, 30);
if (manifestFlags.circleci?.timeoutMinutes) {
timeout = manifestFlags.circleci?.timeoutMinutes;
} else {
const changedOrNewTests = filterE2eChangedFiles();

console.log(extraTime);
// 20 minutes, plus 3 minutes for every changed file, up to a maximum of 30 minutes
timeout = Math.min(20 + changedOrNewTests.length * 3, 30);
}

// If this is the Merge Queue, add 10 minutes
if (process.env.CIRCLE_BRANCH?.startsWith('gh-readonly-queue')) {
timeout += 10;
}

// This is an essential log, that feeds into a bash script
console.log(timeout);
});
2 changes: 1 addition & 1 deletion .devcontainer/download-builds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function getGitBranch() {
const gitOutput = execSync('git status').toString();

const branchRegex = /On branch (?<branch>.*)\n/;
return gitOutput.match(branchRegex)?.groups?.branch || 'develop';
return gitOutput.match(branchRegex)?.groups?.branch || 'main';
}

async function getCircleJobs(branch: string) {
Expand Down
Loading

0 comments on commit ab8ecae

Please sign in to comment.