Skip to content

Commit

Permalink
Merge branch 'stage' into mepplaceholdersfix
Browse files Browse the repository at this point in the history
  • Loading branch information
markpadbe committed Jun 10, 2024
2 parents 13239e9 + f5e66e0 commit 96d95a0
Show file tree
Hide file tree
Showing 35 changed files with 299 additions and 157 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/code-compatibility.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Check for unsupported functions
run: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
config-file: ./.github/codeql/codeql-config.yml

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand All @@ -59,6 +59,6 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
6 changes: 3 additions & 3 deletions .github/workflows/dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: changes
with:
base: ${{ github.ref }}
Expand All @@ -23,7 +23,7 @@ jobs:
- 'libs/**'
- if: steps.changes.outputs.src == 'true'
name: Trigger DC Workflow
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
github-token: ${{ secrets.DC_PAT }}
script: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fg-sync-repos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
repositories: "milo-pink"

- name: Checkout Repo
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
persist-credentials: false
ref: ${{ inputs.syncBranch }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/high-impact-alert.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4.1.4
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.ref }}

- name: Send Slack message for high impact PRs
uses: actions/github-script@v7.0.1
uses: actions/github-script@v7
with:
script: |
const main = require('./.github/workflows/high-impact-alert.js')
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/label-zero-impact.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v4.1.4
uses: actions/checkout@v4

