Skip to content

Commit

Permalink
[not verified] Merge remote-tracking branch 'origin/trunk' into fix/b…
Browse files Browse the repository at this point in the history
…laze-post-publish-i18n
  • Loading branch information
jeherve committed Jun 23, 2023
2 parents 98e5c6a + 5a3083b commit 8b800ef
Show file tree
Hide file tree
Showing 152 changed files with 2,920 additions and 737 deletions.
81 changes: 2 additions & 79 deletions .github/renovate-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ module.exports = {
platform: 'github',
repositories: [ 'Automattic/jetpack' ],

// We're including configuration in this file.
onboarding: false,
requireConfig: 'optional',

// Extra code to run before creating a commit.
allowPostUpgradeCommandTemplating: true,
allowedPostUpgradeCommands: [ monorepoBase + '.github/files/renovate-post-upgrade-run.sh' ],
Expand All @@ -53,15 +49,8 @@ module.exports = {
},
postUpdateOptions: [ 'pnpmDedupe' ],

// This is the renovate configuration.
extends: [ 'config:base', 'group:definitelyTyped' ],
labels: [ '[Type] Janitorial', '[Status] Needs Review' ],
prHourlyLimit: 1,
timezone: 'UTC',
schedule: [ 'before 3am on the first day of the month' ],
updateNotScheduled: false,
semanticCommits: 'disabled',
osvVulnerabilityAlerts: true,
// Most of the actual renovate configuration is in renovate.json5, except for a few things
// where we want to read part of it from somewhere else.
constraints: {
php: `~${ versions.PHP_VERSION }.0`,
},
Expand Down Expand Up @@ -95,71 +84,5 @@ module.exports = {
} )(),
enabled: false,
},

// We need to keep a wide version range to support PHP 5.6.
// Note for libraries used in plugins this will only work right for require-dev deps, not require.
{
matchPackageNames: [
'johnkary/phpunit-speedtrap',
'symfony/console',
'symfony/process',
'wikimedia/at-ease',
'wikimedia/testing-access-wrapper',
],
rangeStrategy: 'widen',
},

// Various other monorepos and package groupings.
{
extends: [ 'monorepo:wordpress' ],
separateMajorMinor: false,
prPriority: 1,
},
{
extends: [ 'monorepo:react' ],
},
{
extends: [ 'packages:eslint' ],
groupName: 'Eslint packages',
},
{
extends: [ 'packages:jsUnitTest' ],
groupName: 'JS unit testing packages',
},
{
groupName: 'Size-limit',
matchPackageNames: [ 'size-limit', '@size-limit/preset-app' ],
},
// These aren't a monorepo, but we may as well do them all together anyway.
{
groupName: 'GitHub API packages',
matchPackagePatterns: [ '^@actions/', '^@octokit/' ],
},

