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

feat(go): add support for releasing yoshi gapic go libraries #514

Merged
merged 8 commits into from
Aug 12, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
more filtering and tweaking regen formatting
  • Loading branch information
codyoss committed Aug 9, 2020
commit 1e43641841ba3ded76be1f1f1a5abb9b1674054d
21 changes: 13 additions & 8 deletions __snapshots__/yoshi-go.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,27 @@ exports['CHANGES-go-yoshi'] = `
## [0.124.0](https://github.com/googleapis/yoshi-go-test-repo/compare/v0.123.4...v0.124.0)


### Features

* **all:** auto-regenerate gapics ([#1000](https://github.com/googleapis/yoshi-go-test-repo/issues/1000)) ([#1001](https://github.com/googleapis/yoshi-go-test-repo/issues/1001))
* **asset:** added a really cool feature ([d7d1c89](https://github.com/googleapis/yoshi-go-test-repo/commit/d7d1c890dc1526f4d62ceedad581f498195c8939))


### Bug Fixes

* **automl:** update dependency com.google.cloud:google-cloud-storage to v1.120.0 ([fcd1c89](https://github.com/googleapis/yoshi-go-test-repo/commit/fcd1c890dc1526f4d62ceedad561f498195c8939))
* **deps:** update dependency com.google.cloud:google-cloud-spanner to v1.50.0 ([1f9663c](https://github.com/googleapis/yoshi-go-test-repo/commit/1f9663cf08ab1cf3b68d95dee4dc99b7c4aac373))
* **automl:** fixed a really bad bug ([d7d1c89](https://github.com/googleapis/yoshi-go-test-repo/commit/d7d1c890dc1526f4d62ceedad581f498195c8939))

`

exports['PR body-go-yoshi'] = {
'title': 'chore: release 0.124.0',
'body': ':robot: I have created a release \\*beep\\* \\*boop\\* \n---\n## [0.124.0](https://github.com/googleapis/yoshi-go-test-repo/compare/v0.123.4...v0.124.0) \n\n\n### Bug Fixes\n\n* **automl:** update dependency com.google.cloud:google-cloud-storage to v1.120.0 ([fcd1c89](https://github.com/googleapis/yoshi-go-test-repo/commit/fcd1c890dc1526f4d62ceedad561f498195c8939))\n* **deps:** update dependency com.google.cloud:google-cloud-spanner to v1.50.0 ([1f9663c](https://github.com/googleapis/yoshi-go-test-repo/commit/1f9663cf08ab1cf3b68d95dee4dc99b7c4aac373))\n---\n\n\nThis PR was generated with [Release Please](https://github.com/googleapis/release-please).',
'head': 'release-v0.124.0',
'base': 'master'
"title": "chore: release 0.124.0",
"body": ":robot: I have created a release \\*beep\\* \\*boop\\* \n---\n## [0.124.0](https://github.com/googleapis/yoshi-go-test-repo/compare/v0.123.4...v0.124.0) \n\n\n### Features\n\n* **all:** auto-regenerate gapics ([#1000](https://github.com/googleapis/yoshi-go-test-repo/issues/1000)) ([#1001](https://github.com/googleapis/yoshi-go-test-repo/issues/1001))\n* **asset:** added a really cool feature ([d7d1c89](https://github.com/googleapis/yoshi-go-test-repo/commit/d7d1c890dc1526f4d62ceedad581f498195c8939))\n\n\n### Bug Fixes\n\n* **automl:** fixed a really bad bug ([d7d1c89](https://github.com/googleapis/yoshi-go-test-repo/commit/d7d1c890dc1526f4d62ceedad581f498195c8939))\n---\n\n\nThis PR was generated with [Release Please](https://github.com/googleapis/release-please).",
"head": "release-v0.124.0",
"base": "master"
}

