From 0c9b24b69c7fba74d922ce2616467111e508c397 Mon Sep 17 00:00:00 2001 From: Raluca Pelin Date: Thu, 8 Sep 2022 13:28:05 +0300 Subject: [PATCH 1/4] 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 2/4] 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 c945af9000e7febe0523bdfccc24e0cf80680644 Mon Sep 17 00:00:00 2001 From: Raluca Pelin Date: Tue, 13 Sep 2022 17:44:03 +0300 Subject: [PATCH 3/4] Appropriately rename northstar screener config file --- packages/fluentui/react-northstar/src/index.ts | 1 - scripts/gulp/tasks/screener.ts | 2 +- .../{screener.config.js => screener.config-northstar.js} | 0 3 files changed, 1 insertion(+), 2 deletions(-) rename scripts/screener/{screener.config.js => screener.config-northstar.js} (100%) 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 diff --git a/scripts/gulp/tasks/screener.ts b/scripts/gulp/tasks/screener.ts index cad16621b101c2..95acf3605e6259 100644 --- a/scripts/gulp/tasks/screener.ts +++ b/scripts/gulp/tasks/screener.ts @@ -22,7 +22,7 @@ task('screener:runner', cb => { throw new Error(`package ${docsPackageName} does not exist in the repo`); } - const screenerConfigPath = paths.base('scripts/screener/screener.config.js'); + const screenerConfigPath = paths.base('scripts/screener/screener.config-northstar.js'); // kill the server when done const handlePromiseExit = promise => diff --git a/scripts/screener/screener.config.js b/scripts/screener/screener.config-northstar.js similarity index 100% rename from scripts/screener/screener.config.js rename to scripts/screener/screener.config-northstar.js From 732eea8c792beaeb36b751b75cdc7d29d989ecc2 Mon Sep 17 00:00:00 2001 From: Raluca Pelin Date: Wed, 14 Sep 2022 12:24:38 +0300 Subject: [PATCH 4/4] Use only one screener config file for v8 and v9 --- .github/workflows/screener-run.yml | 4 +- .../screener.config.js | 42 --------------- apps/vr-tests/screener.config.js | 44 --------------- scripts/just.config.ts | 6 +-- scripts/screener/screener.config.js | 54 +++++++++++++++++++ scripts/tasks/screener.ts | 13 +++-- 6 files changed, 68 insertions(+), 95 deletions(-) delete mode 100644 apps/vr-tests-react-components/screener.config.js delete mode 100644 apps/vr-tests/screener.config.js create mode 100644 scripts/screener/screener.config.js diff --git a/.github/workflows/screener-run.yml b/.github/workflows/screener-run.yml index 6ddd0a26c50bef..19c4d4be5e0593 100644 --- a/.github/workflows/screener-run.yml +++ b/.github/workflows/screener-run.yml @@ -175,7 +175,7 @@ jobs: if: ${{ env.IS_ARTIFACT_PRESENT == 'true' }} - name: Start @fluentui/react VR Test - run: yarn workspace @fluentui/vr-tests screener + run: yarn workspace @fluentui/vr-tests screener --v8 env: SCREENER_ENDPOINT: ${{secrets.SCREENER_ENDPOINT}} SCREENER_PROXY_ENDPOINT: ${{secrets.SCREENER_PROXY_ENDPOINT}} @@ -252,7 +252,7 @@ jobs: if: ${{ env.IS_ARTIFACT_PRESENT == 'true' }} - name: Start @fluentui/react-components VR Test - run: yarn workspace @fluentui/vr-tests-react-components screener + run: yarn workspace @fluentui/vr-tests-react-components screener --v9 env: SCREENER_ENDPOINT: ${{secrets.SCREENER_ENDPOINT}} SCREENER_PROXY_ENDPOINT: ${{secrets.SCREENER_PROXY_ENDPOINT}} diff --git a/apps/vr-tests-react-components/screener.config.js b/apps/vr-tests-react-components/screener.config.js deleted file mode 100644 index caa843a8fbb11f..00000000000000 --- a/apps/vr-tests-react-components/screener.config.js +++ /dev/null @@ -1,42 +0,0 @@ -const cp = require('child_process'); - -function getCurrentHash() { - try { - const buffer = cp.execSync('git rev-list --parents -n 1 HEAD', { - stdio: ['pipe', 'pipe', process.stderr], - }); - - if (buffer) { - // The command returns a list of hashes, the last one is the one we want - return buffer.toString().trim().split(' ').pop(); - } - } catch (e) { - console.error('Cannot get current git hash'); - process.exit(1); - } - - return ''; -} - -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_SOURCEBRANCH && process.env.BUILD_SOURCEBRANCH.indexOf('refs/pull') > -1 - ? { 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; diff --git a/apps/vr-tests/screener.config.js b/apps/vr-tests/screener.config.js deleted file mode 100644 index 3002918395bf26..00000000000000 --- a/apps/vr-tests/screener.config.js +++ /dev/null @@ -1,44 +0,0 @@ -// @ts-check - -const cp = require('child_process'); - -function getCurrentHash() { - try { - const buffer = cp.execSync('git rev-list --parents -n 1 HEAD', { - stdio: ['pipe', 'pipe', process.stderr], - }); - - if (buffer) { - // The command returns a list of hashes, the last one is the one we want - return buffer.toString().trim().split(' ').pop(); - } - } catch (e) { - console.error('Cannot get current git hash'); - process.exit(1); - } - - return ''; -} - -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', - storybookStaticBuildDir: 'dist/storybook', - storybookConfigDir: '.storybook', - apiKey: process.env.SCREENER_API_KEY, - resolution: '1024x768', - baseBranch, - failureExitCode: 0, - alwaysAcceptBaseBranch: true, - ...(process.env.BUILD_SOURCEBRANCH && process.env.BUILD_SOURCEBRANCH.indexOf('refs/pull') > -1 - ? { commit: getCurrentHash() } - : null), - baseUrl: `${process.env.DEPLOYURL}/react-screener/iframe.html`, -}; -console.log('Screener config: ' + JSON.stringify({ ...config, apiKey: '...' }, null, 2)); - -module.exports = config; diff --git a/scripts/just.config.ts b/scripts/just.config.ts index 6406ae09cd17b7..a43927a80a559d 100644 --- a/scripts/just.config.ts +++ b/scripts/just.config.ts @@ -1,4 +1,4 @@ -import { task, series, parallel, condition, option, addResolvePath } from 'just-scripts'; +import { task, series, parallel, condition, option, addResolvePath, argv } from 'just-scripts'; import path from 'path'; import fs from 'fs'; @@ -124,8 +124,8 @@ export function preset() { 'bundle', condition('webpack', () => fs.existsSync(path.join(process.cwd(), 'webpack.config.js'))), ); - - task('screener', screener); + option('v8'); + task('screener', () => screener({ version: argv().v8 ? 'v8' : 'v9' })); } preset.basic = basicPreset; diff --git a/scripts/screener/screener.config.js b/scripts/screener/screener.config.js new file mode 100644 index 00000000000000..dfac8bdef013e2 --- /dev/null +++ b/scripts/screener/screener.config.js @@ -0,0 +1,54 @@ +// @ts-check + +const cp = require('child_process'); + +function getCurrentHash() { + try { + const buffer = cp.execSync('git rev-list --parents -n 1 HEAD', { + stdio: ['pipe', 'pipe', process.stderr], + }); + + if (buffer) { + // The command returns a list of hashes, the last one is the one we want + return buffer.toString().trim().split(' ').pop(); + } + } catch (e) { + console.error('Cannot get current git hash'); + process.exit(1); + } + + return ''; +} + +/** + * + * @param {Object} options + * @param {string} options.screenerApiKey + * @param {string} options.sourceBranchName + * @param {string} options.deployUrl + * @param {string} options.targetBranch + * @param {string} options.version + * @returns + */ +function getConfig({ screenerApiKey, sourceBranchName, deployUrl, targetBranch, version }) { + const baseBranch = targetBranch ? targetBranch.replace(/^refs\/heads\//, '') : 'master'; + const projectRepo = version === 'v8' ? 'microsoft/fluentui' : 'microsoft/fluentui/react-components'; + const baseUrlEndpoint = version === 'v8' ? 'react-screener' : 'react-components-screener'; + // https://github.com/screener-io/screener-storybook#additional-configuration-options + const config = { + projectRepo: projectRepo, + storybookStaticBuildDir: 'dist/storybook', + storybookConfigDir: '.storybook', + apiKey: screenerApiKey, + resolution: '1024x768', + baseBranch, + failureExitCode: 0, + alwaysAcceptBaseBranch: true, + ...(sourceBranchName !== 'master' ? { commit: getCurrentHash() } : null), + baseUrl: `${deployUrl}/${baseUrlEndpoint}/iframe.html`, + }; + console.log('Screener config: ' + JSON.stringify({ ...config, apiKey: '...' }, null, 2)); + return config; +} + +module.exports = getConfig; diff --git a/scripts/tasks/screener.ts b/scripts/tasks/screener.ts index c662e83a16caaa..13970d5859691c 100644 --- a/scripts/tasks/screener.ts +++ b/scripts/tasks/screener.ts @@ -1,6 +1,5 @@ import { screenerRunner, environment } from '../screener/screener.runner'; import { ScreenerRunnerConfig, ScreenerRunnerStep, ScreenerState } from '../screener/screener.types'; -import path from 'path'; // @ts-ignore - screener-storybook has no typings import { startStorybook, getStorybook as screenerGetStorybook } from 'screener-storybook'; import { getStorybook } from '@storybook/react'; @@ -8,9 +7,15 @@ import { getStorybook } from '@storybook/react'; * Starts or cancels a screener run through the screener proxy. * Runs are cancelled if package does not appear in Lage's affected package graph. */ -export async function screener() { - const screenerConfigPath = path.resolve(process.cwd(), './screener.config.js'); - const screenerConfig: ScreenerRunnerConfig = require(screenerConfigPath); +export async function screener({ version }) { + const getConfig = require('../screener/screener.config'); + const screenerConfig: ScreenerRunnerConfig = getConfig({ + version: version, + 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));