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

chore: New pipeline for v9 release #19783

Merged
merged 34 commits into from
Sep 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
9c95cfa
experiment with new pipeline
ling1726 Sep 14, 2021
dff586b
use beachball scopes as config
ling1726 Sep 14, 2021
bbe881a
remove generate version file
ling1726 Sep 14, 2021
fc0eb25
remove some steps
ling1726 Sep 14, 2021
ac9199f
use yarn instead of npm
ling1726 Sep 14, 2021
4c18c57
fix northstar scope
ling1726 Sep 14, 2021
427264b
update yml
ling1726 Sep 14, 2021
72fc360
refactor(react-conformance-make-styles): react-conformance as dev deps
ling1726 Sep 15, 2021
bb75fdc
Change files
ling1726 Sep 15, 2021
5a30b0a
update md
ling1726 Sep 15, 2021
0552590
move react-conformance to devdeps
ling1726 Sep 16, 2021
30f8535
merge master
ling1726 Sep 16, 2021
edf9f47
Merge branch 'refactor/react-conformance-make-styles' into chore/sepa…
ling1726 Sep 16, 2021
39c4504
fix scopes
ling1726 Sep 17, 2021
09d0dc6
Merge remote-tracking branch 'origin/master' into chore/separate-v9-r…
ling1726 Sep 17, 2021
926fc64
Merge branch 'master' into chore/separate-v9-release
ling1726 Sep 17, 2021
0e84de2
Merge branch 'master' into chore/separate-v9-release
ling1726 Sep 20, 2021
315e4a6
update current release script
ling1726 Sep 20, 2021
0c3c313
add PR comment for ts-ignore
ling1726 Sep 20, 2021
484a74a
clean up beachball config
ling1726 Sep 20, 2021
7b7822c
remove hard coded paths
ling1726 Sep 20, 2021
ce37505
refactor global scope var
ling1726 Sep 20, 2021
e4651b6
improve type
ling1726 Sep 20, 2021
de5c6d7
add docstring
ling1726 Sep 20, 2021
d2e8a66
use runPublished
ling1726 Sep 20, 2021
a7572e2
filter scopes
ling1726 Sep 20, 2021
b359c2e
Merge branch 'master' into chore/separate-v9-release
ling1726 Sep 21, 2021
6162cc1
PR suggestions
ling1726 Sep 21, 2021
1f0d98b
add TODO
ling1726 Sep 21, 2021
8d671cd
use token in pipeline
ling1726 Sep 21, 2021
7c363bd
remove CG
ling1726 Sep 21, 2021
3281e69
use isConvergedPackage
ling1726 Sep 21, 2021
6e6480d
clean up runPublished
ling1726 Sep 21, 2021
7bcdca8
update docstring
ling1726 Sep 21, 2021
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
82 changes: 82 additions & 0 deletions azure-pipelines.release-vnext.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
pr: none
trigger: none

# Customize build number to include major version
# Example: v9_20201022.1
name: 'v9_$(Date:yyyyMMdd)$(Rev:.r)'

variables:
- group: 'Github and NPM secrets'
- template: .devops/templates/variables.yml
parameters:
skipComponentGovernanceDetection: false
- name: release.vnext # Used to scope beachball to release only vnext packages
value: true

pool: 'Self Host Ubuntu'

# TODO set schedule once the pipeline is validated after a few manual releases
# schedules:
# # minute 0, hour 7 in UTC (11pm in UTC-8), Every monday
# # https://docs.microsoft.com/en-us/azure/devops/pipelines/build/triggers?tabs=yaml&view=azure-devops#supported-cron-syntax
# - cron: '0 7 * * 1'
# # will be 12am during daylight savings time unless trigger is updated
# displayName: 'Scheduled release (Every monday)'
# branches:
# include:
# - master

workspace:
clean: all

steps:
- template: .devops/templates/tools.yml

- script: |
git config user.name "Fluent UI Build"
git config user.email "[email protected]"
git remote set-url origin https://$(githubUser):$(githubPAT)@github.com/microsoft/fluentui.git
displayName: Authenticate git for pushes

- task: Bash@3
inputs:
filePath: yarn-ci.sh
displayName: yarn

- script: |
yarn run:published build --production --no-cache
displayName: yarn build

- script: |
yarn run:published test
displayName: yarn test

- script: |
yarn run:published lint
displayName: yarn lint

- script: |
yarn publish:beachball -n $(npmToken)
git reset --hard origin/master
env:
GITHUB_PAT: $(githubPAT)
displayName: Publish changes and bump versions

# TODO update release notes script for v9
# - script: |
# node -r ./scripts/ts-node-register ./scripts/updateReleaseNotes/index.ts --token=$(githubPAT) --apply --debug
# displayName: 'Update github release notes'