exports['labels-go-yoshi'] = {
'labels': [
'autorelease: pending'
"labels": [
"autorelease: pending"
]
}
31 changes: 21 additions & 10 deletions src/releasers/go-yoshi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import * as semver from 'semver';
// Generic
import {Changelog} from '../updaters/changelog';

// These repos should be ignored when generating a release for the
// top level mono-repo:
const IGNORED_PATHS = [
// Commits containing a scope prefixed with an item in this array will be
// ignored when generating a release PR for the parent module.
const SUB_MODULES = [
'bigtable',
'bigquery',
'datastore',
Expand All @@ -43,21 +43,29 @@ const GAPIC_PR_REGEX = /.*auto-regenerate gapics.*/;
export class GoYoshi extends ReleasePR {
static releaserName = 'go-yoshi';
protected async _run() {
const scopeRe = /^\w+\((?<scope>.*)\):/;
const latestTag = await this.gh.latestTag(
this.monorepoTags ? `${this.packageName}-` : undefined
);
let gapicPR: Commit;
let gapicPR: Commit | undefined;
const commits = (
await this.commits({
sha: latestTag?.sha,
path: this.path,
})
).filter(commit => {
// Filter commits that don't have a scope as we don't know where to put
// them.
const scope = commit.message.match(scopeRe)?.groups?.scope;
if (!scope) {
return false;
}
// Skipping commits related to sub-modules as they are not apart of the
// parent module.
for (const ignoredPath of IGNORED_PATHS) {
const re = new RegExp(`^\\w+\\(${ignoredPath}.*\\)`);
if (re.test(commit.message)) {
for (const subModule of SUB_MODULES) {
if (scope.startsWith(subModule)) {
// TODO(codyoss): eventually gather these commits into a map so we can
// purpose releases for sub-modules.
return false;
}
}
Expand All @@ -72,6 +80,8 @@ export class GoYoshi extends ReleasePR {
}
return false;
} else {
// Throw away the sha for nightly regens, will just append PR numbers.
commit.sha = null;
gapicPR = commit;
}
}
Expand All @@ -88,12 +98,15 @@ export class GoYoshi extends ReleasePR {
latestTag
);

const changelogEntry: string = await cc.generateChangelogEntry({
let changelogEntry: string = await cc.generateChangelogEntry({
version: candidate.version,
currentTag: `v${candidate.version}`,
previousTag: candidate.previousTag,
});

// remove commit reference from auto-generate gapics
changelogEntry = changelogEntry.replace(/\s\(\[null\].*\n/, '\n');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I find this logic a little bit weird, I'll take a look before I land and see if we can simplify.


// don't create a release candidate until user facing changes
// (fix, feat, BREAKING CHANGE) have been made; a CHANGELOG that's
// one line is a good indicator that there were no interesting commits.
Expand All @@ -109,8 +122,6 @@ export class GoYoshi extends ReleasePR {

const updates: Update[] = [];

console.info(changelogEntry);

updates.push(
new Changelog({
path: this.addPath('CHANGES.md'),
Expand Down
78 changes: 66 additions & 12 deletions test/releasers/fixtures/yoshi-go/commits.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,43 @@
"edges": [
{
"node": {
"message": "fix(automl): update dependency com.google.cloud:google-cloud-storage to v1.120.0",
"oid": "fcd1c890dc1526f4d62ceedad561f498195c8939",
"message": "fix(automl): fixed a really bad bug",
"oid": "d7d1c890dc1526f4d62ceedad581f498195c8939",
"associatedPullRequests": {
"edges": [
{
"node": {
"mergeCommit": {
"oid": "fcd1c890dc1526f4d62ceedad561f498195c8939"
"oid": "d7d1c890dc1526f4d62ceedad581f498195c8939"
},
"number": 292,
"number": 293,
"labels": {
"edges": [
{
"node": {
"name": "cla: yes"
}
}
]
}
}
}
]
}
}
},
{
"node": {
"message": "feat(asset): added a really cool feature",
"oid": "d7d1c890dc1526f4d62ceedad581f498195c8939",
"associatedPullRequests": {
"edges": [
{
"node": {
"mergeCommit": {
"oid": "d7d1c890dc1526f4d62ceedad581f498195c8939"
},
"number": 293,
"labels": {
"edges": [
{
Expand Down Expand Up @@ -60,14 +87,41 @@
},
{
"node": {
"message": "fix(deps): update dependency com.google.cloud:google-cloud-spanner to v1.50.0",
"oid": "1f9663cf08ab1cf3b68d95dee4dc99b7c4aac373",
"message": "fix: this commit should be ignored",
"oid": "ecd1c890dc1526f4d62ceedad581f489195c8939",
"associatedPullRequests": {
"edges": [
{
"node": {
"mergeCommit": {
"oid": "1f9663cf08ab1cf3b68d95dee4dc99b7c4aac373"
"oid": "ecd1c890dc1526f4d62ceedad581f489195c8939"
},
"number": 293,
"labels": {
"edges": [
{
"node": {
"name": "cla: yes"
}
}
]
}
}
}
]
}
}
},
{
"node": {
"message": "feat(all): auto-regenerate gapics (#1000)",
"oid": "2f9663cf08ab1cf3b68d95dee4dc99b7c4aac372",
"associatedPullRequests": {
"edges": [
{
"node": {
"mergeCommit": {
"oid": "2f9663cf08ab1cf3b68d95dee4dc99b7c4aac372"
},
"number": 301,
"labels": {
Expand All @@ -87,16 +141,16 @@
},
{
"node": {
"message": "chore: update common templates",
"oid": "3006009a2b1b2cb4bd5108c0f469c410759f3a6a",
"message": "feat(all): auto-regenerate gapics (#1001)",
"oid": "1f9663cf08ab1cf3b68d95dee4dc99b7c4aac371",
"associatedPullRequests": {
"edges": [
{
"node": {
"mergeCommit": {
"oid": "3006009a2b1b2cb4bd5108c0f469c410759f3a6a"
"oid": "1f9663cf08ab1cf3b68d95dee4dc99b7c4aac371"
},
"number": 300,
"number": 301,
"labels": {
"edges": [
{
Expand All @@ -121,4 +175,4 @@
}
}
}
}
}