- name: Add the zero impact label
uses: actions/github-script@v7.0.1
uses: actions/github-script@v7
with:
script: |
const main = require('./.github/workflows/label-zero-impact.js')
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/merge-to-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ jobs:
if: github.repository_owner == 'adobecom' && (github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || (github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main' && github.event.pull_request.head.ref == 'stage'))

steps:
- uses: actions/create-github-app-token@v1.10.0
- uses: actions/create-github-app-token@v1
id: milo-pr-merge-token
with:
app-id: ${{ secrets.MILO_PR_MERGE_APP_ID }}
private-key: ${{ secrets.MILO_PR_MERGE_PRIVATE_KEY }}

- name: Checkout repository
uses: actions/checkout@v4.1.4
uses: actions/checkout@v4

- name: Merge to main
uses: actions/github-script@v7.0.1
uses: actions/github-script@v7
with:
github-token: ${{ steps.milo-pr-merge-token.outputs.token }}
script: |
Expand Down
40 changes: 30 additions & 10 deletions .github/workflows/merge-to-stage.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const LABELS = {
highPriority: 'high priority',
readyForStage: 'Ready for Stage',
SOTPrefix: 'SOT',
zeroImpact: 'zero-impact',
};
const TEAM_MENTIONS = [
'@adobecom/miq-sot',
Expand All @@ -24,8 +25,8 @@ const TEAM_MENTIONS = [
'@adobecom/document-cloud-sot',
];
const SLACK = {
merge: ({ html_url, number, title }) =>
`:merged: PR merged to stage: <${html_url}|${number}: ${title}>.`,
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}>`,
};
Expand All @@ -46,6 +47,7 @@ let body = `
`;

const isHighPrio = (labels) => labels.includes(LABELS.highPriority);
const isZeroImpact = (labels) => labels.includes(LABELS.zeroImpact);

const hasFailingChecks = (checks) =>
checks.some(
Expand Down Expand Up @@ -80,19 +82,34 @@ const getPRs = async () => {
return true;
});

return prs.reverse(); // OLD PRs first
return prs.reverse().reduce(
(categorizedPRs, pr) => {
if (isZeroImpact(pr.labels)) {
categorizedPRs.zeroImpactPRs.push(pr);
} else if (isHighPrio(pr.labels)) {
categorizedPRs.highImpactPRs.push(pr);
} else {
categorizedPRs.normalPRs.push(pr);
}
return categorizedPRs;
},
{ zeroImpactPRs: [], highImpactPRs: [], normalPRs: [] }
);
};

const merge = async ({ prs }) => {
console.log(`Merging ${prs.length || 0} PRs that are ready... `);
const merge = async ({ prs, type }) => {
console.log(`Merging ${prs.length || 0} ${type} PRs that are ready... `);

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.`);
continue;
}
files.forEach((file) => (SEEN[file] = true));
if (type !== LABELS.zeroImpact) {
files.forEach((file) => (SEEN[file] = true));
}

if (!process.env.LOCAL_RUN) {
await github.rest.pulls.merge({
owner,
Expand All @@ -101,12 +118,14 @@ const merge = async ({ prs }) => {
merge_method: 'squash',
});
}
body = `- ${html_url}\n${body}`;
const prefix = type === LABELS.zeroImpact ? ' [ZERO IMPACT]' : '';
body = `-${prefix} ${html_url}\n${body}`;
await slackNotification(
SLACK.merge({
html_url,
number,
title,
prefix,
})
);
await new Promise((resolve) => setTimeout(resolve, 5000));
Expand Down Expand Up @@ -185,11 +204,12 @@ const main = async (params) => {
const stageToMainPR = await getStageToMainPR();
console.log('has Stage to Main PR:', !!stageToMainPR);
if (stageToMainPR) body = stageToMainPR.body;
const { zeroImpactPRs, highImpactPRs, normalPRs } = await getPRs();
await merge({ prs: zeroImpactPRs, type: LABELS.zeroImpact });
if (stageToMainPR?.labels.some((label) => label.includes(LABELS.SOTPrefix)))
return console.log('PR exists & testing started. Stopping execution.');
const prs = await getPRs();
await merge({ prs: prs.filter(({ labels }) => isHighPrio(labels)) });
await merge({ prs: prs.filter(({ labels }) => !isHighPrio(labels)) });
await merge({ prs: highImpactPRs, type: LABELS.highPriority });
await merge({ prs: normalPRs, type: 'normal' });
if (!stageToMainPR) await openStageToMainPR();
if (stageToMainPR && body !== stageToMainPR.body) {
console.log("Updating PR's body...");
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/merge-to-stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ jobs:
environment: milo_pr_merge

steps:
- uses: actions/create-github-app-token@v1.10.0
- uses: actions/create-github-app-token@v1
id: milo-pr-merge-token
with:
app-id: ${{ secrets.MILO_PR_MERGE_APP_ID }}
private-key: ${{ secrets.MILO_PR_MERGE_PRIVATE_KEY }}

- name: Checkout repository
uses: actions/checkout@v4.1.4
uses: actions/checkout@v4

- name: Merge to stage or queue to merge
uses: actions/github-script@v7.0.1
uses: actions/github-script@v7
with:
github-token: ${{ steps.milo-pr-merge-token.outputs.token }}
script: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr-reminders.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v4.1.1
uses: actions/checkout@v4

- name: Remind PR initiators
uses: actions/github-script@v7.0.1
uses: actions/github-script@v7
with:
script: |
const main = require('./.github/workflows/pr-reminders.js')
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/run-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ jobs:
name: Running eslint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: actions/setup-node@v2
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20

- name: Install dependencies
run: npm ci
Expand Down
108 changes: 54 additions & 54 deletions .github/workflows/run-nala-milolibs.yaml
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
name: Run Nala on Milo Libs

on:
workflow_dispatch:
inputs:
branch:
description: 'Provide the live branch url. ex: https://main--cc--adobecom.hlx.live'
required: false
type: string
milolibs:
description: 'Provide MiloLibs param. ex: ?milolibs=marquee-static-hover'
required: false
type: string
tags:
description: 'Test scenario tags, if empty all tests will run. i.e., @marquee'
required: false
type: string
platform:
description: 'Platform to run tests on; select one, options: [ubuntu-latest, macos-latest]'
required: true
type: string

jobs:
action:
name: Running tests
runs-on: ${{ inputs.platform }}
env:
WORKFLOW_NAME: 'Milo Libs Run'
MILO_LIBS_RUN: 'true'

steps:
- name: Check out repository
uses: actions/checkout@v3

- name: Set environment variables
run: |
echo "PR_BRANCH_MILOLIBS_LIVE_URL=${{ github.event.inputs.branch }}" >> $GITHUB_ENV
echo "MILO_LIBS=${{ github.event.inputs.milolibs }}" >> $GITHUB_ENV
- name: Run Nala ${{ inputs.platform }}
uses: adobecom/nala@main
env:
labels: ${{ inputs.tags }}
IMS_EMAIL: ${{ secrets.IMS_EMAIL }}
IMS_PASS: ${{ secrets.IMS_PASS }}
HLX_TKN: ${{ secrets.HLX_TKN }}
SLACK_WH: ${{ secrets.SLACK_WH }}
- name: Persist JSON Artifact
uses: actions/upload-artifact@v3
if: always()
with:
name: nala-results
path: nala-results.json
retention-days: 30
name: Run Nala on Milo Libs

on:
workflow_dispatch:
inputs:
branch:
description: 'Provide the live branch url. ex: https://main--cc--adobecom.hlx.live'
required: false
type: string
milolibs:
description: 'Provide MiloLibs param. ex: ?milolibs=marquee-static-hover'
required: false
type: string
tags:
description: 'Test scenario tags, if empty all tests will run. i.e., @marquee'
required: false
type: string
platform:
description: 'Platform to run tests on; select one, options: [ubuntu-latest, macos-latest]'
required: true
type: string

jobs:
action:
name: Running tests
runs-on: ${{ inputs.platform }}
env:
WORKFLOW_NAME: 'Milo Libs Run'
MILO_LIBS_RUN: 'true'

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set environment variables
run: |
echo "PR_BRANCH_MILOLIBS_LIVE_URL=${{ github.event.inputs.branch }}" >> $GITHUB_ENV
echo "MILO_LIBS=${{ github.event.inputs.milolibs }}" >> $GITHUB_ENV
- name: Run Nala ${{ inputs.platform }}
uses: adobecom/nala@main
env:
labels: ${{ inputs.tags }}
IMS_EMAIL: ${{ secrets.IMS_EMAIL }}
IMS_PASS: ${{ secrets.IMS_PASS }}
HLX_TKN: ${{ secrets.HLX_TKN }}
SLACK_WH: ${{ secrets.SLACK_WH }}
- name: Persist JSON Artifact
uses: actions/upload-artifact@v3
if: always()
with:
name: nala-results
path: nala-results.json
retention-days: 30
2 changes: 1 addition & 1 deletion .github/workflows/run-nala.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

steps:
- name: Check out repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Run Nala
uses: adobecom/nala@main # Change if doing dev work
env:
Expand Down
Loading

0 comments on commit 96d95a0

Please sign in to comment.