# This would usually be run automatically (via a pipeline decorator from an extension), but the
# thorough cleanup step prevents it from working. So run it manually here.
- task: ComponentGovernanceComponentDetection@0
displayName: 'Component Detection'
inputs:
sourceScanPath: $(Agent.BuildDirectory)
condition: succeeded()
timeoutInMinutes: 5
continueOnError: true

- template: .devops/templates/cleanup.yml
parameters:
checkForChangedFiles: false
24 changes: 1 addition & 23 deletions azure-pipelines.release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,6 @@ steps:
yarn generate-version-files
displayName: Generate version files

# The contents of this file is configured in the component governence tab of ADO
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OSSCELA has confirmed we don't need to actually include the NOTICE file in packages, running the enhanced license scans should be enough

# - task: msospo.ospo-extension.8d7f9abb-6896-461d-9e25-4f74ed65ddb2.notice@0
# displayName: 'Generate NOTICE file for convergence'

# - task: DownloadBuildArtifacts@0
# displayName: 'Download NOTICE.txt'
# inputs:
# downloadType: specific
# itemPattern: '**/NOTICE.txt'

# - task: CopyFiles@2
# displayName: 'Copy NOTICE to @fluentui/react-components'
# inputs:
# SourceFolder: '$(System.ArtifactsDirectory)'
# Contents: '**/NOTICE.txt'
# TargetFolder: '$(Build.SourcesDirectory)/packages/react-components'
# flattenFolders: true

# - script: |
# yarn copy-notices
# displayName: Copy NOTICE to converged packages

- script: |
yarn run:published build --production --no-cache
displayName: yarn build
Expand All @@ -84,7 +62,7 @@ steps:
displayName: yarn bundle

- script: |
npm run publish:beachball -- -b origin/master -n $(npmToken) --access public -y
yarn publish:beachball -n $(npmToken)
git reset --hard origin/master
env:
GITHUB_PAT: $(githubPAT)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"postinstall": "node ./scripts/postinstall.js",
"preinstall": "node ./scripts/use-yarn-please.js",
"prelint": "yarn satisfied && yarn syncpack:list",
"publish:beachball": "beachball publish --scope \"!packages/fluentui/*\"",
"publish:beachball": "beachball publish -b origin/master --access public -y",
"rebuild": "node ./scripts/invalidate-just-cache.js && yarn build --reset-cache",
"release:fluentui:canary": "node -r ./scripts/ts-node-register ./scripts/fluentui-publish publish-canary",
"release:fluentui:minor": "node -r ./scripts/ts-node-register ./scripts/fluentui-publish publish-minor",
Expand Down
49 changes: 49 additions & 0 deletions scripts/beachball/getScopes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { AllPackageInfo, getAllPackageInfo, isConvergedPackage } from '../monorepo/index';

/**
* Reads package info from the monorepo and generates the scopes for beachball bump and release.
* Differentiates between vNext and v8 releases.
*
* vNext scope includes all packages that have version > 8.x and shared internal packages that need versions bumped.
* @returns {string[]} Array of package paths for beachball scope
*/
export function getScopes(): string[] {
const allPackageInfo = getAllPackageInfo();

if (process.env.RELEASE_VNEXT) {
return [...getVNextPackagePaths(allPackageInfo), ...getSharedPackagePaths(allPackageInfo)];
}

const ignoreVNextScope = getVNextPackagePaths(allPackageInfo).map(path => `!${path}`);
// Northstar is never published with beachbal
const ignoreNorthstarScope = '!packages/fluentui/*';
return [ignoreNorthstarScope, ...ignoreVNextScope];
}

function getVNextPackagePaths(allPackageInfo: AllPackageInfo) {
return Object.values(allPackageInfo)
.map(packageInfo => {
if (isConvergedPackage(packageInfo.packageJson)) {
return packageInfo.packagePath;
}

return false;
})
.filter(Boolean) as string[];
}

function getSharedPackagePaths(allPackageInfo: AllPackageInfo) {
return Object.values(allPackageInfo)
.map(packageInfo => {
// These packages depend on converged packages, but are private
// Can be included in the publish scope so that dependencies are bumped correctly.
const privateNonConverged = ['perf-test', 'vr-tests'];

if (privateNonConverged.includes(packageInfo.packageJson.name)) {
return packageInfo.packagePath;
}

return false;
})
.filter(Boolean) as string[];
}
37 changes: 37 additions & 0 deletions scripts/beachball/getVNextChangelogGroups.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { ChangelogGroupOptions } from 'beachball';
import { AllPackageInfo, getAllPackageInfo } from '../monorepo/index';

/**
* Generates grouped changelog for vNext
* @returns Grouped changelog configuration
*/
export function getVNextChangelogGroups(): ChangelogGroupOptions {
const allPackageInfo = getAllPackageInfo();
const vNextPackagePaths = getVNextPackagePaths(allPackageInfo);

return {
masterPackageName: '@fluentui/react-components',
changelogPath: 'packages/react-components',
include: vNextPackagePaths,
};
}

