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

[Release] Stage to Main #2359

Merged
merged 8 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/high-impact-alert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const {

Check warning on line 1 in .github/workflows/high-impact-alert.js

View workflow job for this annotation

GitHub Actions / Running eslint

[eslint] reported by reviewdog 🐶 File ignored by default. Use a negated ignore pattern (like "--ignore-pattern '!<relative/path/to/filename>'") to override. Raw Output: {"fatal":false,"severity":1,"message":"File ignored by default. Use a negated ignore pattern (like \"--ignore-pattern '!<relative/path/to/filename>'\") to override."}
slackNotification,
getLocalConfigs,
} = require('./helpers.js');

const main = async (params) => {
const { context } = params;

try {
if (context.payload.label.name !== 'high-impact') {
console.log('No high impact label detected');
return;
}

const { html_url, number, title } = context.payload.pull_request;
console.log('High impact label detected, sending Slack notification');
slackNotification(`:alert: High Impact PR has been opened: <${html_url}|#${number}: ${title}>.` +
` Please prioritize testing the proposed changes.`, process.env.SLACK_HIGH_IMPACT_PR_WEBHOOK);
} catch (error) {
console.error(error);
}
};

if (process.env.LOCAL_RUN) {
const { context } = getLocalConfigs();
main({ context });
}

module.exports = main;
24 changes: 24 additions & 0 deletions .github/workflows/high-impact-alert.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: High Impact Alert

on:
pull_request:
types:
- labeled

env:
SLACK_HIGH_IMPACT_PR_WEBHOOK: ${{ secrets.SLACK_HIGH_IMPACT_PR_WEBHOOK }}

jobs:
send_alert:
if: github.repository_owner == 'adobecom'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4.1.4

- name: Send Slack message for high impact PRs
uses: actions/github-script@v7.0.1
with:
script: |
const main = require('./.github/workflows/high-impact-alert.js')
main({ github, context })
1 change: 1 addition & 0 deletions .github/workflows/mark-stale-prs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:

jobs:
stale:
if: github.repository_owner == 'adobecom'
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v9
Expand Down
21 changes: 4 additions & 17 deletions .github/workflows/merge-to-stage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const {

Check warning on line 1 in .github/workflows/merge-to-stage.js

View workflow job for this annotation

GitHub Actions / Running eslint

[eslint] reported by reviewdog 🐶 File ignored by default. Use a negated ignore pattern (like "--ignore-pattern '!<relative/path/to/filename>'") to override. Raw Output: {"fatal":false,"severity":1,"message":"File ignored by default. Use a negated ignore pattern (like \"--ignore-pattern '!<relative/path/to/filename>'\") to override."}
slackNotification,
getLocalConfigs,
pulls: { addLabels, addFiles, getChecks, getReviews },
Expand All @@ -14,7 +14,6 @@
highPriority: 'high priority',
readyForStage: 'Ready for Stage',
SOTPrefix: 'SOT',
highImpact: 'high-impact',
};
const TEAM_MENTIONS = [
'@adobecom/miq-sot',
Expand All @@ -24,8 +23,8 @@
'@adobecom/document-cloud-sot',
];
const SLACK = {
merge: ({ html_url, number, title, highImpact }) =>
`:merged:${highImpact} PR merged to stage: <${html_url}|${number}: ${title}>.`,
merge: ({ html_url, number, title }) =>
`:merged: PR merged to stage: <${html_url}|${number}: ${title}>.`,
openedSyncPr: ({ html_url, number }) =>
`:fast_forward: Created <${html_url}|Stage to Main PR ${number}>`,
};
Expand Down Expand Up @@ -124,7 +123,8 @@

