Skip to content

Commit

Permalink
Merge branch 'stage' of github.com:adobecom/milo into all-elements
Browse files Browse the repository at this point in the history
  • Loading branch information
John Pratt committed Jan 7, 2025
2 parents 0d3d1e6 + 82694a3 commit 11400a1
Show file tree
Hide file tree
Showing 474 changed files with 26,661 additions and 20,098 deletions.
1 change: 1 addition & 0 deletions .eslintrc-code-compatibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module.exports = {
],
ignorePatterns: [
'/libs/deps/*',
'/libs/navigation/dist/*',
'/tools/loc/*',
],
};
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ module.exports = {
'/libs/features/mas/*',
'/tools/loc/*',
'/libs/features/spectrum-web-components/*',
'/libs/navigation/dist/*',
],
plugins: [
'chai-friendly',
Expand Down
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
11 changes: 6 additions & 5 deletions .github/workflows/merge-to-stage.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,20 @@ const LABELS = {
zeroImpact: 'zero-impact',
};
const TEAM_MENTIONS = [
'@adobecom/miq-sot',
'@adobecom/bacom-sot',
'@adobecom/homepage-sot',
'@adobecom/creative-cloud-sot',
'@adobecom/document-cloud-sot',
'@adobecom/express-sot',
'@adobecom/homepage-sot',
'@adobecom/miq-sot',
];
const SLACK = {
merge: ({ html_url, number, title, prefix = '' }) => `:merged: PR merged to stage: ${prefix} <${html_url}|${number}: ${title}>.`,
openedSyncPr: ({ html_url, number }) => `:fast_forward: Created <${html_url}|Stage to Main PR ${number}>`,
};

let github;
let owner;
let github;
let owner;
let repo;

let body = `
Expand Down Expand Up @@ -230,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
55 changes: 55 additions & 0 deletions .github/workflows/release-standalone-feds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Create a Release for Standalone Feds GlobalNav and Footer
on:
workflow_dispatch:
inputs:
version:
description: 'Version'
required: true
type: string

permissions:
contents: write

jobs:
release-feds:
name: Release Standalone Feds
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
defaults:
run:
working-directory: ./libs/navigation
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: npm install

- name: Build Files
run: node ./build.mjs

- name: Generate tarball
run: npm pack

- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "feds-standalone-v${{ inputs.version }}" \
--repo="$GITHUB_REPOSITORY" \
--title="@adobecom/standalone-feds v${{ inputs.version }} Release" \
--generate-notes
- name: Upload Files to Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload "feds-standalone-v${{ inputs.version }}" "adobecom-standalone-feds-${{ inputs.version }}.tgz"
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
Loading

0 comments on commit 11400a1

Please sign in to comment.