// 🤷
{
groupName: 'Instant Search Dependency Updates',
matchPackageNames: [
'cache',
'preact',
'progress-event',
'q-flat',
'qss',
'strip',
'uuid',
'@testing-library/preact',
],
reviewers: [ 'team:jetpack-search' ],
addLabels: [ 'Search', 'Instant Search' ],
},
],
lockFileMaintenance: {
enabled: true,
schedule: [ 'before 3:00 am on Monday on the 7th through 13th day of the month' ],
},
dependencyDashboard: true,
dependencyDashboardTitle: 'Renovate Dependency Updates',
dependencyDashboardLabels: [ 'Primary Issue', '[Type] Janitorial' ],
dependencyDashboardFooter:
'The bot runs every two hours, and may be monitored or triggered ahead of schedule [here](https://github.com/Automattic/jetpack/actions/workflows/renovate.yml).',
};
94 changes: 93 additions & 1 deletion .github/renovate.json5
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
{
extends: [ 'config:base', 'group:definitelyTyped' ],
labels: [ '[Type] Janitorial', '[Status] Needs Review' ],
prHourlyLimit: 1,
timezone: 'UTC',
schedule: [ 'before 3am on the first day of the month' ],
updateNotScheduled: false,
semanticCommits: 'disabled',
osvVulnerabilityAlerts: true,
// Note: constraints.php is set in renovate-config.js where we can read it in code.

// Paths and files for renovate to ignore.
// We have to override this because the default from config:base catches projects/plugins/*/tests/e2e/package.json which we do want processed.
// We have to do it here rather than renovate-config.js because `extends` and `globalExtends` both somehow overwrite it when defined there, even with `ignorePresets`.
ignorePresets: [ ':ignoreModulesAndTests' ],
ignorePaths: [
'**/node_modules/**',
Expand All @@ -12,4 +21,87 @@
'**/tests/!(e2e)/**',
'**/__fixtures__/**',
],

packageRules: [
// Monorepo packages are excluded in renovate-config.js, where we can read
// the list of them in code.

// We need to keep a wide version range to support PHP 5.6.
// Note for libraries used in plugins this will only work right for require-dev deps, not require.
{
matchPackageNames: [
'johnkary/phpunit-speedtrap',
'symfony/console',
'symfony/process',
'wikimedia/at-ease',
'wikimedia/testing-access-wrapper',
],
rangeStrategy: 'widen',
},

// Various other monorepos and package groupings.
{
extends: [ 'monorepo:wordpress' ],
separateMajorMinor: false,
prPriority: 1,
},
{
extends: [ 'monorepo:react' ],
},
{
extends: [ 'packages:eslint' ],
groupName: 'Eslint packages',
},
{
extends: [ 'packages:jsUnitTest' ],
groupName: 'JS unit testing packages',
},
{
groupName: 'Size-limit',
matchPackageNames: [ 'size-limit', '@size-limit/preset-app' ],
},
// These aren't a monorepo, but we may as well do them all together anyway.
{
groupName: 'GitHub API packages',
matchPackagePatterns: [ '^@actions/', '^@octokit/' ],
},

// 🤷
{
groupName: 'Instant Search Dependency Updates',
matchPackageNames: [
'cache',
'preact',
'progress-event',
'q-flat',
'qss',
'strip',
'uuid',
'@testing-library/preact',
],
reviewers: [ 'team:jetpack-search' ],
addLabels: [ 'Search', 'Instant Search' ],
},
],

regexManagers: [
// Update the renovate-version in the action itself.
// See also https://github.com/renovatebot/github-action/issues/756
{
fileMatch: [ '^\\.github/workflows/renovate\\.yml$' ],
matchStrings: [ 'renovate-version: (?<currentValue>[^\\s]+)' ],
datasourceTemplate: 'docker',
depNameTemplate: 'renovate',
packageNameTemplate: 'ghcr.io/renovatebot/renovate',
},
],

lockFileMaintenance: {
enabled: true,
schedule: [ 'before 3:00 am on Monday on the 7th through 13th day of the month' ],
},
dependencyDashboard: true,
dependencyDashboardTitle: 'Renovate Dependency Updates',
dependencyDashboardLabels: [ 'Primary Issue', '[Type] Janitorial' ],
dependencyDashboardFooter: 'The bot runs every two hours, and may be monitored or triggered ahead of schedule [here](https://github.com/Automattic/jetpack/actions/workflows/renovate.yml).',
}
4 changes: 3 additions & 1 deletion .github/workflows/renovate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ jobs:
TOKEN: ${{ secrets.RENOVATE_TOKEN }}
run: |
curl --no-progress-meter --header "Authorization: Bearer $TOKEN" https://api.github.com/rate_limit
- uses: renovatebot/github-action@v34.154.2
- uses: renovatebot/github-action@v38.1.7
with:
configurationFile: /tmp/monorepo/.github/renovate-config.js
token: ${{ secrets.RENOVATE_TOKEN }}
mount-docker-socket: true
renovate-version: 35.140.0
env:
LOG_LEVEL: ${{ github.event.inputs.logLevel || 'debug' }}
RENOVATE_DRY_RUN: ${{ github.event.inputs.dryRun == 'no' && 'null' || github.event.inputs.dryRun || 'null' }}
Expand Down
10 changes: 10 additions & 0 deletions .pnpmfile.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ function fixDeps( pkg ) {
pkg.dependencies.svelte2tsx = '^0.6.10';
}

