From 0c9b24b69c7fba74d922ce2616467111e508c397 Mon Sep 17 00:00:00 2001 From: Raluca Pelin Date: Thu, 8 Sep 2022 13:28:05 +0300 Subject: [PATCH 01/18] Fix artifact downloading workflow name --- .github/workflows/screener-run.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/screener-run.yml b/.github/workflows/screener-run.yml index 0b77f8724320ac..6ddd0a26c50bef 100644 --- a/.github/workflows/screener-run.yml +++ b/.github/workflows/screener-run.yml @@ -12,10 +12,10 @@ jobs: determine-if-skipping: runs-on: 'ubuntu-latest' steps: - - name: Download environment variables artifact + - name: Download artifact to determine if skipping jobs uses: dawidd6/action-download-artifact@v2 with: - workflow: learn-github-actions.yml + workflow: screener-build.yml run_id: ${{github.event.workflow_run.id}} name: skip-screener From 1628221c4aa5928b2b6d1e3b95f10a50df59ce57 Mon Sep 17 00:00:00 2001 From: Raluca Pelin Date: Thu, 8 Sep 2022 13:41:51 +0300 Subject: [PATCH 02/18] Test screener tests scoping for draft PRs --- .github/workflows/screener-run.yml | 4 ++-- packages/fluentui/react-northstar/src/index.ts | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/screener-run.yml b/.github/workflows/screener-run.yml index 6ddd0a26c50bef..0b77f8724320ac 100644 --- a/.github/workflows/screener-run.yml +++ b/.github/workflows/screener-run.yml @@ -12,10 +12,10 @@ jobs: determine-if-skipping: runs-on: 'ubuntu-latest' steps: - - name: Download artifact to determine if skipping jobs + - name: Download environment variables artifact uses: dawidd6/action-download-artifact@v2 with: - workflow: screener-build.yml + workflow: learn-github-actions.yml run_id: ${{github.event.workflow_run.id}} name: skip-screener diff --git a/packages/fluentui/react-northstar/src/index.ts b/packages/fluentui/react-northstar/src/index.ts index d635199fdb0b96..e8a3049a71069a 100644 --- a/packages/fluentui/react-northstar/src/index.ts +++ b/packages/fluentui/react-northstar/src/index.ts @@ -287,3 +287,4 @@ export const FocusZoneUtilities = { getPreviousElement, focusAsync, }; +//comment From 5a601996524c2cf1019d6f142a97247089503d73 Mon Sep 17 00:00:00 2001 From: Raluca Pelin Date: Fri, 9 Sep 2022 13:06:27 +0300 Subject: [PATCH 03/18] Remove unnecessary environment variables --- .github/workflows/screener-build.yml | 15 +++++---------- .github/workflows/screener-run.yml | 1 + apps/vr-tests-react-components/screener.config.js | 4 +--- apps/vr-tests/screener.config.js | 4 +--- scripts/config.ts | 8 +++++--- scripts/screener/screener.config.js | 3 +-- scripts/screener/screener.runner.ts | 4 ++-- 7 files changed, 16 insertions(+), 23 deletions(-) diff --git a/.github/workflows/screener-build.yml b/.github/workflows/screener-build.yml index f16fc66d2ee2e6..534e1f3829c493 100644 --- a/.github/workflows/screener-build.yml +++ b/.github/workflows/screener-build.yml @@ -9,6 +9,8 @@ on: env: DEPLOYHOST: 'fluentuipr.z22.web.core.windows.net' + SCREENER_BUILD: 1 + BROWSERSLIST_IGNORE_OLD_DATA: true jobs: environment-upload: @@ -25,11 +27,7 @@ jobs: - name: Set base env variables run: | cat <> artifacts/environment - BROWSERSLIST_IGNORE_OLD_DATA=true - DEPLOYHOST='fluentuipr.z22.web.core.windows.net' BUILD_BUILDID=${{ github.run_id }} - BUILD_SOURCEBRANCH=${{ github.ref }} - SCREENER_BUILD=1 EOT - name: Set env variables if there is not a PR @@ -66,23 +64,20 @@ jobs: ########################################### # SYSTEM_PULLREQUEST_TARGETBRANCH = target branch name - # SYSTEM_PULLREQUEST_SOURCEBRANCH = source branch name # SYSTEM_PULLREQUEST_PULLREQUESTID = ID of the PR # SYSTEM_PULLREQUEST_SOURCECOMMITID = commit SHA of PR - # DEPLOYBASEPATH = path for deploy URL -> pull/ for PRs - # DEPLOYURL= address for tests deployment, uses DEPLOYHOST and DEPLOYBASEPATH - # BUILD_SOURCEBRANCHNAME = 'merge' for PRs + # DEPLOYURL= address for tests deployment + # BUILD_SOURCEBRANCHNAME = source branch name ########################################### - name: Set env variables if there is a PR run: | cat <> artifacts/environment SYSTEM_PULLREQUEST_TARGETBRANCH=${{ github.event.pull_request.base.ref }} - SYSTEM_PULLREQUEST_SOURCEBRANCH=${{ github.event.pull_request.head.ref }} SYSTEM_PULLREQUEST_PULLREQUESTID=${{ github.event.pull_request.id }} SYSTEM_PULLREQUEST_SOURCECOMMITID=${{ github.event.pull_request.head.sha }} DEPLOYBASEPATH=pull/${{github.event.pull_request.number}} DEPLOYURL=https://${{env.DEPLOYHOST}}/pull/${{github.event.pull_request.number}} - BUILD_SOURCEBRANCHNAME='merge' + BUILD_SOURCEBRANCHNAME=${{ github.event.pull_request.head.ref }} EOT if: ${{ github.event_name == 'pull_request' && env.SKIP_SCREENER == ''}} diff --git a/.github/workflows/screener-run.yml b/.github/workflows/screener-run.yml index 6ddd0a26c50bef..75ea74e7a06243 100644 --- a/.github/workflows/screener-run.yml +++ b/.github/workflows/screener-run.yml @@ -8,6 +8,7 @@ on: env: AZURE_STORAGE_CONNECTION_STRING: ${{secrets.AZURE_STORAGE_CONNECTION_STRING}} + BROWSERSLIST_IGNORE_OLD_DATA: true jobs: determine-if-skipping: runs-on: 'ubuntu-latest' diff --git a/apps/vr-tests-react-components/screener.config.js b/apps/vr-tests-react-components/screener.config.js index caa843a8fbb11f..b658896625d536 100644 --- a/apps/vr-tests-react-components/screener.config.js +++ b/apps/vr-tests-react-components/screener.config.js @@ -32,9 +32,7 @@ const config = { baseBranch, failureExitCode: 0, alwaysAcceptBaseBranch: true, - ...(process.env.BUILD_SOURCEBRANCH && process.env.BUILD_SOURCEBRANCH.indexOf('refs/pull') > -1 - ? { commit: getCurrentHash() } - : null), + ...(process.env.BUILD_SOURCEBRANCHNAME !== 'master' ? { commit: getCurrentHash() } : null), baseUrl: `${process.env.DEPLOYURL}/react-components-screener/iframe.html`, }; console.log('Screener config: ' + JSON.stringify({ ...config, apiKey: '...' }, null, 2)); diff --git a/apps/vr-tests/screener.config.js b/apps/vr-tests/screener.config.js index 3002918395bf26..f20b74be20796c 100644 --- a/apps/vr-tests/screener.config.js +++ b/apps/vr-tests/screener.config.js @@ -34,9 +34,7 @@ const config = { baseBranch, failureExitCode: 0, alwaysAcceptBaseBranch: true, - ...(process.env.BUILD_SOURCEBRANCH && process.env.BUILD_SOURCEBRANCH.indexOf('refs/pull') > -1 - ? { commit: getCurrentHash() } - : null), + ...(process.env.BUILD_SOURCEBRANCHNAME !== 'master' ? { commit: getCurrentHash() } : null), baseUrl: `${process.env.DEPLOYURL}/react-screener/iframe.html`, }; console.log('Screener config: ' + JSON.stringify({ ...config, apiKey: '...' }, null, 2)); diff --git a/scripts/config.ts b/scripts/config.ts index c91205abfce2fc..89a8795a1aef01 100644 --- a/scripts/config.ts +++ b/scripts/config.ts @@ -9,14 +9,16 @@ const env = process.env.NODE_ENV || 'development'; const __DEV__ = env === 'development'; const __PERF__ = !!process.env.PERF; const __PROD__ = env === 'production'; -let __BASENAME__ = process.env.DEPLOYBASEPATH +const deployURL = new URL(process.env.DEPLOYURL); +const deployBasePath = deployURL.pathname; +let __BASENAME__ = deployBasePath ? // This needs a trailing slash or images won't work. // The path is different for standard PR deploy and screener deploy. - `/${process.env.DEPLOYBASEPATH}/${process.env.SCREENER_BUILD ? 'react-northstar-screener' : 'react-northstar'}/` + `/${deployBasePath}/${process.env.SCREENER_BUILD ? 'react-northstar-screener' : 'react-northstar'}/` : '/'; if (process.env.OFFICIALRELEASE) { - __BASENAME__ = `/${process.env.DEPLOYBASEPATH}/`; + __BASENAME__ = `/${deployBasePath}/`; } const __SKIP_ERRORS__ = !!process.env.SKIP_ERRORS; diff --git a/scripts/screener/screener.config.js b/scripts/screener/screener.config.js index cf6f5d30dd3b0a..0022005595f70d 100644 --- a/scripts/screener/screener.config.js +++ b/scripts/screener/screener.config.js @@ -30,7 +30,6 @@ require('tsconfig-paths').register({ }); const baseBranch = 'master'; -const sourceBranch = process.env.BUILD_SOURCEBRANCH; // https://github.com/screener-io/screener-runner module.exports = { @@ -55,7 +54,7 @@ module.exports = { baseBranch, failureExitCode: 0, - ...(sourceBranch && sourceBranch.indexOf('refs/pull') > -1 + ...(process.env.BUILD_SOURCEBRANCHNAME !== 'master' ? { commit: getCurrentHash(), } diff --git a/scripts/screener/screener.runner.ts b/scripts/screener/screener.runner.ts index 1196282f4cedfd..dc91df75a9b436 100644 --- a/scripts/screener/screener.runner.ts +++ b/scripts/screener/screener.runner.ts @@ -76,10 +76,10 @@ export async function screenerRunner(screenerConfig: ScreenerRunnerConfig) { // https://github.com/microsoft/azure-pipelines-tasks/issues/9801 const commit = process.env.SYSTEM_PULLREQUEST_SOURCECOMMITID; // https://github.com/screener-io/screener-runner/blob/2a8291fb1b0219c96c8428ea6644678b0763a1a1/src/ci.js#L101 - let branchName = process.env.SYSTEM_PULLREQUEST_SOURCEBRANCH || process.env.BUILD_SOURCEBRANCHNAME; + let branchName = process.env.BUILD_SOURCEBRANCHNAME; if (!branchName) { - throw new Error('SYSTEM_PULLREQUEST_SOURCEBRANCH or BUILD_SOURCEBRANCHNAME env variable doesnt exist'); + throw new Error('BUILD_SOURCEBRANCHNAME env variable doesnt exist'); } if (!process.env.BUILD_BUILDID) { throw new Error('BUILD_BUILDID env variable doesnt exist'); From 17f5b5d7b185d70f275fe39a9375983471d40924 Mon Sep 17 00:00:00 2001 From: Raluca Pelin Date: Fri, 9 Sep 2022 13:10:29 +0300 Subject: [PATCH 04/18] Remove comment --- packages/fluentui/react-northstar/src/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/fluentui/react-northstar/src/index.ts b/packages/fluentui/react-northstar/src/index.ts index e8a3049a71069a..d635199fdb0b96 100644 --- a/packages/fluentui/react-northstar/src/index.ts +++ b/packages/fluentui/react-northstar/src/index.ts @@ -287,4 +287,3 @@ export const FocusZoneUtilities = { getPreviousElement, focusAsync, }; -//comment From d72bd91fe86b855154f8d07bd14abff4f6c56c80 Mon Sep 17 00:00:00 2001 From: Raluca Pelin Date: Fri, 9 Sep 2022 13:47:43 +0300 Subject: [PATCH 05/18] Import URL --- scripts/config.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/config.ts b/scripts/config.ts index 89a8795a1aef01..a526e5a6d02a67 100644 --- a/scripts/config.ts +++ b/scripts/config.ts @@ -1,6 +1,7 @@ import * as path from 'path'; import * as _ from 'lodash'; import * as webpack from 'webpack'; +import { URL } from 'url'; // ------------------------------------ // Environment vars From de1120b728d847b91692f782cf57c3587c93affb Mon Sep 17 00:00:00 2001 From: Raluca Pelin Date: Fri, 9 Sep 2022 14:02:25 +0300 Subject: [PATCH 06/18] Fix deployBasePath parsing --- scripts/config.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/config.ts b/scripts/config.ts index a526e5a6d02a67..3abb5e3fb4e775 100644 --- a/scripts/config.ts +++ b/scripts/config.ts @@ -10,8 +10,8 @@ const env = process.env.NODE_ENV || 'development'; const __DEV__ = env === 'development'; const __PERF__ = !!process.env.PERF; const __PROD__ = env === 'production'; -const deployURL = new URL(process.env.DEPLOYURL); -const deployBasePath = deployURL.pathname; +const deployURL = process.env.DEPLOYURL ? new URL(process.env.DEPLOYURL) : undefined; +const deployBasePath = deployURL ? deployURL.pathname : undefined; let __BASENAME__ = deployBasePath ? // This needs a trailing slash or images won't work. // The path is different for standard PR deploy and screener deploy. From 47ba1487a8b65607f5dc514aceefff1f5a15b861 Mon Sep 17 00:00:00 2001 From: Raluca Pelin Date: Fri, 9 Sep 2022 14:37:43 +0300 Subject: [PATCH 07/18] Send env variable to screener run workflow --- .github/workflows/screener-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/screener-build.yml b/.github/workflows/screener-build.yml index 534e1f3829c493..30326c1174bea7 100644 --- a/.github/workflows/screener-build.yml +++ b/.github/workflows/screener-build.yml @@ -9,7 +9,6 @@ on: env: DEPLOYHOST: 'fluentuipr.z22.web.core.windows.net' - SCREENER_BUILD: 1 BROWSERSLIST_IGNORE_OLD_DATA: true jobs: @@ -28,6 +27,7 @@ jobs: run: | cat <> artifacts/environment BUILD_BUILDID=${{ github.run_id }} + SCREENER_BUILD=1 EOT - name: Set env variables if there is not a PR From 6341b5cab4e162ecfd4a20db97135e98df3296bd Mon Sep 17 00:00:00 2001 From: Raluca Pelin Date: Fri, 9 Sep 2022 15:13:30 +0300 Subject: [PATCH 08/18] Add env variable to artifact --- .github/workflows/screener-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/screener-build.yml b/.github/workflows/screener-build.yml index 30326c1174bea7..491a60a931c929 100644 --- a/.github/workflows/screener-build.yml +++ b/.github/workflows/screener-build.yml @@ -9,7 +9,6 @@ on: env: DEPLOYHOST: 'fluentuipr.z22.web.core.windows.net' - BROWSERSLIST_IGNORE_OLD_DATA: true jobs: environment-upload: @@ -26,6 +25,7 @@ jobs: - name: Set base env variables run: | cat <> artifacts/environment + BROWSERSLIST_IGNORE_OLD_DATA: true BUILD_BUILDID=${{ github.run_id }} SCREENER_BUILD=1 EOT From 373af76e266dd7a194b441b9cd1b98420f6bfa07 Mon Sep 17 00:00:00 2001 From: Raluca Pelin Date: Fri, 9 Sep 2022 15:18:23 +0300 Subject: [PATCH 09/18] Fix typo --- .github/workflows/screener-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/screener-build.yml b/.github/workflows/screener-build.yml index 491a60a931c929..bc49414006704a 100644 --- a/.github/workflows/screener-build.yml +++ b/.github/workflows/screener-build.yml @@ -25,7 +25,7 @@ jobs: - name: Set base env variables run: | cat <> artifacts/environment - BROWSERSLIST_IGNORE_OLD_DATA: true + BROWSERSLIST_IGNORE_OLD_DATA=true BUILD_BUILDID=${{ github.run_id }} SCREENER_BUILD=1 EOT From 79f8c517c40d85f23b2a9f488e19e3307f9f3976 Mon Sep 17 00:00:00 2001 From: Raluca Pelin Date: Fri, 9 Sep 2022 15:54:37 +0300 Subject: [PATCH 10/18] Revert part of changes for debugging purposes --- .github/workflows/screener-build.yml | 8 ++++++-- scripts/config.ts | 9 +++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/screener-build.yml b/.github/workflows/screener-build.yml index bc49414006704a..2c7c50d536bda7 100644 --- a/.github/workflows/screener-build.yml +++ b/.github/workflows/screener-build.yml @@ -26,7 +26,9 @@ jobs: run: | cat <> artifacts/environment BROWSERSLIST_IGNORE_OLD_DATA=true + DEPLOYHOST='fluentuipr.z22.web.core.windows.net' BUILD_BUILDID=${{ github.run_id }} + BUILD_SOURCEBRANCH=${{ github.ref }} SCREENER_BUILD=1 EOT @@ -64,10 +66,12 @@ jobs: ########################################### # SYSTEM_PULLREQUEST_TARGETBRANCH = target branch name + # SYSTEM_PULLREQUEST_SOURCEBRANCH = source branch name # SYSTEM_PULLREQUEST_PULLREQUESTID = ID of the PR # SYSTEM_PULLREQUEST_SOURCECOMMITID = commit SHA of PR - # DEPLOYURL= address for tests deployment - # BUILD_SOURCEBRANCHNAME = source branch name + # DEPLOYBASEPATH = path for deploy URL -> pull/ for PRs + # DEPLOYURL= address for tests deployment, uses DEPLOYHOST and DEPLOYBASEPATH + # BUILD_SOURCEBRANCHNAME = 'merge' for PRs ########################################### - name: Set env variables if there is a PR run: | diff --git a/scripts/config.ts b/scripts/config.ts index 3abb5e3fb4e775..c91205abfce2fc 100644 --- a/scripts/config.ts +++ b/scripts/config.ts @@ -1,7 +1,6 @@ import * as path from 'path'; import * as _ from 'lodash'; import * as webpack from 'webpack'; -import { URL } from 'url'; // ------------------------------------ // Environment vars @@ -10,16 +9,14 @@ const env = process.env.NODE_ENV || 'development'; const __DEV__ = env === 'development'; const __PERF__ = !!process.env.PERF; const __PROD__ = env === 'production'; -const deployURL = process.env.DEPLOYURL ? new URL(process.env.DEPLOYURL) : undefined; -const deployBasePath = deployURL ? deployURL.pathname : undefined; -let __BASENAME__ = deployBasePath +let __BASENAME__ = process.env.DEPLOYBASEPATH ? // This needs a trailing slash or images won't work. // The path is different for standard PR deploy and screener deploy. - `/${deployBasePath}/${process.env.SCREENER_BUILD ? 'react-northstar-screener' : 'react-northstar'}/` + `/${process.env.DEPLOYBASEPATH}/${process.env.SCREENER_BUILD ? 'react-northstar-screener' : 'react-northstar'}/` : '/'; if (process.env.OFFICIALRELEASE) { - __BASENAME__ = `/${deployBasePath}/`; + __BASENAME__ = `/${process.env.DEPLOYBASEPATH}/`; } const __SKIP_ERRORS__ = !!process.env.SKIP_ERRORS; From b16735c3d04e54957f5f5278746ac3adefd5c482 Mon Sep 17 00:00:00 2001 From: Raluca Pelin Date: Fri, 9 Sep 2022 16:17:22 +0300 Subject: [PATCH 11/18] Remove BUILD_SOURCEBRANCH env variable --- .github/workflows/screener-build.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/screener-build.yml b/.github/workflows/screener-build.yml index 2c7c50d536bda7..b9f2b3c30bfa3f 100644 --- a/.github/workflows/screener-build.yml +++ b/.github/workflows/screener-build.yml @@ -20,7 +20,6 @@ jobs: # BROWSERSLIST_IGNORE_OLD_DATA = Prevents failures on CI when "caniuse-lite" becomes outdated # DEPLOYHOST = address of host for screener tests deployment # BUILD_BUILDID = unique ID of the workflow run within the repo - # BUILD_SOURCEBRANCH = branch that triggered the workflow -> refs/pull//merge ########################################### - name: Set base env variables run: | @@ -28,7 +27,6 @@ jobs: BROWSERSLIST_IGNORE_OLD_DATA=true DEPLOYHOST='fluentuipr.z22.web.core.windows.net' BUILD_BUILDID=${{ github.run_id }} - BUILD_SOURCEBRANCH=${{ github.ref }} SCREENER_BUILD=1 EOT From 5136357ad033daac972f5e0a1692d1f709f3b210 Mon Sep 17 00:00:00 2001 From: Raluca Pelin Date: Fri, 9 Sep 2022 16:35:15 +0300 Subject: [PATCH 12/18] Remove DEPLOYHOST env variable from artifact --- .github/workflows/screener-build.yml | 1 - .github/workflows/screener-run.yml | 1 - 2 files changed, 2 deletions(-) diff --git a/.github/workflows/screener-build.yml b/.github/workflows/screener-build.yml index b9f2b3c30bfa3f..f4ddf2e6633f10 100644 --- a/.github/workflows/screener-build.yml +++ b/.github/workflows/screener-build.yml @@ -25,7 +25,6 @@ jobs: run: | cat <> artifacts/environment BROWSERSLIST_IGNORE_OLD_DATA=true - DEPLOYHOST='fluentuipr.z22.web.core.windows.net' BUILD_BUILDID=${{ github.run_id }} SCREENER_BUILD=1 EOT diff --git a/.github/workflows/screener-run.yml b/.github/workflows/screener-run.yml index 75ea74e7a06243..6ddd0a26c50bef 100644 --- a/.github/workflows/screener-run.yml +++ b/.github/workflows/screener-run.yml @@ -8,7 +8,6 @@ on: env: AZURE_STORAGE_CONNECTION_STRING: ${{secrets.AZURE_STORAGE_CONNECTION_STRING}} - BROWSERSLIST_IGNORE_OLD_DATA: true jobs: determine-if-skipping: runs-on: 'ubuntu-latest' From f76f5e6d3ad82492d41ec5a0a2f626ed505c52c7 Mon Sep 17 00:00:00 2001 From: Raluca Pelin Date: Fri, 9 Sep 2022 17:03:48 +0300 Subject: [PATCH 13/18] Use DEPLOYURL env var in screener code --- scripts/config.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/config.ts b/scripts/config.ts index c91205abfce2fc..41a044c5657907 100644 --- a/scripts/config.ts +++ b/scripts/config.ts @@ -1,6 +1,7 @@ import * as path from 'path'; import * as _ from 'lodash'; import * as webpack from 'webpack'; +import { URL } from 'url'; // ------------------------------------ // Environment vars @@ -9,14 +10,16 @@ const env = process.env.NODE_ENV || 'development'; const __DEV__ = env === 'development'; const __PERF__ = !!process.env.PERF; const __PROD__ = env === 'production'; -let __BASENAME__ = process.env.DEPLOYBASEPATH +const deployUrl = process.env.DEPLOYURL ? new URL(process.env.DEPLOYURL) : undefined; +const deployBasePath = deployUrl ? deployUrl.pathname : undefined; +let __BASENAME__ = deployBasePath ? // This needs a trailing slash or images won't work. // The path is different for standard PR deploy and screener deploy. - `/${process.env.DEPLOYBASEPATH}/${process.env.SCREENER_BUILD ? 'react-northstar-screener' : 'react-northstar'}/` + `${deployBasePath}/${process.env.SCREENER_BUILD ? 'react-northstar-screener' : 'react-northstar'}/` : '/'; if (process.env.OFFICIALRELEASE) { - __BASENAME__ = `/${process.env.DEPLOYBASEPATH}/`; + __BASENAME__ = `/${deployBasePath}/`; } const __SKIP_ERRORS__ = !!process.env.SKIP_ERRORS; From e7a40569f08a91df2eb39885dce1189fe25d0d8d Mon Sep 17 00:00:00 2001 From: Raluca Pelin Date: Fri, 9 Sep 2022 17:39:00 +0300 Subject: [PATCH 14/18] Refactor N* screener config file --- scripts/gulp/tasks/screener.ts | 3 +- scripts/screener/screener.config.js | 60 +++++++++++++++-------------- 2 files changed, 33 insertions(+), 30 deletions(-) diff --git a/scripts/gulp/tasks/screener.ts b/scripts/gulp/tasks/screener.ts index cad16621b101c2..a598f9f13d90d6 100644 --- a/scripts/gulp/tasks/screener.ts +++ b/scripts/gulp/tasks/screener.ts @@ -36,7 +36,8 @@ task('screener:runner', cb => { process.exit(1); }); - const screenerConfig = require(screenerConfigPath); + const getConfig = require(screenerConfigPath); + const screenerConfig = getConfig(process.env.SCREENER_API_KEY, process.env.BUILD_SOURCEBRANCHNAME); handlePromiseExit(screenerRunner(screenerConfig)); }); diff --git a/scripts/screener/screener.config.js b/scripts/screener/screener.config.js index 0022005595f70d..682e985bdf4808 100644 --- a/scripts/screener/screener.config.js +++ b/scripts/screener/screener.config.js @@ -30,33 +30,35 @@ require('tsconfig-paths').register({ }); const baseBranch = 'master'; +function getConfig(SCREENER_API_KEY, BUILD_SOURCEBRANCHNAME) { + // https://github.com/screener-io/screener-runner + return { + apiKey: SCREENER_API_KEY, + projectRepo: 'microsoft/fluentui/fluentui', -// https://github.com/screener-io/screener-runner -module.exports = { - apiKey: process.env.SCREENER_API_KEY, - projectRepo: 'microsoft/fluentui/fluentui', - - diffOptions: { - structure: true, - layout: true, - style: true, - content: true, - minLayoutPosition: 1, // Optional threshold for Layout changes. Defaults to 4 pixels. - minLayoutDimension: 1, // Optional threshold for Layout changes. Defaults to 10 pixels. - minShiftGraphic: 1, // Optional threshold for pixel shifts in graphics. - compareSVGDOM: false, // Pass if SVG DOM is the same. Defaults to false. - }, - - // screenshot every example in maximized mode - states: require('./screener.states').default, - - alwaysAcceptBaseBranch: true, - baseBranch, - failureExitCode: 0, - - ...(process.env.BUILD_SOURCEBRANCHNAME !== 'master' - ? { - commit: getCurrentHash(), - } - : null), -}; + diffOptions: { + structure: true, + layout: true, + style: true, + content: true, + minLayoutPosition: 1, // Optional threshold for Layout changes. Defaults to 4 pixels. + minLayoutDimension: 1, // Optional threshold for Layout changes. Defaults to 10 pixels. + minShiftGraphic: 1, // Optional threshold for pixel shifts in graphics. + compareSVGDOM: false, // Pass if SVG DOM is the same. Defaults to false. + }, + + // screenshot every example in maximized mode + states: require('./screener.states').default, + + alwaysAcceptBaseBranch: true, + baseBranch, + failureExitCode: 0, + + ...(BUILD_SOURCEBRANCHNAME !== 'master' + ? { + commit: getCurrentHash(), + } + : null), + }; +} +module.exports = getConfig; From ddfe943b0333b277ae78255571688e1ec96ba9c1 Mon Sep 17 00:00:00 2001 From: Raluca Pelin Date: Mon, 12 Sep 2022 10:47:14 +0300 Subject: [PATCH 15/18] Refactor screener config files --- .../screener.config.js | 49 ++++++++++------- apps/vr-tests/screener.config.js | 52 ++++++++++++------- scripts/screener/screener.config.js | 7 +++ scripts/tasks/screener.ts | 8 ++- 4 files changed, 77 insertions(+), 39 deletions(-) diff --git a/apps/vr-tests-react-components/screener.config.js b/apps/vr-tests-react-components/screener.config.js index b658896625d536..afbaff57011a1d 100644 --- a/apps/vr-tests-react-components/screener.config.js +++ b/apps/vr-tests-react-components/screener.config.js @@ -17,24 +17,33 @@ function getCurrentHash() { return ''; } +/** + * + * @param {string} SCREENER_API_KEY + * @param {string} BUILD_SOURCEBRANCHNAME + * @param {string} DEPLOYURL + * @param {string} SYSTEM_PULLREQUEST_TARGETBRANCH + * @returns + */ +function getConfig(SCREENER_API_KEY, BUILD_SOURCEBRANCHNAME, DEPLOYURL, SYSTEM_PULLREQUEST_TARGETBRANCH) { + const baseBranch = SYSTEM_PULLREQUEST_TARGETBRANCH + ? SYSTEM_PULLREQUEST_TARGETBRANCH.replace(/^refs\/heads\//, '') + : 'master'; + // https://github.com/screener-io/screener-storybook#additional-configuration-options + const config = { + projectRepo: 'microsoft/fluentui/react-components', + storybookStaticBuildDir: 'dist/storybook', + storybookConfigDir: '.storybook', + apiKey: SCREENER_API_KEY, + resolution: '1024x768', + baseBranch, + failureExitCode: 0, + alwaysAcceptBaseBranch: true, + ...(BUILD_SOURCEBRANCHNAME !== 'master' ? { commit: getCurrentHash() } : null), + baseUrl: `${DEPLOYURL}/react-components-screener/iframe.html`, + }; + console.log('Screener config: ' + JSON.stringify({ ...config, apiKey: '...' }, null, 2)); + return config; +} -const baseBranch = process.env.SYSTEM_PULLREQUEST_TARGETBRANCH - ? process.env.SYSTEM_PULLREQUEST_TARGETBRANCH.replace(/^refs\/heads\//, '') - : 'master'; - -// https://github.com/screener-io/screener-storybook#additional-configuration-options -const config = { - projectRepo: 'microsoft/fluentui/react-components', - storybookStaticBuildDir: 'dist/storybook', - storybookConfigDir: '.storybook', - apiKey: process.env.SCREENER_API_KEY, - resolution: '1024x768', - baseBranch, - failureExitCode: 0, - alwaysAcceptBaseBranch: true, - ...(process.env.BUILD_SOURCEBRANCHNAME !== 'master' ? { commit: getCurrentHash() } : null), - baseUrl: `${process.env.DEPLOYURL}/react-components-screener/iframe.html`, -}; -console.log('Screener config: ' + JSON.stringify({ ...config, apiKey: '...' }, null, 2)); - -module.exports = config; +module.exports = getConfig; diff --git a/apps/vr-tests/screener.config.js b/apps/vr-tests/screener.config.js index f20b74be20796c..83a6f820b4ee5a 100644 --- a/apps/vr-tests/screener.config.js +++ b/apps/vr-tests/screener.config.js @@ -20,23 +20,39 @@ function getCurrentHash() { return ''; } -const baseBranch = process.env.SYSTEM_PULLREQUEST_TARGETBRANCH - ? process.env.SYSTEM_PULLREQUEST_TARGETBRANCH.replace(/^refs\/heads\//, '') - : 'master'; +/** + * + * @param {string} SCREENER_API_KEY + * @param {string} BUILD_SOURCEBRANCHNAME + * @param {string} DEPLOYURL + * @param {string} SYSTEM_PULLREQUEST_TARGETBRANCH + * @returns + */ +function getConfig( + SCREENER_API_KEY, + BUILD_SOURCEBRANCHNAME, + DEPLOYURL, + SYSTEM_PULLREQUEST_TARGETBRANCH, +) { + const baseBranch = SYSTEM_PULLREQUEST_TARGETBRANCH + ? SYSTEM_PULLREQUEST_TARGETBRANCH.replace(/^refs\/heads\//, '') + : 'master'; -// https://github.com/screener-io/screener-storybook#additional-configuration-options -const config = { - projectRepo: 'microsoft/fluentui', - storybookStaticBuildDir: 'dist/storybook', - storybookConfigDir: '.storybook', - apiKey: process.env.SCREENER_API_KEY, - resolution: '1024x768', - baseBranch, - failureExitCode: 0, - alwaysAcceptBaseBranch: true, - ...(process.env.BUILD_SOURCEBRANCHNAME !== 'master' ? { commit: getCurrentHash() } : null), - baseUrl: `${process.env.DEPLOYURL}/react-screener/iframe.html`, -}; -console.log('Screener config: ' + JSON.stringify({ ...config, apiKey: '...' }, null, 2)); + // https://github.com/screener-io/screener-storybook#additional-configuration-options + const config = { + projectRepo: 'microsoft/fluentui', + storybookStaticBuildDir: 'dist/storybook', + storybookConfigDir: '.storybook', + apiKey: SCREENER_API_KEY, + resolution: '1024x768', + baseBranch, + failureExitCode: 0, + alwaysAcceptBaseBranch: true, + ...(BUILD_SOURCEBRANCHNAME !== 'master' ? { commit: getCurrentHash() } : null), + baseUrl: `${DEPLOYURL}/react-screener/iframe.html`, + }; + console.log('Screener config: ' + JSON.stringify({ ...config, apiKey: '...' }, null, 2)); + return config; +} -module.exports = config; +module.exports = getConfig; diff --git a/scripts/screener/screener.config.js b/scripts/screener/screener.config.js index 682e985bdf4808..8ad4afcc7ce702 100644 --- a/scripts/screener/screener.config.js +++ b/scripts/screener/screener.config.js @@ -30,6 +30,13 @@ require('tsconfig-paths').register({ }); const baseBranch = 'master'; + +/** + * + * @param {string} SCREENER_API_KEY + * @param {string} BUILD_SOURCEBRANCHNAME + * @returns + */ function getConfig(SCREENER_API_KEY, BUILD_SOURCEBRANCHNAME) { // https://github.com/screener-io/screener-runner return { diff --git a/scripts/tasks/screener.ts b/scripts/tasks/screener.ts index c662e83a16caaa..428f6a691a7083 100644 --- a/scripts/tasks/screener.ts +++ b/scripts/tasks/screener.ts @@ -10,7 +10,13 @@ import { getStorybook } from '@storybook/react'; */ export async function screener() { const screenerConfigPath = path.resolve(process.cwd(), './screener.config.js'); - const screenerConfig: ScreenerRunnerConfig = require(screenerConfigPath); + const getConfig = require(screenerConfigPath); + const screenerConfig: ScreenerRunnerConfig = getConfig( + process.env.SCREENER_API_KEY, + process.env.BUILD_SOURCEBRANCHNAME, + process.env.DEPLOYURL, + process.env.SYSYEM_PULLREQUEST_TARGETBRANCH, + ); console.log('screener config for run:'); console.log(JSON.stringify(screenerConfig, null, 2)); From 54cbd92cd83b25372eac0439ebd4404a7fef5367 Mon Sep 17 00:00:00 2001 From: Raluca Pelin Date: Tue, 13 Sep 2022 10:56:45 +0300 Subject: [PATCH 16/18] Make changes according to review --- .../screener.config.js | 20 +++++++-------- apps/vr-tests/screener.config.js | 25 +++++++------------ scripts/config.ts | 2 +- scripts/screener/screener.config.js | 10 ++++---- 4 files changed, 24 insertions(+), 33 deletions(-) diff --git a/apps/vr-tests-react-components/screener.config.js b/apps/vr-tests-react-components/screener.config.js index afbaff57011a1d..3715e94b3bca08 100644 --- a/apps/vr-tests-react-components/screener.config.js +++ b/apps/vr-tests-react-components/screener.config.js @@ -19,28 +19,26 @@ function getCurrentHash() { } /** * - * @param {string} SCREENER_API_KEY - * @param {string} BUILD_SOURCEBRANCHNAME - * @param {string} DEPLOYURL - * @param {string} SYSTEM_PULLREQUEST_TARGETBRANCH + * @param {string} screenerApiKey + * @param {string} sourceBranchName + * @param {string} deployUrl + * @param {string} targetBranch * @returns */ -function getConfig(SCREENER_API_KEY, BUILD_SOURCEBRANCHNAME, DEPLOYURL, SYSTEM_PULLREQUEST_TARGETBRANCH) { - const baseBranch = SYSTEM_PULLREQUEST_TARGETBRANCH - ? SYSTEM_PULLREQUEST_TARGETBRANCH.replace(/^refs\/heads\//, '') - : 'master'; +function getConfig(screenerApiKey, sourceBranchName, deployUrl, targetBranch) { + const baseBranch = targetBranch ? targetBranch.replace(/^refs\/heads\//, '') : 'master'; // https://github.com/screener-io/screener-storybook#additional-configuration-options const config = { projectRepo: 'microsoft/fluentui/react-components', storybookStaticBuildDir: 'dist/storybook', storybookConfigDir: '.storybook', - apiKey: SCREENER_API_KEY, + apiKey: screenerApiKey, resolution: '1024x768', baseBranch, failureExitCode: 0, alwaysAcceptBaseBranch: true, - ...(BUILD_SOURCEBRANCHNAME !== 'master' ? { commit: getCurrentHash() } : null), - baseUrl: `${DEPLOYURL}/react-components-screener/iframe.html`, + ...(sourceBranchName !== 'master' ? { commit: getCurrentHash() } : null), + baseUrl: `${deployUrl}/react-components-screener/iframe.html`, }; console.log('Screener config: ' + JSON.stringify({ ...config, apiKey: '...' }, null, 2)); return config; diff --git a/apps/vr-tests/screener.config.js b/apps/vr-tests/screener.config.js index 83a6f820b4ee5a..7ddbf7c766bde3 100644 --- a/apps/vr-tests/screener.config.js +++ b/apps/vr-tests/screener.config.js @@ -22,34 +22,27 @@ function getCurrentHash() { /** * - * @param {string} SCREENER_API_KEY - * @param {string} BUILD_SOURCEBRANCHNAME - * @param {string} DEPLOYURL - * @param {string} SYSTEM_PULLREQUEST_TARGETBRANCH + * @param {string} screenerApiKey + * @param {string} sourceBranchName + * @param {string} deployUrl + * @param {string} targetBranch * @returns */ -function getConfig( - SCREENER_API_KEY, - BUILD_SOURCEBRANCHNAME, - DEPLOYURL, - SYSTEM_PULLREQUEST_TARGETBRANCH, -) { - const baseBranch = SYSTEM_PULLREQUEST_TARGETBRANCH - ? SYSTEM_PULLREQUEST_TARGETBRANCH.replace(/^refs\/heads\//, '') - : 'master'; +function getConfig(screenerApiKey, sourceBranchName, deployUrl, targetBranch) { + const baseBranch = targetBranch ? targetBranch.replace(/^refs\/heads\//, '') : 'master'; // https://github.com/screener-io/screener-storybook#additional-configuration-options const config = { projectRepo: 'microsoft/fluentui', storybookStaticBuildDir: 'dist/storybook', storybookConfigDir: '.storybook', - apiKey: SCREENER_API_KEY, + apiKey: screenerApiKey, resolution: '1024x768', baseBranch, failureExitCode: 0, alwaysAcceptBaseBranch: true, - ...(BUILD_SOURCEBRANCHNAME !== 'master' ? { commit: getCurrentHash() } : null), - baseUrl: `${DEPLOYURL}/react-screener/iframe.html`, + ...(sourceBranchName !== 'master' ? { commit: getCurrentHash() } : null), + baseUrl: `${deployUrl}/react-screener/iframe.html`, }; console.log('Screener config: ' + JSON.stringify({ ...config, apiKey: '...' }, null, 2)); return config; diff --git a/scripts/config.ts b/scripts/config.ts index 41a044c5657907..83039d4fd8956a 100644 --- a/scripts/config.ts +++ b/scripts/config.ts @@ -19,7 +19,7 @@ let __BASENAME__ = deployBasePath : '/'; if (process.env.OFFICIALRELEASE) { - __BASENAME__ = `/${deployBasePath}/`; + __BASENAME__ = `${deployBasePath}/`; } const __SKIP_ERRORS__ = !!process.env.SKIP_ERRORS; diff --git a/scripts/screener/screener.config.js b/scripts/screener/screener.config.js index 8ad4afcc7ce702..744ac9c4df971c 100644 --- a/scripts/screener/screener.config.js +++ b/scripts/screener/screener.config.js @@ -33,14 +33,14 @@ const baseBranch = 'master'; /** * - * @param {string} SCREENER_API_KEY - * @param {string} BUILD_SOURCEBRANCHNAME + * @param {string} screenerApiKey + * @param {string} sourceBranchName * @returns */ -function getConfig(SCREENER_API_KEY, BUILD_SOURCEBRANCHNAME) { +function getConfig(screenerApiKey, sourceBranchName) { // https://github.com/screener-io/screener-runner return { - apiKey: SCREENER_API_KEY, + apiKey: screenerApiKey, projectRepo: 'microsoft/fluentui/fluentui', diffOptions: { @@ -61,7 +61,7 @@ function getConfig(SCREENER_API_KEY, BUILD_SOURCEBRANCHNAME) { baseBranch, failureExitCode: 0, - ...(BUILD_SOURCEBRANCHNAME !== 'master' + ...(sourceBranchName !== 'master' ? { commit: getCurrentHash(), } From 8d0c00705848635ed17bc30e7a29597a323054d4 Mon Sep 17 00:00:00 2001 From: Raluca Pelin Date: Tue, 13 Sep 2022 15:30:17 +0300 Subject: [PATCH 17/18] Use named arguments for refactored config files functions --- apps/vr-tests-react-components/screener.config.js | 11 ++++++----- apps/vr-tests/screener.config.js | 11 ++++++----- scripts/screener/screener.config.js | 7 ++++--- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/apps/vr-tests-react-components/screener.config.js b/apps/vr-tests-react-components/screener.config.js index 3715e94b3bca08..56a9934f99dc1c 100644 --- a/apps/vr-tests-react-components/screener.config.js +++ b/apps/vr-tests-react-components/screener.config.js @@ -19,13 +19,14 @@ function getCurrentHash() { } /** * - * @param {string} screenerApiKey - * @param {string} sourceBranchName - * @param {string} deployUrl - * @param {string} targetBranch + * @param {Object} options + * @param {string} options.screenerApiKey + * @param {string} options.sourceBranchName + * @param {string} options.deployUrl + * @param {string} options.targetBranch * @returns */ -function getConfig(screenerApiKey, sourceBranchName, deployUrl, targetBranch) { +function getConfig({ screenerApiKey, sourceBranchName, deployUrl, targetBranch }) { const baseBranch = targetBranch ? targetBranch.replace(/^refs\/heads\//, '') : 'master'; // https://github.com/screener-io/screener-storybook#additional-configuration-options const config = { diff --git a/apps/vr-tests/screener.config.js b/apps/vr-tests/screener.config.js index 7ddbf7c766bde3..b928986b51524a 100644 --- a/apps/vr-tests/screener.config.js +++ b/apps/vr-tests/screener.config.js @@ -22,13 +22,14 @@ function getCurrentHash() { /** * - * @param {string} screenerApiKey - * @param {string} sourceBranchName - * @param {string} deployUrl - * @param {string} targetBranch + * @param {Object} options + * @param {string} options.screenerApiKey + * @param {string} options.sourceBranchName + * @param {string} options.deployUrl + * @param {string} options.targetBranch * @returns */ -function getConfig(screenerApiKey, sourceBranchName, deployUrl, targetBranch) { +function getConfig({ screenerApiKey, sourceBranchName, deployUrl, targetBranch }) { const baseBranch = targetBranch ? targetBranch.replace(/^refs\/heads\//, '') : 'master'; // https://github.com/screener-io/screener-storybook#additional-configuration-options diff --git a/scripts/screener/screener.config.js b/scripts/screener/screener.config.js index 744ac9c4df971c..64384043d2cab5 100644 --- a/scripts/screener/screener.config.js +++ b/scripts/screener/screener.config.js @@ -33,11 +33,12 @@ const baseBranch = 'master'; /** * - * @param {string} screenerApiKey - * @param {string} sourceBranchName + * @param {Object} options + * @param {string} options.screenerApiKey + * @param {string} options.sourceBranchName * @returns */ -function getConfig(screenerApiKey, sourceBranchName) { +function getConfig({ screenerApiKey, sourceBranchName }) { // https://github.com/screener-io/screener-runner return { apiKey: screenerApiKey, From bc7c228e1d4e2488cada51054a12874f7bf3bf2f Mon Sep 17 00:00:00 2001 From: Raluca Pelin Date: Tue, 13 Sep 2022 15:39:19 +0300 Subject: [PATCH 18/18] Update call arguments for refactored functions --- scripts/gulp/tasks/screener.ts | 5 ++++- scripts/tasks/screener.ts | 12 ++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/scripts/gulp/tasks/screener.ts b/scripts/gulp/tasks/screener.ts index a598f9f13d90d6..329bf716c30e82 100644 --- a/scripts/gulp/tasks/screener.ts +++ b/scripts/gulp/tasks/screener.ts @@ -37,7 +37,10 @@ task('screener:runner', cb => { }); const getConfig = require(screenerConfigPath); - const screenerConfig = getConfig(process.env.SCREENER_API_KEY, process.env.BUILD_SOURCEBRANCHNAME); + const screenerConfig = getConfig({ + screenerApiKey: process.env.SCREENER_API_KEY, + sourceBranchName: process.env.BUILD_SOURCEBRANCHNAME, + }); handlePromiseExit(screenerRunner(screenerConfig)); }); diff --git a/scripts/tasks/screener.ts b/scripts/tasks/screener.ts index 428f6a691a7083..3f89764f70b651 100644 --- a/scripts/tasks/screener.ts +++ b/scripts/tasks/screener.ts @@ -11,12 +11,12 @@ import { getStorybook } from '@storybook/react'; export async function screener() { const screenerConfigPath = path.resolve(process.cwd(), './screener.config.js'); const getConfig = require(screenerConfigPath); - const screenerConfig: ScreenerRunnerConfig = getConfig( - process.env.SCREENER_API_KEY, - process.env.BUILD_SOURCEBRANCHNAME, - process.env.DEPLOYURL, - process.env.SYSYEM_PULLREQUEST_TARGETBRANCH, - ); + const screenerConfig: ScreenerRunnerConfig = getConfig({ + screenerApiKey: process.env.SCREENER_API_KEY, + sourceBranchName: process.env.BUILD_SOURCEBRANCHNAME, + deployUrl: process.env.DEPLOYURL, + targetBranch: process.env.SYSYEM_PULLREQUEST_TARGETBRANCH, + }); console.log('screener config for run:'); console.log(JSON.stringify(screenerConfig, null, 2));