-
Notifications
You must be signed in to change notification settings - Fork 17
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
test(ci): add tests for release process #241
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,239 @@ | ||
import { | ||
parseCommit, | ||
getVersionChangesText, | ||
decideReleaseStrategy, | ||
} from '../create-release-issue'; | ||
|
||
describe('create release issue', () => { | ||
it('parses commit', () => { | ||
expect(parseCommit(`abcdefg fix(javascript): fix the thing`)).toEqual({ | ||
hash: 'abcdefg', | ||
lang: 'javascript', | ||
message: 'fix the thing', | ||
raw: 'abcdefg fix(javascript): fix the thing', | ||
type: 'fix', | ||
}); | ||
}); | ||
|
||
it('returns error when language scope is missing', () => { | ||
expect(parseCommit(`abcdefg fix: fix the thing`)).toEqual({ | ||
error: 'missing-language-scope', | ||
}); | ||
}); | ||
|
||
it('returns error when language scope is unknown', () => { | ||
expect(parseCommit(`abcdefg fix(basic): fix the thing`)).toEqual({ | ||
error: 'unknown-language-scope', | ||
}); | ||
}); | ||
|
||
it('generates text for version changes', () => { | ||
expect( | ||
getVersionChangesText({ | ||
javascript: { | ||
current: '0.0.1', | ||
next: '0.0.2', | ||
}, | ||
php: { | ||
current: '0.0.1', | ||
next: '0.0.2', | ||
}, | ||
java: { | ||
current: '0.0.1', | ||
next: '0.0.2', | ||
}, | ||
}) | ||
).toMatchInlineSnapshot(` | ||
"- [x] javascript: v0.0.1 -> v0.0.2 | ||
- [x] java: v0.0.1 -> v0.0.2 | ||
- [x] php: v0.0.1 -> v0.0.2" | ||
`); | ||
}); | ||
|
||
it('generates text for version changes with a language with no commit', () => { | ||
expect( | ||
getVersionChangesText({ | ||
javascript: { | ||
current: '0.0.1', | ||
next: '0.0.2', | ||
}, | ||
php: { | ||
current: '0.0.1', | ||
next: '0.0.1', | ||
noCommit: true, | ||
}, | ||
java: { | ||
current: '0.0.1', | ||
next: '0.0.2', | ||
}, | ||
}) | ||
).toMatchInlineSnapshot(` | ||
"- [x] javascript: v0.0.1 -> v0.0.2 | ||
- [x] java: v0.0.1 -> v0.0.2 | ||
- ~php: v0.0.1 (no commit)~" | ||
`); | ||
}); | ||
|
||
it('generates text for version changes with a language to skip', () => { | ||
expect( | ||
getVersionChangesText({ | ||
javascript: { | ||
current: '0.0.1', | ||
next: '0.0.2', | ||
}, | ||
php: { | ||
current: '0.0.1', | ||
next: '0.0.1', | ||
}, | ||
java: { | ||
current: '0.0.1', | ||
next: '0.0.2', | ||
skipRelease: true, | ||
}, | ||
}) | ||
).toMatchInlineSnapshot(` | ||
"- [x] javascript: v0.0.1 -> v0.0.2 | ||
- [ ] java: v0.0.1 -> v0.0.2 | ||
- No \`feat\` or \`fix\` commit, thus unchecked by default. | ||
- [x] php: v0.0.1 -> v0.0.1" | ||
`); | ||
}); | ||
|
||
it('bumps major version for BREAKING CHANGE', () => { | ||
const versions = decideReleaseStrategy({ | ||
versions: { | ||
javascript: { | ||
current: '0.0.1', | ||
}, | ||
java: { | ||
current: '0.0.1', | ||
}, | ||
php: { | ||
current: '0.0.1', | ||
}, | ||
}, | ||
commits: [ | ||
{ | ||
hash: 'abcdefg', | ||
type: 'feat', | ||
lang: 'javascript', | ||
message: 'update the API (BREAKING CHANGE)', | ||
raw: 'abcdefg feat(javascript): update the API (BREAKING CHANGE)', | ||
}, | ||
], | ||
}); | ||
|
||
expect(versions.javascript.next).toEqual('1.0.0'); | ||
}); | ||
|
||
it('bumps minor version for feat', () => { | ||
const versions = decideReleaseStrategy({ | ||
versions: { | ||
javascript: { | ||
current: '0.0.1', | ||
}, | ||
java: { | ||
current: '0.0.1', | ||
}, | ||
php: { | ||
current: '0.0.1', | ||
}, | ||
}, | ||
commits: [ | ||
{ | ||
hash: 'abcdefg', | ||
type: 'feat', | ||
lang: 'php', | ||
message: 'update the API', | ||
raw: 'abcdefg feat(php): update the API', | ||
}, | ||
], | ||
}); | ||
|
||
expect(versions.php.next).toEqual('0.1.0'); | ||
}); | ||
|
||
it('bumps patch version for fix', () => { | ||
const versions = decideReleaseStrategy({ | ||
versions: { | ||
javascript: { | ||
current: '0.0.1', | ||
}, | ||
java: { | ||
current: '0.0.1', | ||
}, | ||
php: { | ||
current: '0.0.1', | ||
}, | ||
}, | ||
commits: [ | ||
{ | ||
hash: 'abcdefg', | ||
type: 'fix', | ||
lang: 'java', | ||
message: 'fix some bug', | ||
raw: 'abcdefg fix(java): fix some bug', | ||
}, | ||
], | ||
}); | ||
|
||
expect(versions.java.next).toEqual('0.0.2'); | ||
}); | ||
|
||
it('marks noCommit for languages without any commit', () => { | ||
const versions = decideReleaseStrategy({ | ||
versions: { | ||
javascript: { | ||
current: '0.0.1', | ||
}, | ||
java: { | ||
current: '0.0.1', | ||
}, | ||
php: { | ||
current: '0.0.1', | ||
}, | ||
}, | ||
commits: [ | ||
{ | ||
hash: 'abcdefg', | ||
type: 'fix', | ||
lang: 'java', | ||
message: 'fix some bug', | ||
raw: 'abcdefg fix(java): fix some bug', | ||
}, | ||
], | ||
}); | ||
|
||
expect(versions.javascript.noCommit).toEqual(true); | ||
expect(versions.php.noCommit).toEqual(true); | ||
expect(versions.java.noCommit).toBeUndefined(); | ||
}); | ||
|
||
it('marks skipRelease for patch upgrade without fix commit', () => { | ||
const versions = decideReleaseStrategy({ | ||
versions: { | ||
javascript: { | ||
current: '0.0.1', | ||
}, | ||
java: { | ||
current: '0.0.1', | ||
}, | ||
php: { | ||
current: '0.0.1', | ||
}, | ||
}, | ||
commits: [ | ||
{ | ||
hash: 'abcdefg', | ||
type: 'chore', | ||
lang: 'javascript', | ||
message: 'update devDevpendencies', | ||
raw: 'abcdefg chore(javascript): update devDevpendencies', | ||
}, | ||
], | ||
}); | ||
expect(versions.javascript.skipRelease).toEqual(true); | ||
expect(versions.java.skipRelease).toBeUndefined(); | ||
expect(versions.php.skipRelease).toBeUndefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { getVersionsToRelease, getLangsToUpdateRepo } from '../process-release'; | ||
|
||
describe('process release', () => { | ||
it('gets versions to release', () => { | ||
const versions = getVersionsToRelease(` | ||
## Version Changes | ||
|
||
- [x] javascript: v1.0.0 -> v1.1.0 | ||
- [x] php: v2.0.0 -> v2.0.1 | ||
- [ ] java: v3.0.0 -> v3.0.1 | ||
`); | ||
|
||
expect(Object.keys(versions)).toEqual(['javascript', 'php']); | ||
expect(versions.javascript.current).toEqual('1.0.0'); | ||
expect(versions.javascript.next).toEqual('1.1.0'); | ||
expect(versions.php.current).toEqual('2.0.0'); | ||
expect(versions.php.next).toEqual('2.0.1'); | ||
}); | ||
|
||
it('gets langs to update', () => { | ||
expect( | ||
getLangsToUpdateRepo(` | ||
## Version Changes | ||
|
||
- [ ] javascript: v1.0.0 -> v1.1.0 | ||
- [x] php: v2.0.0 -> v2.0.1 | ||
- [ ] java: v3.0.0 -> v3.0.1 | ||
`) | ||
).toEqual(['javascript', 'java']); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't it be a
throw
or we handle this error?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It returns
error
and prints some warning logs.https://github.com/algolia/api-clients-automation/blob/d68ccee283af203e0e562c1cfb6ed0064b80b2d9/scripts/release/create-release-issue.ts#L204:L213
Assuming most of the commits follow semantic rules, some of commits might slip through (like "Merge ...."), and it shouldn't fail the release process. We can just ignore those commits and exclude from the changelogs, and versioning process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep that make sense, but I believe it would also make sense to have an error log in that case (maybe a file like yarn does for example, or a commit, or msg to slack).
Otherwise, we might not see the error and have release with missing commits, it might be intended to skip that commit in particular but it could also be a mistake on our side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I'm dumb it's in the issue then ._.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, it's not in the issue, but we should definitely include them in the issue, like
Expand to see skipped commit messages:
lack of language scope
unknown language scope
I can do this in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep it make sense then, we definitely need to track those