const merge = async ({ prs }) => {
console.log(`Merging ${prs.length || 0} PRs that are ready... `);
for await (const { number, files, html_url, title, labels } of prs) {

for await (const { number, files, html_url, title } of prs) {
try {
if (files.some((file) => SEEN[file])) {
console.log(`Skipping ${number}: ${title} due to overlap in files.`);
Expand All @@ -140,24 +140,11 @@
});
}
body = `- ${html_url}\n${body}`;
const isHighImpact = labels.includes(LABELS.highImpact);
if (isHighImpact && process.env.SLACK_HIGH_IMPACT_PR_WEBHOOK) {
await slackNotification(
SLACK.merge({
html_url,
number,
title,
highImpact: ' :alert: High impact',
}),
process.env.SLACK_HIGH_IMPACT_PR_WEBHOOK
);
}
await slackNotification(
SLACK.merge({
html_url,
number,
title,
highImpact: isHighImpact ? ' :alert: High impact' : '',
})
);
await new Promise((resolve) => setTimeout(resolve, 5000));
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/merge-to-stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ env:

jobs:
merge-to-stage:
if: github.repository_owner == 'adobecom'
runs-on: ubuntu-latest
environment: milo_pr_merge

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pr-reminders.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:

jobs:
update:
if: github.repository_owner == 'adobecom'
runs-on: ubuntu-latest

steps:
Expand Down
14 changes: 12 additions & 2 deletions libs/blocks/global-navigation/global-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -991,10 +991,20 @@ class Gnav {
};
}

const getSource = async () => {
const { locale, dynamicNavKey } = getConfig();
let url = getMetadata('gnav-source') || `${locale.contentRoot}/gnav`;
if (dynamicNavKey) {
const { default: dynamicNav } = await import('../../features/dynamic-navigation.js');
url = dynamicNav(url, dynamicNavKey);
}
return url;
};

export default async function init(block) {
try {
const { locale, mep } = getConfig();
const url = getMetadata('gnav-source') || `${locale.contentRoot}/gnav`;
const { mep } = getConfig();
const url = await getSource();
const content = await fetchAndProcessPlainHtml({ url })
.catch((e) => lanaLog({
message: `Error fetching gnav content url: ${url}`,
Expand Down
15 changes: 15 additions & 0 deletions libs/features/dynamic-navigation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { getMetadata } from '../utils/utils.js';

export default function dynamicNav(url, key) {
const metadataContent = getMetadata('dynamic-nav');

if (metadataContent === 'entry') {
window.sessionStorage.setItem('gnavSource', url);
window.sessionStorage.setItem('dynamicNavKey', key);
return url;
}

if (metadataContent !== 'on' || key !== window.sessionStorage.getItem('dynamicNavKey')) return url;

return window.sessionStorage.getItem('gnavSource') || url;
}
1 change: 1 addition & 0 deletions libs/features/personalization/stage-entitlements.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const STAGE_ENTITLEMENTS = {
'569f0f9d-83e8-45b4-adbf-07ef08a83398': 'any-cc-product-with-stock',
'47e204a3-220a-4e53-a95e-94b6eded0d26': '3d-substance-collection',
'4ec7b469-42c9-4367-a7da-39f11a32d880': '3d-substance-texturing',
'2a93b6cc-90a2-4cff-a32d-03c71d4692e6': 'free-cc',
// PEP segments
'9202b767-77dc-4e6e-8d74-488d9ef08900': 'lightroom-web-usage',
'3a7ffcce-11b8-4242-8cdf-8c8d059ae1cd': 'photoshop-signup-source',
Expand Down
8 changes: 6 additions & 2 deletions libs/features/webapp-prompt/webapp-prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ class AppPrompt {
init = async () => {
if (this.isDismissedPrompt() || !this.parent) return;

const entMatch = await this.doesEntitlementMatch();
const skipEntitlements = new URLSearchParams(window.location.search).get('skipPepEntitlements');
const entMatch = skipEntitlements || await this.doesEntitlementMatch();
if (!entMatch) return;

const content = await this.fetchContent();
Expand Down Expand Up @@ -84,7 +85,10 @@ class AppPrompt {
};

doesEntitlementMatch = async () => {
const entitlements = await getConfig().entitlements();
const config = getConfig();
const entitlements = await config.entitlements();
const extraEnts = new URLSearchParams(window.location.search).get('mockPepEnts');
extraEnts?.split(',').forEach((ent) => entitlements.push(ent.trim()));
return entitlements?.length && entitlements.includes(this.entName);
};

Expand Down
5 changes: 4 additions & 1 deletion libs/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,9 @@ export async function decorateFooterPromo(doc = document) {
let imsLoaded;
export async function loadIms() {
imsLoaded = imsLoaded || new Promise((resolve, reject) => {
const { locale, imsClientId, imsScope, env, base } = getConfig();
const {
locale, imsClientId, imsScope, env, base, adobeid,
} = getConfig();
if (!imsClientId) {
reject(new Error('Missing IMS Client ID'));
return;
Expand All @@ -812,6 +814,7 @@ export async function loadIms() {
clearTimeout(timeout);
},
onError: reject,
...adobeid,
};
const path = PAGE_URL.searchParams.get('useAlternateImsDomain')
? 'https://auth.services.adobe.com/imslib/imslib.min.js'
Expand Down
26 changes: 26 additions & 0 deletions test/blocks/global-navigation/global-navigation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import globalNavigationMock from './mocks/global-navigation.plain.js';
import globalNavigationActiveMock from './mocks/global-navigation-active.plain.js';
import globalNavigationWideColumnMock from './mocks/global-navigation-wide-column.plain.js';
import globalNavigationCrossCloud from './mocks/global-navigation-cross-cloud.plain.js';
import { getConfig } from '../../../tools/send-to-caas/send-utils.js';

const ogFetch = window.fetch;

Expand Down Expand Up @@ -1410,5 +1411,30 @@ describe('global navigation', () => {
fetchStub.calledOnceWith('https://www.stage.adobe.com/federal/path/to/gnav.plain.html'),
).to.be.true;
});

it('fetches navigation saved in sessionStorage', async () => {
const dynamicNavOn = toFragment`<meta name="dynamic-nav" content="on">`;
const conf = getConfig();
setConfig({ dynamicNavKey: 'milo', ...conf });
document.head.append(dynamicNavOn);
window.sessionStorage.setItem('dynamicNavKey', 'milo');
window.sessionStorage.setItem('gnavSource', '/some-path');
await initGnav(document.body.querySelector('header'));
expect(
fetchStub.calledOnceWith('/some-path.plain.html'),
).to.be.true;
});

it('does not fetch from sessionStorage url when dyanmicNavKey is not present', async () => {
const dynamicNavOn = toFragment`<meta name="dynamic-nav" content="on">`;
document.head.append(dynamicNavOn);
document.body.replaceChildren(toFragment`<header class="global-navigation"></header>`);
window.sessionStorage.setItem('dynamicNavKey', 'milo');
window.sessionStorage.setItem('gnavSource', '/some-path');
await initGnav(document.body.querySelector('header'));
expect(
fetchStub.calledOnceWith('http://localhost:2000/gnav.plain.html'),
).to.be.true;
});
});
});
48 changes: 48 additions & 0 deletions test/features/dynamic-nav/dynamicNav.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { readFile } from '@web/test-runner-commands';
import { expect } from '@esm-bundle/chai';
import { setConfig } from '../../../libs/utils/utils.js';
import dynamicNav from '../../../libs/features/dynamic-navigation.js';

describe('Dynamic nav', () => {
beforeEach(() => {
const conf = { dynamicNavKey: 'bacom' };
setConfig(conf);
window.sessionStorage.setItem('gnavSource', 'some-source-string');
});

it('Saves the gnavSource and dynamicNavKey to session storage', async () => {
document.head.innerHTML = await readFile({ path: './mocks/entry.html' });
window.sessionStorage.removeItem('gnavSource');
dynamicNav('gnav/aem-sites', 'bacom');
expect(window.sessionStorage.getItem('gnavSource')).to.equal('gnav/aem-sites');
expect(window.sessionStorage.getItem('dynamicNavKey')).to.equal('bacom');
});

it('Returns the provided url when the dynamic nav metadata is not present', async () => {
document.head.innerHTML = await readFile({ path: './mocks/off.html' });
const url = dynamicNav('gnav/aem-sites', 'nocom');
expect(window.sessionStorage.getItem('gnavSource')).to.equal('some-source-string');
expect(url).to.equal('gnav/aem-sites');
});

it('Returns the provided url with when the wrong dynamicNavKey is passed', async () => {
document.head.innerHTML = await readFile({ path: './mocks/on.html' });
const url = dynamicNav('gnav/aem-sites', 'nocom');
expect(window.sessionStorage.getItem('gnavSource')).to.equal('some-source-string');
expect(url).to.equal('gnav/aem-sites');
});

it('Returns the sessionStorage url if the item exists, the keys match, and dynamic nav is on', async () => {
document.head.innerHTML = await readFile({ path: './mocks/on.html' });
const url = dynamicNav('gnav/aem-sites', 'bacom');
expect(window.sessionStorage.getItem('gnavSource')).to.equal('some-source-string');
expect(url).to.equal('some-source-string');
});

it('Returns the pprovided url if it does not find an item in sessionStorage and dynamic nav is on', async () => {
document.head.innerHTML = await readFile({ path: './mocks/on.html' });
window.sessionStorage.removeItem('gnavSource');
const url = dynamicNav('gnav/aem-sites', 'bacom');
expect(url).to.equal('gnav/aem-sites');
});
});
1 change: 1 addition & 0 deletions test/features/dynamic-nav/mocks/entry.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<meta name="dynamic-nav" content="entry">
1 change: 1 addition & 0 deletions test/features/dynamic-nav/mocks/off.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<meta name="stub" content="stub">
1 change: 1 addition & 0 deletions test/features/dynamic-nav/mocks/on.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<meta name="dynamic-nav" content="on">
Loading