export function getVNextPackagePaths(allPackageInfo: AllPackageInfo) {
return Object.values(allPackageInfo)
.map(packageInfo => {
if (packageInfo.packageJson.version.startsWith('9.')) {
Copy link
Member

@ecraig12345 ecraig12345 Sep 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just added this thing which might be useful https://github.com/microsoft/fluentui/blob/master/scripts/monorepo/isConvergedPackage.js

(it's a simple check but decided it might be worth centralizing in case we need to change it later or something? and makes it easier to find all the places checking "is this package converged")

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good callout, I'll use it in this PR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made some modifications to the util to improve the typing

return packageInfo.packagePath;
}

// These packages depend on converged packages, but are private
// Can be included in the publish scope so that dependencies are bumped correctly.
const privateNonConverged = ['perf-test', 'vr-tests'];

if (privateNonConverged.includes(packageInfo.packageJson.name)) {
return packageInfo.packagePath;
}

return false;
})
.filter(Boolean) as string[];
}
23 changes: 4 additions & 19 deletions scripts/beachball/index.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,18 @@
import { BeachballConfig } from 'beachball';
import { getAllPackageInfo, isConvergedPackage } from '../monorepo/index';
import { renderHeader, renderEntry } from './customRenderers';

const allPackageInfo = getAllPackageInfo();
const fluentConvergedPackagePaths = Object.values(allPackageInfo)
.map(packageInfo => {
if (isConvergedPackage(packageInfo.packageJson) && !packageInfo.packageJson.private) {
return packageInfo.packagePath;
}

return false;
})
.filter(Boolean) as string[];
import { getScopes } from './getScopes';
import { getVNextChangelogGroups } from './getVNextChangelogGroups';

export const config: BeachballConfig = {
disallowedChangeTypes: ['major', 'prerelease'],
tag: 'latest',
generateChangelog: true,
scope: getScopes(),
changelog: {
customRenderers: {
renderHeader,
renderEntry,
},
groups: [
{
masterPackageName: '@fluentui/react-components',
changelogPath: 'packages/react-components',
include: fluentConvergedPackagePaths,
},
],
groups: [getVNextChangelogGroups()],
},
};
10 changes: 6 additions & 4 deletions scripts/monorepo/isConvergedPackage.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
const semver = require('semver');
const { readConfig } = require('../read-config');

/**
* @typedef {string | import('./index').PackageJson} PathOrPackageJson
*/

/**
* Determines whether a package is converged, based on its version.
* @param {string} [packagePathOrJson] optional different package path to run in OR previously-read package.json
* @param {PathOrPackageJson} [packagePathOrJson] optional different package path to run in OR previously-read package.json
* (defaults to reading package.json from `process.cwd()`)
* @returns {boolean} true if it's a converged package (version >= 9)
*/
function isConvergedPackage(packagePathOrJson) {
const packageJson =
!packagePathOrJson || typeof packagePathOrJson === 'string'
? readConfig('package.json', packagePathOrJson)
: packagePathOrJson;
typeof packagePathOrJson === 'string' ? readConfig('package.json', packagePathOrJson) : packagePathOrJson;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the !pathOrPackageJson broke the default case where it reads from process.cwd(), which broke building converged packages in codesandbox. I'll make a PR to fix it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return !!packageJson && semver.major(packageJson.version) >= 9;
}

Expand Down
21 changes: 15 additions & 6 deletions scripts/monorepo/runPublished.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @ts-check
const { spawnSync } = require('child_process');
const getAllPackageInfo = require('./getAllPackageInfo');
const isConvergedPackage = require('./isConvergedPackage');
const lageBin = require.resolve('lage/bin/lage.js');

const argv = process.argv.slice(2);
Expand All @@ -27,12 +28,20 @@ const websitePackages = [
// (which must be built and uploaded with each release). This is similar to "--scope \"!packages/fluentui/*\""
// in the root package.json's publishing-related scripts and will need to be updated if --scope changes.
const beachballPackageScopes = Object.entries(getAllPackageInfo())
.filter(
([, { packageJson, packagePath }]) =>
!/[\\/]fluentui[\\/]/.test(packagePath) &&
(packageJson.private !== true || websitePackages.includes(packageJson.name)),
)
.map(([packageName]) => `--to=${packageName}`);
.filter(([, { packageJson, packagePath }]) => {
// Ignore northstar and private packages
if (/[\\/]fluentui[\\/]/.test(packagePath) || packageJson.private === true) {
return false;
}

if (process.env.RELEASE_VNEXT) {
return isConvergedPackage(packageJson);
}

return websitePackages.includes(packageJson.name);
})
.map(([packageName]) => `--to=${packageName}`)
.filter(Boolean);

const lageArgs = [
'run',
Expand Down