Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/adobecom/nala
Browse files Browse the repository at this point in the history
  • Loading branch information
xiasun authored and xiasun committed Jan 9, 2024
2 parents 5a22211 + 7945139 commit c7936da
Show file tree
Hide file tree
Showing 18 changed files with 807 additions and 188 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/helpx.daily.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Helpx Nala Daily Run

on:
schedule:
- cron: "30 15 * * *"
workflow_dispatch:

jobs:
platform_matrix:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
name: Running tests
runs-on: ${{ matrix.os }}
env:
WORKFLOW_NAME: 'Helpx Nala Daily Run'
DAILY_RUN: 'true'

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

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: lts/*

- name: Run Nala ${{ matrix.os }}
run: bash dailyrun.sh helpx
env:
IMS_EMAIL: ${{ secrets.IMS_EMAIL }}
IMS_PASS: ${{ secrets.IMS_PASS }}
HLX_TKN: ${{ secrets.HLX_TKN }}
SLACK_WH: ${{ secrets.SLACK_WH }}

- name: Display workflow name
run: echo "The workflow name is $WORKFLOW_NAME"

- name: Persist JSON Artifact
uses: actions/upload-artifact@v3
if: always()
with:
name: nala-results
path: nala-results.json
retention-days: 30
3 changes: 1 addition & 2 deletions .github/workflows/manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ jobs:
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set permissions
run: chmod +x ./path/to/run.sh

- name: Run Nala ${{ inputs.platform }}
uses: ./
env:
Expand Down
54 changes: 54 additions & 0 deletions .github/workflows/milolib.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Run Nala on Milo Libs Manually

on:
workflow_dispatch:
inputs:
branch:
description: 'Provide the branch url'
required: false
type: string
milolibs:
description: 'Provide MiloLibs param'
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, windows-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: ./
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
7 changes: 5 additions & 2 deletions configs/helpx.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// @ts-check
const { devices } = require('@playwright/test');

const envs = require('../envs/envs.js');

/**
Expand Down Expand Up @@ -39,7 +38,7 @@ const config = {
: [
['html', { outputFolder: 'test-html-results' }],
['list'],
['./utils/reporters/base-reporter.js'],
['../utils/reporters/base-reporter.js']
],
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
Expand All @@ -59,6 +58,10 @@ const config = {
name: 'helpx-live-chrome',
use: {
...devices['Desktop Chrome'],
channel: 'chrome',
launchOptions: {
args: ['--disable-web-security', '--disable-gpu'],
},
},
},

Expand Down
20 changes: 19 additions & 1 deletion features/helpx/draft.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,26 @@ module.exports = {
{
tcid: '0',
name: '@draft',
path: '/automation/blocks/Drafts/draft-test',
path: '/automation/blocks/Draft/draft-test.html',
tags: '@draft @regression @helpx',
},
{
tcid: '1',
name: '@draftforBeforeAfter',
path: '/automation/blocks/Draft/draft-before-after.html',
tags: '@draft @regression @helpx',
},
{
tcid: '2',
name: '@draftforCodeBlock',
path: '/automation/blocks/Draft/draft-code-block.html',
tags: '@draft @regression @helpx',
},
{
tcid: '3',
name: '@draftforGeneric',
path: '/automation/blocks/Draft/draft-generic.html',
tags: '@draft @regression @helpx',
}
],
};
72 changes: 72 additions & 0 deletions features/helpx/procedure.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,78 @@ module.exports = {
path: '/automation/blocks/procedure',
tags: '@procedure @regression @helpx',
},
{
tcid: '1',
name: '@procedureComponentTitleValidation',
path: '/automation/blocks/procedure/procedure-step-component',
tags: '@procedure @regression @helpx',
},
{
tcid: '2',
name: '@procedureComponentCaseSensitive',
path: '/automation/blocks/procedure/procedure-step-component',
tags: '@procedure @regression @helpx',
},
{
tcid: '3',
name: '@procedureComponentWrongProcedureClassName',
path: '/automation/blocks/procedure/procedure-step-component',
tags: '@procedure @regression @helpx',
},
{
tcid: '4',
name: '@procedureComponentDraftFunctionality',
path: '/automation/blocks/procedure/procedure-step-component',
tags: '@procedure @regression @helpx',
},
{
tcid: '5',
name: '@procedureComponentTextProperties',
path: '/automation/blocks/procedure/procedure-step-component',
tags: '@procedure @regression @helpx',
},
{
tcid: '6',
name: '@procedureComponentVideo',
path: '/automation/blocks/procedure/procedure-step-component',
tags: '@procedure @regression @helpx',
},
{
tcid: '1',
name: '@procedureAndStepValidation',
path: '/automation/blocks/procedure/procedure-step-component',
tags: '@procedure @regression @helpx',
},
{
tcid: '7',
name: '@procedureComponentFileDownload',
path: '/automation/blocks/procedure/procedure-step-component',
tags: '@procedure @regression @helpx',
},
{
tcid: '8',
name: '@procedureComponentBeforeAfter',
path: '/automation/blocks/procedure/procedure-step-component',
tags: '@procedure @regression @helpx',
},
{
tcid: '9',
name: '@procedureComponentCodeBlock',
path: '/automation/blocks/procedure/procedure-step-component',
tags: '@procedure @regression @helpx',
},
{
tcid: '10',
name: '@procedureComponentAllComponents',
path: '/automation/blocks/procedure/procedure-step-component',
tags: '@procedure @regression @helpx',
},
{
tcid: '11',
name: '@procedureComponentImageComponent',
path: '/automation/blocks/procedure/procedure-step-component',
tags: '@procedure @regression @helpx',
}
],
};

151 changes: 151 additions & 0 deletions global.setup_1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
import { exit } from 'process';
const { execSync } = require('child_process');
const { isBranchURLValid } = require('./libs/baseurl.js');
const axios = require('axios');

const MAIN_BRANCH_LIVE_URL = 'https://main--milo--adobecom.hlx.live';
const STAGE_BRANCH_URL = 'https://milo.stage.adobe.com';
const LOCALHOST_URL = 'http://localhost:3000';

async function getGitHubPRBranchLiveUrl() {
// get the pr number
const prReference = process.env.GITHUB_REF;
const prNumber = prReference.split('/')[2];

// get the pr branch name
const branch = process.env.GITHUB_HEAD_REF;
const prBranch = branch.replace(/\//g, '-');

// get the org and repo
const repository = process.env.GITHUB_REPOSITORY;
const repoParts = repository.split('/');
const toRepoOrg = repoParts[0];
const toRepoName = repoParts[1];

// Get the org and repo from the environment variables
const prFromOrg = process.env.prOrg;
const prFromRepoName = process.env.prRepo;


let prBranchLiveUrl;

if (toRepoName === 'nala' || toRepoName === 'janus') {
prBranchLiveUrl = MAIN_BRANCH_LIVE_URL;
} else {
prBranchLiveUrl = `https://${prBranch}--${prFromRepoName}--${prFromOrg}.hlx.live`;
}

try {
if (await isBranchURLValid(prBranchLiveUrl)) {
process.env.PR_BRANCH_LIVE_URL = prBranchLiveUrl;
}
console.info('PR Repository : ', repository);
console.info('PR TO ORG : ', toRepoOrg);
console.info('PR TO REPO : ', toRepoName);
console.info('PR From ORG : ', prFromOrg);
console.info('PR From REPO : ', prFromRepoName);
console.info('PR Branch : ', branch);
console.info('PR Branch(U) : ', prBranch);
console.info('PR Number : ', prNumber);
console.info('PR From Branch live url : ', prBranchLiveUrl);
} catch (err) {
console.error(`Error => Error in setting PR Branch test URL : ${prBranchLiveUrl}`);
console.info(`Note: PR branch test url ${prBranchLiveUrl} is not valid, Exiting test execution.`);
process.exit(1);
}
}

async function getGitHubMiloLibsBranchLiveUrl() {
const repository = process.env.GITHUB_REPOSITORY;

let prBranchLiveUrl;
let miloLibs;

prBranchLiveUrl = process.env.PR_BRANCH_MILOLIBS_LIVE_URL;
miloLibs = process.env.MILO_LIBS;

try {
if (await isBranchURLValid(prBranchLiveUrl)) {
process.env.PR_BRANCH_LIVE_URL = prBranchLiveUrl;
}
console.info('PR Repository : ', repository);
console.info('PR Branch live url : ', prBranchLiveUrl);
console.info('Milo Libs : ', miloLibs);
} catch (err) {
console.error(`Error => Error in setting PR Branch test URL : ${prBranchLiveUrl}`);
console.info(`Note: PR branch test url ${prBranchLiveUrl} is not valid, Exiting test execution.`);
process.exit(1);
}
}

async function getCircleCIBranchLiveUrl() {
const stageBranchLiveUrl = STAGE_BRANCH_URL;

try {
if (await isBranchURLValid(stageBranchLiveUrl)) {
process.env.PR_BRANCH_LIVE_URL = stageBranchLiveUrl;
}
console.info('Stage Branch Live URL : ', stageBranchLiveUrl);
} catch (err) {
console.error('Error => Error in setting Stage Branch test URL : ', stageBranchLiveUrl);
console.info('Note: Stage branch test url is not valid, Exiting test execution.');
process.exit(1);
}
}

async function getLocalBranchLiveUrl() {
try {
const localGitRootDir = execSync('git rev-parse --show-toplevel', { encoding: 'utf-8' }).trim();

if (localGitRootDir) {
const gitRemoteOriginUrl = execSync('git config --get remote.origin.url', { cwd: localGitRootDir, encoding: 'utf-8' }).trim();
const match = gitRemoteOriginUrl.match(/github\.com\/(.*?)\/(.*?)\.git/);

if (match) {
const [localOrg, localRepo] = match.slice(1, 3);
const localBranch = execSync('git rev-parse --abbrev-ref HEAD', { cwd: localGitRootDir, encoding: 'utf-8' }).trim();
let localTestLiveUrl;

if (localRepo === 'nala' || localRepo === 'janus') {
localTestLiveUrl = MAIN_BRANCH_LIVE_URL;
} else {
localTestLiveUrl = LOCALHOST_URL;
}

if (await isBranchURLValid(localTestLiveUrl)) {
process.env.LOCAL_TEST_LIVE_URL = localTestLiveUrl;
}
console.info('Git ORG : ', localOrg);
console.info('Git REPO : ', localRepo);
console.info('Local Branch : ', localBranch);
console.info('Local Test Live URL : ', process.env.LOCAL_TEST_LIVE_URL);
}
}
} catch (error) {
console.error(`Error => Error in setting local test URL : ${localTestLiveUrl}`);
console.info(`Note: Local or branch test url is not valid, Exiting test execution.`);
process.exit(1);
}
}

async function globalSetup() {
console.info('----Executing Global setup---------');

if (process.env.GITHUB_ACTIONS === 'true') {
console.info('---- Running Tests in the GitHub environment ---------');

if (process.env.MILO_LIBS_RUN === 'true') {
await getGitHubMiloLibsBranchLiveUrl();
} else {
await getGitHubPRBranchLiveUrl();
}
} else if (process.env.CIRCLECI) {
console.info('---- Running Tests in the CircleCI environment ---------');
await getCircleCIBranchLiveUrl();
} else {
console.info('---- Running Tests in the Local environment ---------');
await getLocalBranchLiveUrl();
}
}

export default globalSetup;
Loading

0 comments on commit c7936da

Please sign in to comment.