Skip to content

Commit

Permalink
Merge branch 'stage' of https://github.com/adobecom/milo into mwpw-16…
Browse files Browse the repository at this point in the history
…3379
  • Loading branch information
sharmeeatadobe committed Dec 16, 2024
2 parents 3973197 + d543279 commit 4e5f78a
Show file tree
Hide file tree
Showing 334 changed files with 12,391 additions and 17,986 deletions.
1 change: 1 addition & 0 deletions .github/codeql/codeql-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ paths-ignore:
- 'tools/translation/**'
- node_modules
- libs/deps/mas
- libs/features/mas/dist
73 changes: 50 additions & 23 deletions .github/workflows/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,57 +3,83 @@
const owner = process.env.REPO_OWNER || ''; // example owner: adobecom
const repo = process.env.REPO_NAME || ''; // example repo name: milo
const auth = process.env.GH_TOKEN || ''; // https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens
const CURRENT_YEAR = 2024;
const RCPDates = [
{
start: new Date('2024-05-26T00:00:00-07:00'),
end: new Date('2024-06-01T00:00:00-07:00'),
start: new Date('2024-12-12T11:00:00-08:00'),
end: new Date('2024-12-12T14:00:00-08:00'),
},
{
start: new Date('2024-06-13T11:00:00-07:00'),
end: new Date('2024-06-13T14:00:00-07:00'),
start: new Date('2024-12-15T00:00:00-08:00'),
end: new Date('2025-01-02T00:00:00-08:00'),
},
{
start: new Date('2024-06-30T00:00:00-07:00'),
end: new Date('2024-07-06T00:00:00-07:00'),
start: new Date('2025-02-23T00:00:00-08:00'),
end: new Date('2025-03-01T00:00:00-08:00'),
},
{
start: new Date('2024-08-25T00:00:00-07:00'),
end: new Date('2024-08-31T00:00:00-07:00'),
start: new Date('2025-03-12T11:00:00-07:00'),
end: new Date('2025-03-12T14:00:00-07:00'),
},
{
start: new Date('2024-09-12T11:00:00-07:00'),
end: new Date('2024-09-12T14:00:00-07:00'),
start: new Date('2025-03-17T00:00:00-07:00'),
end: new Date('2025-03-20T17:00:00-07:00'),
},
{
start: new Date('2024-10-07T00:00:00-07:00'),
end: new Date('2024-10-18T17:00:00-07:00'),
start: new Date('2025-05-25T00:00:00-07:00'),
end: new Date('2025-05-31T00:00:00-07:00'),
},
{
start: new Date('2024-11-17T00:00:00-08:00'),
end: new Date('2024-11-30T00:00:00-08:00'),
start: new Date('2025-06-12T11:00:00-07:00'),
end: new Date('2025-06-12T14:00:00-07:00'),
},
{
start: new Date('2024-12-12T11:00:00-08:00'),
end: new Date('2024-12-12T14:00:00-08:00'),
start: new Date('2025-06-29T00:00:00-07:00'),
end: new Date('2025-07-05T00:00:00-07:00'),
},
{
start: new Date('2024-12-15T00:00:00-08:00'),
end: new Date('2025-01-02T00:00:00-08:00'),
start: new Date('2025-08-24T00:00:00-07:00'),
end: new Date('2025-08-30T00:00:00-07:00'),
},
{
start: new Date('2025-09-11T11:00:00-07:00'),
end: new Date('2025-09-11T14:00:00-07:00'),
},
{
start: new Date('2025-10-06T00:00:00-07:00'),
end: new Date('2025-10-16T17:00:00-07:00'),
},
{
start: new Date('2025-11-16T00:00:00-08:00'),
end: new Date('2025-11-29T00:00:00-08:00'),
},
{
start: new Date('2025-12-10T11:00:00-08:00'),
end: new Date('2025-12-10T14:00:00-08:00'),
},
{
start: new Date('2025-12-14T00:00:00-08:00'),
end: new Date('2026-01-04T00:00:00-08:00'),
},
];