// Missing dep or peer dep on @babel/runtime
// https://github.com/zillow/react-slider/issues/296
if (
pkg.name === 'react-slider' &&
! pkg.dependencies?.[ '@babel/runtime' ] &&
! pkg.peerDependencies?.[ '@babel/runtime' ]
) {
pkg.peerDependencies[ '@babel/runtime' ] = '^7';
}

return pkg;
}

Expand Down
69 changes: 49 additions & 20 deletions docs/monorepo.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,13 @@ Most projects in the monorepo should have a mirror repository holding a built ve
1. Create the mirror repo on GitHub. It will most likely be named like "<span>https://</span>github.com/Automattic/jetpack-_something_".
1. The repo's description should begin with `[READ ONLY]` and end with `This repository is a mirror, for issue tracking and development head to: https://github.com/automattic/jetpack`.
2. The default branch should be `trunk`, matching the monorepo.
* Note that you can't set the default branch until at least one branch is created in the repo.
3. In the repo's settings, turn off wikis, issues, projects, and so on.
4. Make sure that [matticbot](https://github.com/matticbot) can push to the repo. You would do this here: `https://github.com/Automattic/example-reposiroty-name/settings/branches` - creating a new branch protection rule where only Matticbot (and whoever needs access to push, for example Ground Control) can push to that repository.
5. Make sure that Actions are enabled. The build process copies workflows from `.github/files/mirror-.github` into the mirror to do useful things like automatically close PRs with a reference back to the monorepo.
6. Create any secrets needed (e.g. for Autotagger or Npmjs-Autopublisher). See PCYsg-xsv-p2#mirror-repo-secrets for details.
2. For a package you also need to go to packagist.org and create the package there. This requires pushing a first commit with a valid `composer.json` to the repository. That can be done by copying the new package's `composer.json` from the PR that introduced it.
1. Once the package is added to Packagist, it is best to add some maintainers. Currently these will be `automattic`, `kraft` and `dereksmart`.
2. For a PHP package (or a plugin listed in Packagist) you also need to go to packagist.org and create the package there. This requires pushing a first commit with a valid `composer.json` to the repository. That can be done by copying the new package's `composer.json` from the PR that introduced it.
1. Be sure that `automattic` is added as a maintainer.
3. If your project requires building, configure `.scripts.build-production` in your project's `composer.json` to run the necessary commands.
4. If there are any files included in the monorepo that should not be included in the mirror, use `.gitattributes` to tag them with "production-exclude".
5. If there are any built files in `.gitignore` that should be included in the mirror, use `.gitattributes` to tag them with "production-include".
Expand Down Expand Up @@ -378,28 +379,56 @@ Within a single project, changlogger’s `version next` command can tell you the
## New Projects
### Creating a new Composer Package
To add a Composer package:
* For Automatticians, drop us a line in #jetpack-crew to discuss your needs, just to be sure we don't have something already.
* Use the `jetpack generate package` command to create a skeleton project.
* Create your package and submit a PR as usual.
To begin,
* For Automatticians, drop us a line in #jetpack-crew to discuss your needs, just to be sure we don't have something already. For others, it would probably be best to open an issue to discuss it.
* Use the `jetpack generate` command to create a skeleton project.
* Create your project based on the skeleton and submit a PR as usual.
Once reviewed and approved, the Crew team does the following:
* Creates a GitHub repo in the Automattic repo to be the mirror repo for this project, if not done already. The new repo follows the [mirror repo guidelines](#mirror-repositories).
* Adds a `composer.json` file to the repo, with some basic information about the package. This file is used by Packagist to generate the package page.
* Creates a new Packagist package on packagist.org under the Automattic org. @jeherve, @dsmart, and @kraftbj are added as maintainers of all Jetpack monorepo packages.
### Creating a new plugin
Once we're sure that the project will be created and what its name will be, someone (you or the Crew team) does the following:
* Create a GitHub repo in the Automattic repo to be the mirror repo for this project. The new repo follows the [mirror repo guidelines](#mirror-repositories).
If you're thinking about developing a new plugin in the monorepo, come chat with us in #jetpack-crew. We'll help you get started.
### Creating a new Composer Package
Once you are ready to start working on a first version of your plugin in the monorepo, use the `jetpack generate plugin` command to create the first files for your plugin. Then, open a new PR with that skeleton.
In addition to the above, after creating the mirror repo,
* Add a `composer.json` file to the repo, with some basic information about the package. This file is used by Packagist to generate the package page.
* Create a new Packagist package on packagist.org under the Automattic org. Add `automattic` as a maintainer.
Before you can merge your PR, the Crew team will do the following:
### Creating a new plugin
* Create the mirror repo for the plugin following the [mirror repo guidelines](#mirror-repositories).
In addition to the above, after creating the mirror repo,
* Add a first version of a `composer.json` file to the mirror repo.
* Add the plugin to Packagist, for folks who may be consuming it through Composer.
* Add maintainers to the Packagist entry, just like for Composer packages above.
* Add the plugin to Packagist, just like for Composer packages above, for folks who want to consume it through Composer.
* Add an entry for the new plugin in the Beta server settings. Find extra details on this process in the Jetpack Beta Builder repository. More information: PCYsg-gDE-p2
### Importing an existing repo
To move development of an existing (public) repo into the Jetpack monorepo, you might do something like this.
Preparation in the original repo:
* Set up PHP_CodeSniffer with [our ruleset](https://packagist.org/packages/Automattic/jetpack-codesniffer) and fix any lints identified.
* Merge any PRs that are ready to merge.
In a checkout of the monorepo:
* Use `git remote add` to add a new remote for the existing repo, e.g. `git remote add existing-source-repo [email protected]:Automattic/existing-source-repo`
* `git fetch existing-source-repo`
* Create a new (temporary) branch based on the existing source repo: `git checkout -b existing-repo/prepare-source existing-source-repo/trunk`
* Move the files to where they should live in the monorepo, e.g. `git mv -k * .* projects/plugins/new-plugin`
* You may need to do something like `mkdir --parents ./projects/plugins/new-plugin` for the move to work.
* TODO: Consider whether `git filter-repo` might be better. See p9dueE-2on-p2#comment-5761
* Commit `git add --all && git commit -m "Prepare XXX for monorepo"`
* Create the branch for the actual import: `git fetch origin && git checkout -b add/import-from-existing-repo origin/trunk`
* `git merge --allow-unrelated-histories existing-repo/prepare-source`. This will merge in the source plugin into the monorepo while maintaining all previous commits.
* Create additional commits to clean up the new project: adjust tooling to use what the monorepo provides, remove unneeded tooling, set monorepo configuration in `composer.json`, etc.
* Run linting and such. Commit anything necessary.
* `git push origin HEAD` and create your PR. Add the "DO NOT MERGE" tag.
* When it's time to merge the PR, go to the [GitHub settings page](https://href.li/?https://github.com/Automattic/jetpack/settings) and enable "Allow merge commits". Then go to the PR. There should be a caret dropdown next to "Squash and Merge" which you can use to select "Create a merge commit" instead.
* Clean up:
* Go back to the settings and turn "Allow merge commits" back off.
* `git branch -D existing-repo/prepare-source` to delete the temporary branch.
* If you want to move any open PRs from the old repo, check out the branches, `git merge origin/trunk` (and resolve any conflicts), push to origin, and recreate.
* `git remote remove existing-source-repo` to remove the remote.
* If you're going to reuse the old repo as the mirror, reconfigure it to match the [mirror repo guidelines](#mirror-repositories).
See p9dueE-2on-p2 for past uses of this process.
While a private repo could be imported similarly, you'd have a lot of auditing to do to make sure no old commit exposes any private information.
Loading

0 comments on commit 8b800ef

Please sign in to comment.