const isWithinRCP = (offset = 0) => {
const isShortRCP = (start, end) => {
return ((end - start) / (1000 * 60 * 60)) < 24;
};

const isWithinRCP = ({ offset = 0, excludeShortRCP = false } = {}) => {
const now = new Date();
if (now.getFullYear() !== CURRENT_YEAR) {
console.log(`ADD NEW RCPs for ${CURRENT_YEAR + 1}`);
const lastRcpDate = RCPDates.reverse()[0];
if (now > lastRcpDate.end) {
console.log('ADD NEW RCPs for the current year');
return true;
}

if (RCPDates.some(({ start, end }) => {
const adjustedStart = new Date(start);
adjustedStart.setDate(adjustedStart.getDate() - offset);
return start <= now && now <= end
const match = adjustedStart <= now && now <= end;
if (!match || (excludeShortRCP && isShortRCP(start, end))) return false;
return true;
})) {
console.log(
'Current date is within a RCP (2 days earlier for stage, to keep stage clean & make CSO contributions during an RCP easier). Stopping execution.'
Expand Down Expand Up @@ -148,6 +174,7 @@ module.exports = {
getLocalConfigs,
slackNotification,
pulls: { addLabels, addFiles, getChecks, getReviews },
isShortRCP,
isWithinRCP,
RCPDates,
};
3 changes: 2 additions & 1 deletion .github/workflows/merge-to-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const {
const PR_TITLE = '[Release] Stage to Main';
const STAGE = 'stage';
const PROD = 'main';
const MIN_SOT_APPROVALS = process.env.MIN_SOT_APPROVALS ? Number(process.env.MIN_SOT_APPROVALS) : 4;

let github, owner, repo;

Expand Down Expand Up @@ -40,7 +41,7 @@ const main = async (params) => {
const stageToMainPR = await getStageToMainPR();
const signOffs = stageToMainPR?.labels.filter((l) => l.includes('SOT'));
console.log(`${signOffs.length} SOT labels on PR ${stageToMainPR.number}`);
if (signOffs.length >= 4) {
if (signOffs.length >= MIN_SOT_APPROVALS) {
console.log('Stage to Main PR has all required labels. Merging...');
await github.rest.pulls.merge({
owner,
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/merge-to-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:

env:
MILO_RELEASE_SLACK_WH: ${{ secrets.MILO_RELEASE_SLACK_WH }}
MIN_SOT_APPROVALS: ${{ secrets.MIN_SOT_APPROVALS }}

jobs:
merge-to-main:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/merge-to-stage.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ const main = async (params) => {
github = params.github;
owner = params.context.repo.owner;
repo = params.context.repo.repo;
if (isWithinRCP(process.env.STAGE_RCP_OFFSET_DAYS || 2)) return console.log('Stopped, within RCP period.');
if (isWithinRCP({ offset: process.env.STAGE_RCP_OFFSET_DAYS || 2, excludeShortRCP: true })) return console.log('Stopped, within RCP period.');

try {
const stageToMainPR = await getStageToMainPR();
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/rcp-notifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ const {
slackNotification,
getLocalConfigs,
RCPDates,
isShortRCP,
} = require('./helpers.js');

const isWithin24Hours = (targetDate) =>
Math.abs(new Date() - targetDate) <= 24 * 60 * 60 * 1000;
const isWithin24Hours = (targetDate) => {
const now = new Date();
return now < targetDate && new Date(now.getTime() + 24 * 60 * 60 * 1000) > targetDate;
};

const calculateDateOffset = (date, offset) => {
const newDate = new Date(date);
Expand All @@ -19,17 +22,18 @@ const main = async () => {
for (const rcp of RCPDates) {
const start = new Date(rcp.start);
const end = new Date(rcp.end);
const isShort = isShortRCP(start, end);
const tenDaysBefore = calculateDateOffset(start, 10);
const fourDaysBefore = calculateDateOffset(start, 4);
const stageOffset = Number(process.env.STAGE_RCP_OFFSET_DAYS) || 2;
const slackText = (days) =>
`Reminder RCP starts in ${days} days: from ${start.toUTCString()} to ${end.toUTCString()}. Merges to stage will be disabled beginning ${calculateDateOffset(start, stageOffset).toUTCString()}.`;
if (isWithin24Hours(tenDaysBefore)) {
if (isWithin24Hours(tenDaysBefore) && !isShort) {
console.log('Is within 24 hours of 10 days before RCP');
await slackNotification(slackText(10), process.env.MILO_DEV_HOOK);
}

if (isWithin24Hours(fourDaysBefore)) {
if (isWithin24Hours(fourDaysBefore) && !isShort) {
console.log('Is within 24 hours of 4 days before RCP');
await slackNotification(slackText(4), process.env.MILO_DEV_HOOK);
}
Expand Down
11 changes: 2 additions & 9 deletions .github/workflows/run-mas-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ jobs:
- name: Upload commerce coverage to Codecov
uses: codecov/codecov-action@v4
with:
name: mas-commerce
name: mas
token: ${{ secrets.CODECOV_TOKEN }}
files: libs/features/mas/commerce/coverage/lcov.info

- name: Upload web-components coverage to Codecov
uses: codecov/codecov-action@v4
with:
name: mas-web-components
token: ${{ secrets.CODECOV_TOKEN }}
files: libs/features/mas/web-components/coverage/lcov.info
files: libs/features/mas/coverage/lcov.info
6 changes: 2 additions & 4 deletions .github/workflows/run-nala-circleci.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
name: Nala Tests on CircleCI

on:
push:
branches:
- stage
workflow_dispatch:

jobs:
trigger-circleci:
Expand All @@ -15,4 +13,4 @@ jobs:
curl -X POST 'https://circle.ci.adobe.com/api/v2/project/gh/wcms/nala/pipeline' \
-H 'Circle-Token: ${{ secrets.CCI_TOKEN }}' \
-H 'content-type: application/json' \
-d "{\"branch\":\"main\"}"
-d "{\"branch\":\"main\"}"
1 change: 1 addition & 0 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install dependencies
run: npm install
Expand Down
15 changes: 14 additions & 1 deletion .github/workflows/update-dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Update file and create PR if needed
- name: Update ims lib and create PR if needed
uses: actions/github-script@v7
with:
script: |
Expand All @@ -26,5 +26,18 @@ jobs:
branch: 'update-imslib',
scriptPath: './libs/deps/imslib.min.js'
})
- name: Update forms2 and create PR if needed
uses: actions/github-script@v7
with:
script: |
const updateDependency = require('./.github/workflows/update-script.js')
updateDependency({
github,
context,
title: '[AUTOMATED-PR] Update forms2.min.js dependency',
path: 'https://engage.adobe.com/js/forms2/js/forms2.min.js',
branch: 'update-forms2',
scriptPath: './libs/deps/forms2.min.js'
})
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
96 changes: 61 additions & 35 deletions .github/workflows/update-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,41 +17,67 @@ const localRunConfigs = {
origin: process.env.LOCAL_RUN_ORIGIN || 'origin',
};

const getPrDescription = ({ branch, scriptPath }) => `## Description
Update ${scriptPath} to the latest version
## Related Issue
Resolves: NO TICKET - AUTOMATED CREATED PR.
## Testing instructions
1. Signing in should still function
2. Signing out should still work
3. Regression tests on all consumers
## Test URLs
**Acrobat:**
- Before: https://www.stage.adobe.com/acrobat/online/sign-pdf.html?martech=off
- After: https://www.stage.adobe.com/acrobat/online/sign-pdf.html?martech=off&milolibs=${branch}--milo--adobecom
**BACOM:**
- Before: https://business.stage.adobe.com/fr/customer-success-stories.html?martech=off
- After: https://business.stage.adobe.com/fr/customer-success-stories.html?martech=off&milolibs=${branch}--milo--adobecom
**CC:**
- Before: https://main--cc--adobecom.hlx.live/?martech=off
- After: https://main--cc--adobecom.hlx.live/?martech=off&milolibs=${branch}--milo--adobecom
**Homepage:**
- Before: https://main--homepage--adobecom.hlx.page/homepage/index-loggedout?martech=off
- After: https://main--homepage--adobecom.hlx.page/homepage/index-loggedout?martech=off&milolibs=${branch}--milo--adobecom
**Blog:**
- Before: https://main--blog--adobecom.hlx.page/?martech=off
- After: https://main--blog--adobecom.hlx.page/?martech=off&milolibs=${branch}--milo--adobecom
**Milo:**
- Before: https://main--milo--adobecom.aem.page/ch_de/drafts/ramuntea/gnav-refactor?martech=off
- After: https://${branch}--milo--adobecom.aem.page/ch_de/drafts/ramuntea/gnav-refactor?martech=off`;
const getPrDescription = ({ branch, scriptPath }) => {
switch(scriptPath) {
case './libs/deps/imslib.min.js':
return `## Description
Update ${scriptPath} to the latest version
## Related Issue
Resolves: NO TICKET - AUTOMATED CREATED PR.
## Testing instructions - IMS Libs
1. Signing in should still function
2. Signing out should still work
3. Regression tests on all consumers
## Test URLs - IMS
**Acrobat:**
- Before: https://www.stage.adobe.com/acrobat/online/sign-pdf.html?martech=off
- After: https://www.stage.adobe.com/acrobat/online/sign-pdf.html?martech=off&milolibs=${branch}--milo--adobecom
**BACOM:**
- Before: https://business.stage.adobe.com/fr/customer-success-stories.html?martech=off
- After: https://business.stage.adobe.com/fr/customer-success-stories.html?martech=off&milolibs=${branch}--milo--adobecom
**CC:**
- Before: https://main--cc--adobecom.hlx.live/?martech=off
- After: https://main--cc--adobecom.hlx.live/?martech=off&milolibs=${branch}--milo--adobecom
**Homepage:**
- Before: https://main--homepage--adobecom.hlx.page/homepage/index-loggedout?martech=off
- After: https://main--homepage--adobecom.hlx.page/homepage/index-loggedout?martech=off&milolibs=${branch}--milo--adobecom
**Blog:**
- Before: https://main--blog--adobecom.hlx.page/?martech=off
- After: https://main--blog--adobecom.hlx.page/?martech=off&milolibs=${branch}--milo--adobecom
**Milo:**
- Before: https://main--milo--adobecom.aem.page/ch_de/drafts/ramuntea/gnav-refactor?martech=off
- After: https://${branch}--milo--adobecom.aem.page/ch_de/drafts/ramuntea/gnav-refactor?martech=off`
case './libs/deps/forms2.min.js':
return `## Description
Update ${scriptPath} to the latest version
## Related Issue
Resolves: NO TICKET - AUTOMATED CREATED PR.
## Testing instructions - Marketo Forms
1. The form should still load
2. The form should still submit
3. The form should redirect you a new page
## Test URLs - Marketo
**BACOM:**
- Before: https://business.stage.adobe.com?martech=off
- After: https://business.stage.adobe.com?martech=off&milolibs=${branch}--milo--adobecom
**Milo:**
- Before: https://main--milo--adobecom.hlx.live/drafts/bmarshal/marketo/full
- After: https://${branch}--milo--adobecom.hlx.live/drafts/bmarshal/marketo/full`
}
}

const fetchScript = (path) =>
new Promise((resolve, reject) => {
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ logs/*
test-html-results/
test-results/
test-a11y-results/
tmp
libs/navigation/dist/
1 change: 1 addition & 0 deletions .hlxignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ web-test-runner.config.mjs
codecov.yaml
libs/features/mas/*
!libs/features/mas/docs
!libs/features/mas/dist
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ npm run test:watch
-----

#### 1. Running Nala Tests
Make sure you ran `npm run install` in the project root.
You might need also to run `npx playwright install`.
Nala tests are run using the `npm run nala <env> [options]` command:

```sh
Expand All @@ -91,8 +93,14 @@ npm run nala <env> [options]
- config=<config-file> # Configuration file (default: Playwright default)
- project=<project-name> # Project configuration (default: milo-live-chromium)
- milolibs=<local|prod|feature|any|> # Milolibs?=<env>
```

Examples:
```
npm run nala local test=masccd.test.js # Run tests from masccd.test.js file on your local changes. Don't forget `aem up` before running.
npm run nala MWPW-162385 owner='npeltier' @mas-ccd # Run tests tagged as 'mas-ccd' in 'npeltier' fork on MWPW-162385 branch
```

#### 2. Nala Help Command:
To view examples of how to use Nala commands with various options, you can run
```sh
Expand Down
Loading

0 comments on commit 4e5f78a

Please sign in to comment.